diff options
| author | Pavel Vymetálek <pavel@vym.cz> | 2020-04-06 11:21:03 +0200 | 
|---|---|---|
| committer | Pavel Vymetálek <pavel@vym.cz> | 2020-04-06 11:21:03 +0200 | 
| commit | 18699ca29d46d87d94ea8623148457157389f4ce (patch) | |
| tree | 1b798554e34494effecf4ac2c855aae8dce95277 | |
| parent | 9cc1f6571b3fa961a45ef7320b66e12524fc09de (diff) | |
| download | sercp-pc-18699ca29d46d87d94ea8623148457157389f4ce.tar.gz | |
Fixed windows build
| -rw-r--r-- | sercp.c | 15 | 
1 files changed, 13 insertions, 2 deletions
| @@ -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); | 
