From: Uwe Hermann Date: Tue, 11 Jan 2011 00:25:10 +0000 (+0100) Subject: MinGW: Quickfix to make serial.c/ols.c compile. X-Git-Tag: libsigrok-0.1.0~449 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1fdb75e14528abd62ebe727537512c741a5759da;p=libsigrok.git MinGW: Quickfix to make serial.c/ols.c compile. Note: It does NOT actually work, yet, it only compiles! --- diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 18b62d0c..0b9b1c8c 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -95,10 +95,22 @@ int serial_close(int fd) #endif } +/* + * Flush serial port buffers (if any). + * Returns 0 upon success, -1 upon failure. + */ int serial_flush(int fd) { - +#ifdef _WIN32 + /* Returns non-zero upon success, 0 upon failure. */ + if (PurgeComm(hdl, PURGE_RXCLEAR | PURGE_TXCLEAR) == 0) + return -1; + else + return 0; +#else + /* Returns 0 upon success, -1 upon failure. */ return tcflush(fd, TCIOFLUSH); +#endif } void *serial_backup_params(int fd) @@ -140,6 +152,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, /* TODO: Rename 'speed' to 'baudrate'. */ switch(speed) { + /* TODO: Support for higher baud rates. */ case 115200: dcb.BaudRate = CBR_115200; break; diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 7f44788e..d95e0827 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -38,6 +38,10 @@ #include #include +#ifdef _WIN32 +#define O_NONBLOCK FIONBIO +#endif + #define NUM_PROBES 32 #define NUM_TRIGGER_STAGES 4 #define TRIGGER_TYPES "01"