server: put VUART terminal into raw mode
We want raw data from the vuart device, with any processing occuring
only on the client's tty.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/console-server.c b/console-server.c
index 9677064..f60629c 100644
--- a/console-server.c
+++ b/console-server.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <getopt.h>
#include <limits.h>
+#include <termios.h>
#include <sys/types.h>
#include <sys/poll.h>
@@ -159,6 +160,27 @@
}
/**
+ * Set console to raw mode: we don't want any processing to occur on
+ * the underlying terminal input/output.
+ */
+static void tty_init_termios(struct console *console)
+{
+ struct termios termios;
+ int rc;
+
+ rc = tcgetattr(console->tty_fd, &termios);
+ if (rc) {
+ warn("Can't read tty termios");
+ return;
+ }
+
+ cfmakeraw(&termios);
+ rc = tcsetattr(console->tty_fd, TCSANOW, &termios);
+ if (rc)
+ warn("Can't set terminal raw mode for tty");
+}
+
+/**
* Open and initialise the serial device
*/
static int tty_init_io(struct console *console)
@@ -180,6 +202,8 @@
*/
fcntl(console->tty_fd, F_SETFL, FNDELAY);
+ tty_init_termios(console);
+
console->pollfds[console->n_pollers].fd = console->tty_fd;
console->pollfds[console->n_pollers].events = POLLIN;