From 6f875e13e7038cb0e2a93f877083c8a1020bba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Wed, 22 Feb 2017 22:46:10 +0100 Subject: [PATCH] Make serial device sort of work. One way. --- src/device_serial.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/device_serial.c b/src/device_serial.c index efe3e92..1bdcc63 100644 --- a/src/device_serial.c +++ b/src/device_serial.c @@ -11,7 +11,7 @@ #include "bus.h" #include "device.h" -const static char *pipepath = "/tmp/serial"; /* should really be configurable */ +const static char *pipepath = "/tmp/serial_tx"; /* should really be configurable */ struct device_serial_priv { int pipefd; @@ -43,6 +43,8 @@ device_serial_write_1(void *vd, uint16_t offset, uint8_t val) d = (device_t *) vd; dp = d->aux; + /*fprintf(stderr, "writing to fd %d val %x", dp->pipefd, val);*/ + write(dp->pipefd, &val, 1); fsync(dp->pipefd); } @@ -65,8 +67,13 @@ device_serial_init() dp = (struct device_serial_priv *) malloc(sizeof(struct device_serial_priv)); d->aux = dp; + + if (mkfifo(pipepath, S_IRUSR | S_IWUSR) != 0) { + fprintf(stderr, "Creating FIFO for serial port failed!\n"); + /* perror, handle this failure... */ + } - dp->pipefd = mkfifo(pipepath, 600); + dp->pipefd = open(pipepath, O_RDWR); return d; } @@ -75,6 +82,6 @@ void device_serial_finish(device_t *d) { free(d->aux); - //close pipe + //close pipe etc. }