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

@ -39,5 +39,7 @@ void tty_wait_for_device(void);
void list_serial_devices(void);
void tty_input_thread_create(void);
void tty_input_thread_wait_ready(void);
void tty_line_set(int fd, const char *name, int mask, bool value);
void tty_line_toggle(int fd, const char *name, int mask);
void tty_line_set(int fd, int mask, bool value);
void tty_line_toggle(int fd, int mask);
void tty_line_config(int mask, bool value);
void tty_line_config_apply(void);