]> sigrok.org Git - libsigrok.git/commitdiff
add serial_flush()
authorBert Vermeulen <redacted>
Thu, 12 Aug 2010 04:02:25 +0000 (06:02 +0200)
committerBert Vermeulen <redacted>
Thu, 12 Aug 2010 04:02:25 +0000 (06:02 +0200)
hardware/common/serial.c
hardware/openbench-logic-sniffer/ols.c

index 3395c3e058e7b49203510f27060586a428df0e86..6bf0e40270fbb13f95235c787f4cd6d542de496f 100644 (file)
@@ -95,6 +95,13 @@ int serial_close(int fd)
 #endif
 }
 
+int serial_flush(int fd)
+{
+
+       tcflush(fd, TCIOFLUSH);
+
+}
+
 void *serial_backup_params(int fd)
 {
 #ifdef _WIN32
index a103e8fc1f50528cf07f2f56e19459603b84b13b..2138aa7033abb5a4e10b5a1e0329e4d78f2ef98e 100644 (file)
@@ -42,7 +42,6 @@
 #define NUM_TRIGGER_STAGES             4
 #define TRIGGER_TYPES                  "01"
 #define SERIAL_SPEED                   B115200
-/* TODO: SERIAL_ bits, parity, stop bit */
 #define CLOCK_RATE                     100000000
 
 /* Command opcodes */
@@ -243,12 +242,7 @@ static int hw_init(char *deviceinfo)
                 * respond with g_poll().
                 */
                g_message("probing %s...", (char *)l->data);
-#ifdef _WIN32
-               // FIXME
-               // hdl = serial_open(l->data, 0);
-#else
                fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
-#endif
                if (fd != -1) {
                        serial_params[devcnt] = serial_backup_params(fd);
                        serial_set_params(fd, 115200, 8, 0, 1, 2);
@@ -631,10 +625,7 @@ static int receive_data(int fd, int revents, void *user_data)
                }
                free(raw_sample_buf);
 
-#ifndef _WIN32
-               /* TODO: Move to serial.c? */
-               tcflush(fd, TCIOFLUSH);
-#endif
+               serial_flush(fd);
                serial_close(fd);
                packet.type = DF_END;
                packet.length = 0;