aboutsummaryrefslogtreecommitdiffstats
path: root/sercp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sercp.c')
-rw-r--r--sercp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sercp.c b/sercp.c
index a044639..21069bc 100644
--- a/sercp.c
+++ b/sercp.c
@@ -203,6 +203,17 @@ void TestArgs (int argc, char *argv[])
+void FlushSerialPort() {
+if (serial_fd) {
+#ifdef _WIN32
+ PurgeComm(serial_fd, PURGE_RXABORT| PURGE_TXABORT | PURGE_RXCLEAR | PURGE_TXCLEAR);
+#else
+ tcflush(serial_fd, TCIOFLUSH);
+ #endif
+ }
+}
+
+
//*****************************************************************************
//
// uSleep win32 implementation
@@ -440,7 +451,7 @@ void sercpRecv(void) {
len = read (serial_fd, p_buff, sizeof(fileinfo));
#endif
printf("Received unknown data. End...\n");
- tcflush(serial_fd, TCIOFLUSH);
+ FlushSerialPort();
exit (EXIT_FAILURE);
break;
}
@@ -603,7 +614,7 @@ void sercpSend(void) {
len_sent = len;
while (len_sent) {
#ifdef _WIN32
- WriteFile(serial_fd, (void*)p_buff, sent_size, &ulNumBytes, NULL);
+ WriteFile(serial_fd, (void*)p_buff, send_size, &ulNumBytes, NULL);
odeslano = (size_t)ulNumBytes;
#else
odeslano = write (serial_fd, (void*)p_buff, send_size);