comparison sw/mcsi-rxtx/mainloop.c @ 15:8b49ea8aeb99

fc-mcsi-rxtx: more reliable fflush(stdout) in main loop
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 23:43:10 +0000
parents 315428573a25
children
comparison
equal deleted inserted replaced
14:f908a782cff9 15:8b49ea8aeb99
20 struct timeval tv; 20 struct timeval tv;
21 u_char buf[320]; 21 u_char buf[320];
22 unsigned off; 22 unsigned off;
23 int cc; 23 int cc;
24 24
25 is_active = 0; 25 for (off = 0; ; fflush(stdout)) {
26 off = 0;
27 for (;;) {
28 FD_ZERO(&fds); 26 FD_ZERO(&fds);
29 FD_SET(0, &fds); 27 FD_SET(0, &fds);
30 FD_SET(target_fd, &fds); 28 FD_SET(target_fd, &fds);
31 if (is_active) { 29 if (is_active) {
32 tv.tv_sec = 0; 30 tv.tv_sec = 0;
73 process_rx_block(buf); 71 process_rx_block(buf);
74 off = 0; 72 off = 0;
75 transmit_20ms_block(); 73 transmit_20ms_block();
76 } 74 }
77 } 75 }
78 fflush(stdout);
79 } 76 }
80 } 77 }