From: Florent Kermarrec Date: Mon, 9 Mar 2015 23:42:54 +0000 (+0100) Subject: mibuild/sim: get serial dev from /tmp/simserial X-Git-Tag: 24jan2021_ls180~2099^2~197 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d8f1cd61d6cd77d47ac8d66c562e113d4a5b9fb;p=litex.git mibuild/sim: get serial dev from /tmp/simserial --- 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