Simplify lua line manipulation API

Collapses lua high(), low(), toggle(), config_high(), config_low(),
config_apply() into one simple function:

set{<line>=<state>, ...}

Line can be any of DTR, RTS, CTS, DSR, CD, RI.

State is high, low, or toggle.

Example:
script = set{DTR=high, RTS=low}; msleep(100); set{DTR=low, RTS=high}; msleep(100); set{RTS=low}

Notice the use of {} instad of () when calling the set function. This is
required to pass parameters by name in lua.
This commit is contained in:
Martin Lund 2024-04-29 14:45:36 +02:00
parent eef0a15194
commit 6d77201ba0
6 changed files with 112 additions and 211 deletions

View file

@ -457,29 +457,19 @@ until data is ready to read.
Returns number of bytes read on success, 0 on timeout, or -1 on error.
.IP "\fBexit(code)"
Exit with exit code.
.IP "\fBhigh(line)"
Set tty line high.
.IP "\fBlow(line)"
Set tty line low.
.IP "\fBtoggle(line)"
Toggle the tty line.
.IP "\fBset{line=state, ...}"
Set state of one or multiple tty modem lines.
Line can be any of DTR, RTS, CTS, DSR, CD, RI
State is high, low, or toggle.
.IP "\fBsleep(seconds)"
Sleep for seconds.
.IP "\fBmsleep(ms)"
Sleep for miliseconds.
.IP "\fBconfig_high(line)"
Set tty line state configuration to high.
.IP "\fBconfig_low(line)"
Set tty line state configuration to low.
.IP "\fBapply_config()"
Apply tty line state configuration. Using the line state configuration API
instead of high()/low() will help to make the lines physically switch as
simultaneously as possible. This may solve timing issues on some platforms.
.TP 0n
Note: Line can be any of DTR, RTS, CTS, DSR, CD, RI
.IP "\fBexit(code)"
Exit with exit code.
.SH "CONFIGURATION FILE"
.PP