From 003b2e37d4858d808278387d83858ee979ad7df0 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sun, 2 Jun 2024 23:34:33 +0200 Subject: [PATCH] Make sure ICRNL, IGNCR, INLCR take effect --- src/tty.c | 17 ++++++++++++++--- src/tty.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tty.c b/src/tty.c index d6356bf..bb90d12 100644 --- a/src/tty.c +++ b/src/tty.c @@ -749,13 +749,13 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward) switch (input_char) { case KEY_0: - tio.c_iflag ^= ICRNL; option.map_i_cr_nl = !option.map_i_cr_nl; + tty_reconfigure(); tio_printf("ICRNL is %s", option.map_i_cr_nl ? "set" : "unset"); break; case KEY_1: - tio.c_iflag ^= IGNCR; option.map_ign_cr = !option.map_ign_cr; + tty_reconfigure(); tio_printf("IGNCR is %s", option.map_ign_cr ? "set" : "unset"); break; case KEY_2: @@ -763,8 +763,8 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward) tio_printf("IFFESCC is %s", option.map_i_ff_escc ? "set" : "unset"); break; case KEY_3: - tio.c_iflag ^= INLCR; option.map_i_nl_cr = !option.map_i_nl_cr; + tty_reconfigure(); tio_printf("INLCR is %s", option.map_i_nl_cr ? "set" : "unset"); break; case KEY_4: @@ -1365,6 +1365,17 @@ void tty_configure(void) } } +void tty_reconfigure(void) +{ + tty_configure(); + + if (connected) + { + /* Activate new port settings */ + tcsetattr(device_fd, TCSANOW, &tio); + } +} + static bool is_serial_device(const char *format, ...) { char filename[PATH_MAX]; diff --git a/src/tty.h b/src/tty.h index a04304d..39c64af 100644 --- a/src/tty.h +++ b/src/tty.h @@ -75,6 +75,7 @@ extern bool interactive_mode; void stdout_configure(void); void stdin_configure(void); void tty_configure(void); +void tty_reconfigure(void); int tty_connect(void); void tty_wait_for_device(void); void list_serial_devices(void);