From 474bab96aaa42526fdd5283a925e540679ae0bfe Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Tue, 5 May 2020 21:45:41 +1000 Subject: aio: tty: Add support for vstart and vstop xonxoff start and stop chars Signed-off-by: Steve Bennett --- jim-aio.c | 2 +- jim-tty.c | 25 +++++++++++++++++-------- jim_tcl.txt | 6 ++++++ tests/tty.test | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/jim-aio.c b/jim-aio.c index f199433..0805d41 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -2145,7 +2145,7 @@ static const jim_subcmd_type aio_command_table[] = { #endif #if defined(HAVE_TERMIOS_H) { "tty", - "?baud rate? ?data bits? ?stop bits? ?parity even|odd|none? ?handshake xonxoff|rtscts|none? ?input raw|cooked? ?output raw|cooked? ?echo 0|1? ?vmin n? ?vtime n?", + "?baud rate? ?data bits? ?stop bits? ?parity even|odd|none? ?handshake xonxoff|rtscts|none? ?input raw|cooked? ?output raw|cooked? ?echo 0|1? ?vmin n? ?vtime n? ?vstart char? ?vstop char?", aio_cmd_tty, 0, -1, diff --git a/jim-tty.c b/jim-tty.c index b3faaba..534e65c 100644 --- a/jim-tty.c +++ b/jim-tty.c @@ -79,6 +79,8 @@ static const char * const tty_settings_names[] = { "vmin", "vtime", "echo", + "vstart", + "vstop", NULL }; @@ -92,7 +94,9 @@ enum { OPT_STOP, OPT_VMIN, OPT_VTIME, - OPT_ECHO + OPT_ECHO, + OPT_VSTART, + OPT_VSTOP, }; @@ -184,6 +188,10 @@ Jim_Obj *Jim_GetTtySettings(Jim_Interp *interp, int fd) Jim_ListAppendElement(interp, listObjPtr, Jim_NewIntObj(interp, tio.c_cc[VMIN])); Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, "vtime", -1)); Jim_ListAppendElement(interp, listObjPtr, Jim_NewIntObj(interp, tio.c_cc[VTIME])); + Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, "vstart", -1)); + Jim_ListAppendElement(interp, listObjPtr, Jim_NewIntObj(interp, tio.c_cc[VSTART])); + Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, "vstop", -1)); + Jim_ListAppendElement(interp, listObjPtr, Jim_NewIntObj(interp, tio.c_cc[VSTOP])); speed = cfgetispeed(&tio); baud = 0; @@ -283,17 +291,18 @@ badvalue: break; case OPT_VMIN: - if (Jim_GetLong(interp, valueObj, &l) != JIM_OK) { - goto badvalue; - } - tio.c_cc[VMIN] = l; - break; - case OPT_VTIME: + case OPT_VSTART: + case OPT_VSTOP: if (Jim_GetLong(interp, valueObj, &l) != JIM_OK) { goto badvalue; } - tio.c_cc[VTIME] = l; + switch (opt) { + case OPT_VMIN: tio.c_cc[VMIN] = l; break; + case OPT_VTIME: tio.c_cc[VTIME] = l; break; + case OPT_VSTART: tio.c_cc[VSTART] = l; break; + case OPT_VSTOP: tio.c_cc[VSTOP] = l; break; + } break; case OPT_OUTPUT: diff --git a/jim_tcl.txt b/jim_tcl.txt index a92ba9f..05a2e26 100644 --- a/jim_tcl.txt +++ b/jim_tcl.txt @@ -5173,6 +5173,12 @@ This command returns an empty string. +*vtime* 'time'+;; Timeout for noncanonical read (units of 0.1 seconds) + +*vstart* 'char'+;; + Start character for xonoff, usually 0x11 (^Q) + + +*vstop* 'char'+;; + Stop character for xonoff, usually 0x13 (^S) + +$handle *ssl* ?*-server* 'cert ?key?'|*-sni* 'servername'?+:: Upgrades the stream to a SSL/TLS session and returns the handle. If +-server+ is specified, either both the certificate and private key files diff --git a/tests/tty.test b/tests/tty.test index 104683f..b710c78 100644 --- a/tests/tty.test +++ b/tests/tty.test @@ -25,7 +25,7 @@ test tty-1.1 {tty status} { test tty-1.2 {tty bad param} -body { $chan tty bad value -} -returnCodes error -result {bad setting "bad": must be baud, data, echo, handshake, input, output, parity, stop, vmin, or vtime} +} -returnCodes error -result {bad setting "bad": must be baud, data, echo, handshake, input, output, parity, stop, vmin, vstart, vstop, or vtime} test tty-1.3 {tty bad baud} -body { $chan tty baud 12345 -- cgit v1.1