aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-05-05 22:50:27 +1000
committerSteve Bennett <steveb@workware.net.au>2023-06-22 08:34:19 +1000
commit29f2bbd1322e4c50e641188f113af4b334842351 (patch)
tree2ebd2a6408247dff1720fe85cd04b78cce084531 /jim-aio.c
parent578320daa421608c05fcad87842e4f0b66af3b6a (diff)
downloadjimtcl-tty-modem-control.zip
jimtcl-tty-modem-control.tar.gz
jimtcl-tty-modem-control.tar.bz2
aio: Add support for modem control signalstty-modem-control
RTS, DTR, etc. and sending a break condition Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/jim-aio.c b/jim-aio.c
index 7d96de3..2a2e7eb 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -1673,6 +1673,49 @@ static int aio_cmd_tty(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return ret;
}
+
+static int aio_cmd_ttycontrol(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+ AioFile *af = Jim_CmdPrivData(interp);
+ Jim_Obj *dictObjPtr;
+ int ret;
+
+ if (argc == 0) {
+ /* get the current settings as a dictionary */
+ dictObjPtr = Jim_GetTtyControlSettings(interp, af->fd);
+ if (dictObjPtr == NULL) {
+ JimAioSetError(interp, NULL);
+ return JIM_ERR;
+ }
+ Jim_SetResult(interp, dictObjPtr);
+ return JIM_OK;
+ }
+
+ if (argc > 1) {
+ /* Convert name value arguments to a dictionary */
+ dictObjPtr = Jim_NewListObj(interp, argv, argc);
+ }
+ else {
+ /* The settings are already given as a list */
+ dictObjPtr = argv[0];
+ }
+ Jim_IncrRefCount(dictObjPtr);
+
+ if (Jim_ListLength(interp, dictObjPtr) % 2) {
+ /* Must be a valid dictionary */
+ Jim_DecrRefCount(interp, dictObjPtr);
+ return -1;
+ }
+
+ ret = Jim_SetTtyControlSettings(interp, af->fd, dictObjPtr);
+ if (ret < 0) {
+ JimAioSetError(interp, NULL);
+ ret = JIM_ERR;
+ }
+ Jim_DecrRefCount(interp, dictObjPtr);
+
+ return ret;
+}
#endif /* JIM_BOOTSTRAP */
static const jim_subcmd_type aio_command_table[] = {
@@ -1911,6 +1954,13 @@ static const jim_subcmd_type aio_command_table[] = {
-1,
/* Description: Get or set tty settings - valid only on a tty */
},
+ { "ttycontrol",
+ "?rts 0|1? ?dtr 0|1?",
+ aio_cmd_ttycontrol,
+ 0,
+ -1,
+ /* Description: Get or set tty modem control settings - valid only on a tty */
+ },
#endif
#endif /* JIM_BOOTSTRAP */
{ NULL }