From 76e5f120948edfa188de1915e9f6008784a86b51 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 29 Oct 2007 10:49:35 +0000 Subject: [PATCH] Implemented the win32 serial_drain function using FlushFileBuffers. --- serial_win32.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/serial_win32.c b/serial_win32.c index 2a224d5..fa2d6c1 100644 --- a/serial_win32.c +++ b/serial_win32.c @@ -105,14 +105,6 @@ serial_open (serial** out, const char* name) return -1; } - // Set the event mask for the drain function. - if (!SetCommMask (device->hFile, EV_TXEMPTY)) { - TRACE ("SetCommMask"); - CloseHandle (device->hFile); - free (device); - return -1; - } - *out = device; return 0; @@ -384,14 +376,8 @@ serial_drain (serial* device) if (device == NULL) return -1; // ERROR_INVALID_PARAMETER (The parameter is incorrect) - BOOL rc = 0; - DWORD mask = 0; - do { - rc = WaitCommEvent (device->hFile, &mask, NULL); - } while ( rc && !(mask & EV_TXEMPTY) ); - - if (!rc) { - TRACE ("WaitCommEvent"); + if (!FlushFileBuffers (device->hFile)) { + TRACE ("FlushFileBuffers"); return -1; }