mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Renamed --char-delay to --output-delay
Renaming to make the naming more specific for the feature.
This commit is contained in:
parent
ab54352b51
commit
4eaff1df9d
6 changed files with 23 additions and 13 deletions
1
README
1
README
|
|
@ -27,6 +27,7 @@
|
|||
-f, --flow hard|soft|none Flow control (default: none)
|
||||
-s, --stopbits 1|2 Stop bits (default: 1)
|
||||
-p, --parity even|odd|none Parity (default: none)
|
||||
-o, --output-delay <ms> Output delay (default: 0)
|
||||
-n, --no-autoconnect Disable automatic connect
|
||||
-v, --version Display version
|
||||
-h, --help Display help
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ Set stop bits (default: 1).
|
|||
|
||||
Set parity (default: none).
|
||||
.TP
|
||||
.B \-o, \--output-delay <ms>
|
||||
|
||||
Set output delay [ms] - delay inserted between each transmitted character (default: 0).
|
||||
.TP
|
||||
.B \-n, \--no-autoconnect
|
||||
|
||||
Disable automatic connect.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ _gotty()
|
|||
-f --flow \
|
||||
-s --stopbits \
|
||||
-p --parity \
|
||||
-o --output-delay \
|
||||
-n --no-autoconnect \
|
||||
-v --version \
|
||||
-h --help"
|
||||
|
|
@ -70,6 +71,10 @@ _gotty()
|
|||
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-o | --output-delay)
|
||||
COMPREPLY=( $(compgen -W "0 1 10 100" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-n | --no-autoconnect)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ struct option_t
|
|||
char tty_device[MAXPATHLEN];
|
||||
bool no_autoconnect;
|
||||
struct termios tio;
|
||||
int char_delay;
|
||||
int output_delay;
|
||||
};
|
||||
|
||||
extern struct option_t option;
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ void print_options_help(char *argv[])
|
|||
printf("\n");
|
||||
printf("Options:\n");
|
||||
printf(" -b, --baudrate <baudrate> Baud rate (default: 115200)\n");
|
||||
printf(" -c, --char-delay <ms> Character delay (default: 0)\n");
|
||||
printf(" -d, --databits 5|6|7|8 Data bits (default: 8)\n");
|
||||
printf(" -f, --flow hard|soft|none Flow control (default: none)\n");
|
||||
printf(" -s, --stopbits 1|2 Stop bits (default: 1)\n");
|
||||
printf(" -p, --parity odd|even|none Parity (default: none)\n");
|
||||
printf(" -o, --output-delay <ms> Output delay (default: 0)\n");
|
||||
printf(" -n, --no-autoconnect Disable automatic connect\n");
|
||||
printf(" -v, --version Display version\n");
|
||||
printf(" -h, --help Display help\n");
|
||||
|
|
@ -74,8 +74,8 @@ void parse_options(int argc, char *argv[])
|
|||
bzero(&option.tio, sizeof(option.tio));
|
||||
option.tio.c_cflag = B115200 | CS8;
|
||||
|
||||
/* Set default char delay */
|
||||
option.char_delay = 0;
|
||||
/* Set default output delay */
|
||||
option.output_delay = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
|
@ -86,10 +86,10 @@ void parse_options(int argc, char *argv[])
|
|||
{"flow", required_argument, 0, 'f'},
|
||||
{"stopbits", required_argument, 0, 's'},
|
||||
{"parity", required_argument, 0, 'p'},
|
||||
{"output-delay", required_argument, 0, 'o'},
|
||||
{"no-autoconnect", no_argument, 0, 'n'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"char-delay", required_argument, 0, 'c'},
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ void parse_options(int argc, char *argv[])
|
|||
int option_index = 0;
|
||||
|
||||
/* Parse argument using getopt_long */
|
||||
c = getopt_long(argc, argv, "b:c:d:f:s:p:nvh", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:nvh", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options */
|
||||
if (c == -1)
|
||||
|
|
@ -216,10 +216,6 @@ void parse_options(int argc, char *argv[])
|
|||
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
option.char_delay = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
databits = atoi(optarg);
|
||||
option.tio.c_cflag &= ~CSIZE;
|
||||
|
|
@ -302,6 +298,10 @@ void parse_options(int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
option.output_delay = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
option.no_autoconnect = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -235,9 +235,9 @@ int connect_tty(void)
|
|||
/* Forward input to tty device */
|
||||
status = write(fd, &c_stdin[0], 1);
|
||||
|
||||
/* Insert char delay */
|
||||
if (option.char_delay)
|
||||
usleep(option.char_delay * 1000);
|
||||
/* Insert output delay */
|
||||
if (option.output_delay)
|
||||
usleep(option.output_delay * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue