From 894f031e78eb3f237f44a9069280f3a334f61937 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 5 Apr 2012 13:36:20 +0100 Subject: [PATCH] uart_pty: Added a debug terminal You can now launch an xterm with picocom by setting environment SIMAVR_UART_XTERM. This could (will) be improved. Also, the uart_pty symlinks the pty pathname to /tmp/simavr-uart-X so you can rely on a constant pathname. Signed-off-by: Michel Pollet --- examples/parts/uart_pty.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/parts/uart_pty.c b/examples/parts/uart_pty.c index b442825..2f95e60 100644 --- a/examples/parts/uart_pty.c +++ b/examples/parts/uart_pty.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -183,5 +184,19 @@ void uart_pty_connect(uart_pty_t * p, char uart) avr_irq_register_notify(xon, uart_pty_xon_hook, p); if (xoff) avr_irq_register_notify(xoff, uart_pty_xoff_hook, p); + + char link[128]; + sprintf(link, "/tmp/simavr-uart%c", uart); + unlink(link); + if (symlink(p->slavename, link) != 0) { + fprintf(stderr, "WARN %s: Can't create %s: %s", __func__, link, strerror(errno)); + } else { + printf("%s: %s now points to %s\n", __func__, link, p->slavename); + } + if (getenv("SIMAVR_UART_XTERM")) { + char cmd[256]; + sprintf(cmd, "nohup xterm -e picocom -b 115200 %s >/dev/null 2>&1 &", p->slavename); + system(cmd); + } } -- 2.39.5