Make sure ICRNL, IGNCR, INLCR take effect

This commit is contained in:
Martin Lund 2024-06-02 23:34:33 +02:00
parent 8014ef68c0
commit 003b2e37d4
2 changed files with 15 additions and 3 deletions

View file

@ -749,13 +749,13 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward)
switch (input_char) switch (input_char)
{ {
case KEY_0: case KEY_0:
tio.c_iflag ^= ICRNL;
option.map_i_cr_nl = !option.map_i_cr_nl; option.map_i_cr_nl = !option.map_i_cr_nl;
tty_reconfigure();
tio_printf("ICRNL is %s", option.map_i_cr_nl ? "set" : "unset"); tio_printf("ICRNL is %s", option.map_i_cr_nl ? "set" : "unset");
break; break;
case KEY_1: case KEY_1:
tio.c_iflag ^= IGNCR;
option.map_ign_cr = !option.map_ign_cr; option.map_ign_cr = !option.map_ign_cr;
tty_reconfigure();
tio_printf("IGNCR is %s", option.map_ign_cr ? "set" : "unset"); tio_printf("IGNCR is %s", option.map_ign_cr ? "set" : "unset");
break; break;
case KEY_2: 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"); tio_printf("IFFESCC is %s", option.map_i_ff_escc ? "set" : "unset");
break; break;
case KEY_3: case KEY_3:
tio.c_iflag ^= INLCR;
option.map_i_nl_cr = !option.map_i_nl_cr; option.map_i_nl_cr = !option.map_i_nl_cr;
tty_reconfigure();
tio_printf("INLCR is %s", option.map_i_nl_cr ? "set" : "unset"); tio_printf("INLCR is %s", option.map_i_nl_cr ? "set" : "unset");
break; break;
case KEY_4: 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, ...) static bool is_serial_device(const char *format, ...)
{ {
char filename[PATH_MAX]; char filename[PATH_MAX];

View file

@ -75,6 +75,7 @@ extern bool interactive_mode;
void stdout_configure(void); void stdout_configure(void);
void stdin_configure(void); void stdin_configure(void);
void tty_configure(void); void tty_configure(void);
void tty_reconfigure(void);
int tty_connect(void); int tty_connect(void);
void tty_wait_for_device(void); void tty_wait_for_device(void);
void list_serial_devices(void); void list_serial_devices(void);