#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)
/* TODO: Rename 'speed' to 'baudrate'. */
switch(speed) {
+ /* TODO: Support for higher baud rates. */
case 115200:
dcb.BaudRate = CBR_115200;
break;
return SIGROK_ERR;
}
- term.c_iflag &= ~(IGNPAR | PARODD | PARENB);
+ term.c_iflag &= ~IGNPAR;
+ term.c_cflag &= ~(PARODD | PARENB);
switch (parity) {
case 0:
term.c_iflag |= IGNPAR;
break;
case 1:
- term.c_iflag |= PARENB;
+ term.c_cflag |= PARENB;
break;
case 2:
- term.c_iflag |= PARENB | PARODD;
+ term.c_cflag |= PARENB | PARODD;
break;
default:
return SIGROK_ERR;