mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Various cleanup
Renamed device -> tty_device. Removed hardcoded tty device name max length. Updated README.
This commit is contained in:
parent
9721f2436c
commit
cc7f21e735
4 changed files with 9 additions and 9 deletions
2
README
2
README
|
|
@ -19,7 +19,7 @@
|
|||
(output from 'gotty --help'):
|
||||
|
||||
|
||||
Usage: gotty [<options>] <device>
|
||||
Usage: gotty [<options>] <tty device>
|
||||
|
||||
Options:
|
||||
-b, --baudrate <baudrate> Baud rate (default: 115200)
|
||||
|
|
|
|||
|
|
@ -25,11 +25,12 @@
|
|||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include <termios.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/* Options */
|
||||
struct option_t
|
||||
{
|
||||
char device[256];
|
||||
char tty_device[MAXPATHLEN];
|
||||
bool no_autoconnect;
|
||||
struct termios tio;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct option_t option =
|
|||
|
||||
void print_options_help(char *argv[])
|
||||
{
|
||||
printf("Usage: %s [<options>] <device>\n", argv[0]);
|
||||
printf("Usage: %s [<options>] <tty device>\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("Options:\n");
|
||||
printf(" -b, --baudrate <baudrate> Baud rate (default: 115200)\n");
|
||||
|
|
@ -324,9 +324,9 @@ void parse_options(int argc, char *argv[])
|
|||
|
||||
/* Assume first non-option is the tty device name */
|
||||
if (optind < argc)
|
||||
strcpy(option.device, argv[optind++]);
|
||||
strcpy(option.tty_device, argv[optind++]);
|
||||
|
||||
if (strlen(option.device) == 0)
|
||||
if (strlen(option.tty_device) == 0)
|
||||
{
|
||||
printf("Error: Missing device name.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -34,8 +35,6 @@
|
|||
#include "gotty/print.h"
|
||||
#include "gotty/options.h"
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
static int connected = false;
|
||||
struct termios new_stdout, old_stdout, old_tio;
|
||||
static int fd;
|
||||
|
|
@ -78,7 +77,7 @@ void wait_for_tty_device(void)
|
|||
/* Timeout */
|
||||
|
||||
/* Test for device file */
|
||||
if (stat(option.device, &status) == 0)
|
||||
if (stat(option.tty_device, &status) == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -146,7 +145,7 @@ int connect_tty(void)
|
|||
char c_stdin[3];
|
||||
|
||||
/* Open tty device */
|
||||
fd = open(option.device, O_RDWR | O_NOCTTY );
|
||||
fd = open(option.tty_device, O_RDWR | O_NOCTTY );
|
||||
if (fd <0)
|
||||
{
|
||||
printf("\033[300DError: %s\n\033[300D", strerror(errno));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue