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. }