From 18699ca29d46d87d94ea8623148457157389f4ce Mon Sep 17 00:00:00 2001 From: Pavel Vymetálek Date: Mon, 6 Apr 2020 11:21:03 +0200 Subject: Fixed windows build --- sercp.c | 15 +++++++++++++-- 1 file 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); -- cgit