From 9d8f1cd61d6cd77d47ac8d66c562e113d4a5b9fb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 10 Mar 2015 00:42:54 +0100 Subject: [PATCH] mibuild/sim: get serial dev from /tmp/simserial --- mibuild/sim/dut_tb.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) mode change 100644 => 100755 mibuild/sim/dut_tb.cpp diff --git a/mibuild/sim/dut_tb.cpp b/mibuild/sim/dut_tb.cpp old mode 100644 new mode 100755 index 4cce6500..794e64f2 --- a/mibuild/sim/dut_tb.cpp +++ b/mibuild/sim/dut_tb.cpp @@ -52,7 +52,7 @@ struct sim { char rx_serial_data; char rx_serial_presented; #else - const char *serial_dev; + char serial_dev[64]; int serial_fd; unsigned char serial_rx_data; unsigned char serial_tx_data; @@ -216,11 +216,20 @@ int console_service(struct sim *s) return 0; } #else -void console_open(struct sim *s, const char *dev) +void console_init(struct sim *s) { - s->serial_fd = open(dev, O_RDWR); + FILE *f; + f = fopen("/tmp/simserial","r"); + fscanf(f, "%[^\n]", s->serial_dev); + fclose(f); + return; +} + +void console_open(struct sim *s) +{ + s->serial_fd = open(s->serial_dev, O_RDWR); if(s->serial_fd < 0) { - fprintf (stderr, " Could not open dev %s\n", s->serial_dev); + fprintf(stderr, " Could not open dev %s\n", s->serial_dev); return; } return; @@ -352,7 +361,8 @@ int main(int argc, char **argv, char **env) sim_init(&s); #ifdef WITH_SERIAL_PTY - console_open(&s, "/dev/pts/3"); // XXX get this from /tmp/simserial + console_init(&s); + console_open(&s); #endif #ifdef WITH_ETH -- 2.30.2