From 944ee9173b7120f4972e0c9566b1b371efbeea44 Mon Sep 17 00:00:00 2001 From: Robert Snell Date: Sat, 9 Jul 2022 21:22:43 -0400 Subject: [PATCH] Additional commands: EOL delay, lower to upper translation, added mark parity Added command line options: -O, --eol-delay to have a separate delay for end of line -U, --upper to enable translation of lower case alpha to upper case Added ability to set mark parity. Added ctrl-t U key sequence to allow enable/disable lower case alpha to upper case during a session. Updated Man page with command line options, ctrl-t sequences and configuration file options. Updated README.md, with above information. --- README.md | 13 ++++++++++++- man/tio.1.in | 17 ++++++++++++++++- src/configfile.c | 8 ++++++++ src/options.c | 20 ++++++++++++++++++-- src/options.h | 2 ++ src/tty.c | 43 +++++++++++++++++++++++++++++++++++++++++-- src/tty.h | 1 + 7 files changed, 98 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93d747e..c67b48f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,9 @@ when used in combination with [tmux](https://tmux.github.io). * Local echo support * Remap special characters (nl, cr-nl, bs, etc.) * Line timestamps - * Support for delayed output + * Support for delayed output per transmitted character + * Support for delayed output per line + * Support for translation of lower case to upper case * Hexadecimal mode * Log to file * Autogeneration of log filename @@ -66,6 +68,13 @@ The command-line interface is straightforward as reflected in the output from -s, --stopbits 1|2 Stop bits (default: 1) -p, --parity odd|even|none Parity (default: none) -o, --output-delay Character output delay (default: 0) + -O, --eol-delay EOL output delay (default: 0) + --dtr-pulse-duration DTR pulse duration (default: 100) + -n, --no-autoconnect Disable automatic connect + -e, --local-echo Enable local echo + -t, --timestamp Enable line timestamp + --timestamp-format Set timestamp format (default: 24hour) + -L, --list-devices List available serial devices --dtr-pulse-duration DTR pulse duration (default: 100) -n, --no-autoconnect Disable automatic connect -e, --local-echo Enable local echo @@ -79,6 +88,7 @@ The command-line interface is straightforward as reflected in the output from -c, --color 0..255|none|list Colorize tio text (default: 15) -S, --socket Redirect I/O to file or network socket -x, --hexadecimal Enable hexadecimal mode + -U, --upper Enable translation of lower case to upper -v, --version Display version -h, --help Display help @@ -137,6 +147,7 @@ ctrl-t ? to list the available key commands. [20:19:12.041] ctrl-t s Show statistics [20:19:12.041] ctrl-t t Send ctrl-t key code [20:19:12.041] ctrl-t T Toggle line timestamp mode +[20:19:12.041] ctrl-t U Toggle lower case alpha to upper case [20:19:12.041] ctrl-t v Show version ``` diff --git a/man/tio.1.in b/man/tio.1.in index 7132e64..46001d5 100644 --- a/man/tio.1.in +++ b/man/tio.1.in @@ -34,7 +34,7 @@ Set flow control (default: none). Set stop bits (default: 1). .TP -.BR \-p ", " "\-\-parity odd" | even | none +.BR \-p ", " "\-\-parity odd" | even | none | mark Set parity (default: none). .TP @@ -42,6 +42,15 @@ Set parity (default: none). Set output delay [ms] inserted between each sent character (default: 0). +.TP +.BR \-O ", " "\-\-eol\-delay " \fI + +Set EOL delay [ms] inserted between each sent line (default: 0). + +.TP +.BR \-U ", " \-\-upcase" + +Convert any entered lower case alpha to upper case (default: disabled) .TP .BR " \-\-dtr\-pulse\-duration " \fI @@ -209,6 +218,8 @@ Toggle DTR Pulse DTR .IP "\fBctrl-t r" Toggle RTS +.IP "\fBctrl-t U" +Toggle upcase .IP "\fBctrl-t v" Show version @@ -262,6 +273,10 @@ Set stop bits Set parity .IP "\fBoutput-delay" Set output delay +.IP "\fBeol-delay" +Set EOL delay +.IP "\fBupcase" +Set translation of alpha from lower to upper case .IP "\fBdtr-pulse-duration" Set DTR pulse duration .IP "\fBno-autoconnect" diff --git a/src/configfile.c b/src/configfile.c index 84c76d2..c85f163 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -124,6 +124,14 @@ static int data_handler(void *user, const char *section, const char *name, { option.output_delay = atoi(value); } + else if (!strcmp(name, "eol-delay")) + { + option.eol_delay = atoi(value); + } + else if ( !strcmp(name, "upcase")) + { + option.upcase = true; + } else if (!strcmp(name, "dtr-pulse-duration")) { option.dtr_pulse_duration = atoi(value); diff --git a/src/options.c b/src/options.c index 00a21c4..4170ac2 100644 --- a/src/options.c +++ b/src/options.c @@ -56,6 +56,8 @@ struct option_t option = .parity = "none", .output_delay = 0, .dtr_pulse_duration = 100, + .eol_delay = 0, + .upcase = false, .no_autoconnect = false, .log = false, .log_filename = NULL, @@ -79,8 +81,9 @@ void print_help(char *argv[]) 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(" -p, --parity odd|even|none|mark Parity (default: none)\n"); printf(" -o, --output-delay Output delay (default: 0)\n"); + printf(" -O, --eol-delay EOL output delay (default: 0)\n"); printf(" --dtr-pulse-duration DTR pulse duration (default: 100)\n"); printf(" -n, --no-autoconnect Disable automatic connect\n"); printf(" -e, --local-echo Enable local echo\n"); @@ -94,6 +97,7 @@ void print_help(char *argv[]) printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n"); printf(" -S, --socket Redirect I/O to file or network socket\n"); printf(" -x, --hexadecimal Enable hexadecimal mode\n"); + printf(" -U, --upcase Translate lower case alpha to upper case\n"); printf(" -v, --version Display version\n"); printf(" -h, --help Display help\n"); printf("\n"); @@ -172,6 +176,8 @@ void options_print() tio_printf(" Local echo: %s", option.local_echo ? "enabled" : "disabled"); tio_printf(" Timestamp: %s", timestamp_state_to_string(option.timestamp)); tio_printf(" Output delay: %d", option.output_delay); + tio_printf(" EOL delay: %d", option.eol_delay); + tio_printf(" Upcase: %s", option.upcase ? "enabled" : "disabled"); tio_printf(" DTR pulse duration: %d", option.dtr_pulse_duration); tio_printf(" Auto connect: %s", option.no_autoconnect ? "disabled" : "enabled"); if (option.map[0] != 0) @@ -202,6 +208,8 @@ void options_parse(int argc, char *argv[]) {"stopbits", required_argument, 0, 's' }, {"parity", required_argument, 0, 'p' }, {"output-delay", required_argument, 0, 'o' }, + {"eol-delay", required_argument, 0, 'O' }, + {"upcase", no_argument, 0, 'U' }, {"dtr-pulse-duration", required_argument, 0, OPT_DTR_PULSE_DURATION }, {"no-autoconnect", no_argument, 0, 'n' }, {"local-echo", no_argument, 0, 'e' }, @@ -224,7 +232,7 @@ void options_parse(int argc, char *argv[]) int option_index = 0; /* Parse argument using getopt_long */ - c = getopt_long(argc, argv, "b:d:f:s:p:o:netLlS:m:c:xvh", long_options, &option_index); + c = getopt_long(argc, argv, "b:d:f:s:p:o:O:UnetLlS:m:c:xvh", long_options, &option_index); /* Detect the end of the options */ if (c == -1) @@ -266,6 +274,10 @@ void options_parse(int argc, char *argv[]) option.output_delay = string_to_long(optarg); break; + case 'O': + option.eol_delay = string_to_long(optarg); + break; + case OPT_DTR_PULSE_DURATION: option.dtr_pulse_duration = string_to_long(optarg); break; @@ -341,6 +353,10 @@ void options_parse(int argc, char *argv[]) option.hex_mode = true; break; + case 'U': + option.upcase = true; + break; + case 'v': printf("tio v%s\n", VERSION); printf("Copyright (c) 2014-2022 Martin Lund\n"); diff --git a/src/options.h b/src/options.h index b005a1a..1dbe724 100644 --- a/src/options.h +++ b/src/options.h @@ -49,6 +49,8 @@ struct option_t char *parity; int output_delay; int dtr_pulse_duration; + int eol_delay; + bool upcase; bool no_autoconnect; bool log; bool log_strip; diff --git a/src/tty.c b/src/tty.c index 4c09988..f041482 100644 --- a/src/tty.c +++ b/src/tty.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -146,11 +147,16 @@ ssize_t tty_write(int fd, const void *buffer, size_t count) { ssize_t bytes_written = 0; - if (option.output_delay) + if (option.output_delay || option.eol_delay ) { // Write byte by byte with output delay for (size_t i=0; i