FreeCalypso > hg > fc-pcm-if
changeset 9:62579cfff4fc
fc-mcsi-rxtx: more proper integration with ttyhacks
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2024 06:02:04 +0000 |
parents | ee14dd81bba1 |
children | c1d9b5d128f5 |
files | sw/mcsi-rxtx/mainloop.c sw/mcsi-rxtx/rx_samples.c |
diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/sw/mcsi-rxtx/mainloop.c Mon Oct 28 01:45:32 2024 +0000 +++ b/sw/mcsi-rxtx/mainloop.c Mon Oct 28 06:02:04 2024 +0000 @@ -12,13 +12,15 @@ extern int target_fd; +int is_active; + main_loop() { fd_set fds; struct timeval tv; u_char buf[320]; unsigned off; - int cc, is_active; + int cc; is_active = 0; off = 0; @@ -35,12 +37,15 @@ if (cc < 0) { if (errno == EINTR) continue; + tty_cleanup(); perror("select"); exit(1); } if (cc == 0) { is_active = 0; - printf("Rx stream stopped, buffer dribble = %u\n", off); + sprintf(buf, "Rx stream stopped, buffer dribble = %u", + off); + async_msg_output(buf); off = 0; continue; } @@ -49,15 +54,17 @@ if (FD_ISSET(target_fd, &fds)) { cc = read(target_fd, buf + off, sizeof(buf) - off); if (cc < 0) { + tty_cleanup(); perror("serial port read"); exit(1); } if (cc == 0) { + tty_cleanup(); fprintf(stderr, "read EOF from serial port\n"); exit(1); } if (!is_active) { - printf("Rx stream started\n"); + async_msg_output("Rx stream started"); is_active = 1; } off += cc; @@ -66,5 +73,6 @@ off = 0; } } + fflush(stdout); } }