From 0a221429574965ccd9008879a5c09cf2de993441 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Tue, 7 Jun 2022 07:26:40 +0200 Subject: [PATCH] Update README --- README.md | 4 ++-- src/main.c | 10 ++++++++-- src/tty.c | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 212a754..e315112 100644 --- a/README.md +++ b/README.md @@ -114,13 +114,13 @@ color = 10 tty = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0 baudrate = 9600 no-autoconnect = enable +log = enable +log-filename = ftdi.log color = 12 [usb devices] pattern = usb([0-9]*) tty = /dev/ttyUSB%s -log = enable -log-filename = usb.log color = 13 ``` diff --git a/src/main.c b/src/main.c index 49837a9..c7b4363 100644 --- a/src/main.c +++ b/src/main.c @@ -60,10 +60,16 @@ int main(int argc, char *argv[]) tty_configure(); /* Configure input terminal */ - stdin_configure(); + if (isatty(fileno(stdin))) + { + stdin_configure(); + } /* Configure output terminal */ - stdout_configure(); + if (isatty(fileno(stdout))) + { + stdout_configure(); + } /* Add log exit handler */ atexit(&log_exit); diff --git a/src/tty.c b/src/tty.c index aea1d58..b3ec1ab 100644 --- a/src/tty.c +++ b/src/tty.c @@ -583,12 +583,15 @@ void tty_wait_for_device(void) if (FD_ISSET(STDIN_FILENO, &rdfs)) { /* Input from stdin ready */ + printf(".\n"); + fflush(stdout); /* Read one character */ status = read(STDIN_FILENO, &input_char, 1); if (status <= 0) { - error_printf("Could not read from stdin"); + error_printf("Could not read from stdin 0"); + error_printf("Could not read from stdin 0 (%s)", strerror(errno)); exit(EXIT_FAILURE); } @@ -820,7 +823,7 @@ int tty_connect(void) } else { /* Error reading - device is likely unplugged */ - error_printf_silent("Could not read from tty device"); + error_printf_silent("Could not read from tty device 1"); goto error_read; } } @@ -832,7 +835,7 @@ int tty_connect(void) status = read(STDIN_FILENO, &input_char, 1); if (status <= 0) { - error_printf_silent("Could not read from stdin"); + error_printf_silent("Could not read from stdin 2"); goto error_read; }