Add ONULBRK mapping flag

Add ONULBRK mapping to map nul (zero) to send break signal on output.

This is useful if one needs to e.g. send the break signal to the tty
device when connected via socket.
This commit is contained in:
Martin Lund 2024-04-05 13:46:12 +02:00
parent 70913fe120
commit 4369d5b66f
2 changed files with 15 additions and 1 deletions

View file

@ -182,6 +182,8 @@ Map DEL to BS on output
Map NL to CR-NL on output
.IP "\fBOLTU"
Map lowercase characters to uppercase on output
.IP "\fBONULBRK"
Map nul (zero) to send break signal on output
.IP "\fBMSB2LSB"
Map MSB bit order to LSB on output
.P

View file

@ -153,6 +153,7 @@ static bool map_o_cr_nl = false;
static bool map_o_nl_crnl = false;
static bool map_o_del_bs = false;
static bool map_o_ltu = false;
static bool map_o_nulbrk = false;
static bool map_o_msblsb = false;
static char hex_chars[2];
static unsigned char hex_char_index = 0;
@ -1115,6 +1116,10 @@ void tty_configure(void)
{
map_o_ltu = true;
}
else if (strcmp(token, "ONULBRK") == 0)
{
map_o_nulbrk = true;
}
else if (strcmp(token, "MSB2LSB") == 0)
{
map_o_msblsb = true;
@ -1289,7 +1294,14 @@ void forward_to_tty(int fd, char output_char)
{
/* Send output to tty device */
optional_local_echo(output_char);
status = tty_write(fd, &output_char, 1);
if ((output_char == 0) && (map_o_nulbrk))
{
status = tcsendbreak(fd, 0);
}
else
{
status = tty_write(fd, &output_char, 1);
}
if (status < 0)
{
tio_warning_printf("Could not write to tty device");