Add tty line configuration script API

On some platforms calling high()/low() to switch line states result in
costly system calls whick makes it impossible to swith two or more tty
lines simultaneously.

To help solve this timing issue we introduce a tty line state
configuration API which can be used instead of using
high()/low().

Using config_low(line) and config_high(line) one can set up a new line
state configuration for multiple lines and then use config_apply() to
finally apply the configuration. This will result in only one system
call to instruct the serial port drive to switch all the configured line
states which should help ensure that the lines are switched
simultaneously.

Example:

script = config_high(DTR); config_low(RTS); config_apply()
This commit is contained in:
Martin Lund 2024-04-06 09:17:01 +02:00
parent 4369d5b66f
commit 3e50191107
4 changed files with 167 additions and 77 deletions

View file

@ -383,6 +383,14 @@ Toggle the tty line.
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