* Serial back end (Unix-specific).
*/
-/*
- * TODO:
- *
- * - send break.
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
logevent(serial->frontend, msg);
sfree(msg);
- options.c_cflag &= ~(IXON|IXOFF);
+ options.c_iflag &= ~(IXON|IXOFF);
+#ifdef CRTSCTS
+ options.c_cflag &= ~CRTSCTS;
+#endif
+#ifdef CNEW_RTSCTS
+ options.c_cflag &= ~CNEW_RTSCTS;
+#endif
if (cfg->serflow == SER_FLOW_XONXOFF) {
- options.c_cflag |= IXON | IXOFF;
+ options.c_iflag |= IXON | IXOFF;
str = "XON/XOFF";
} else if (cfg->serflow == SER_FLOW_RTSCTS) {
#ifdef CRTSCTS
options.c_cflag |= CLOCAL | CREAD;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
- options.c_oflag &= ~OPOST;
+ options.c_iflag &= ~(ISTRIP | IGNCR | INLCR | ICRNL
+#ifdef IUCLC
+ | IUCLC
+#endif
+ );
+ options.c_oflag &= ~(OPOST
+#ifdef ONLCR
+ | ONLCR
+#endif
+#ifdef OCRNL
+ | OCRNL
+#endif
+#ifdef ONOCR
+ | ONOCR
+#endif
+#ifdef ONLRET
+ | ONLRET
+#endif
+ );
options.c_cc[VMIN] = 1;
options.c_cc[VTIME] = 0;
if (serial->fd < 0)
return "Unable to open serial port";
+ cloexec(serial->fd);
+
err = serial_configure(serial, cfg);
if (err)
return err;
serial_uxsel_setup(serial);
+ /*
+ * Specials are always available.
+ */
+ update_specials_menu(serial->frontend);
+
return NULL;
}
*/
static void serial_special(void *handle, Telnet_Special code)
{
- /*
- * FIXME: serial break? XON? XOFF?
- */
+ Serial serial = (Serial) handle;
+
+ if (serial->fd >= 0 && code == TS_BRK) {
+ tcsendbreak(serial->fd, 0);
+ logevent(serial->frontend, "Sending serial break at user request");
+ }
+
return;
}
*/
static const struct telnet_special *serial_get_specials(void *handle)
{
- /*
- * FIXME: serial break? XON? XOFF?
- */
- return NULL;
+ static const struct telnet_special specials[] = {
+ {"Break", TS_BRK},
+ {NULL, TS_EXITMENU}
+ };
+ return specials;
}
static int serial_connected(void *handle)
serial_provide_logctx,
serial_unthrottle,
serial_cfg_info,
- 1
+ "serial",
+ PROT_SERIAL,
+ 0
};