diff options
author | redman <redman> | 1999-04-21 20:08:17 (GMT) |
---|---|---|
committer | redman <redman> | 1999-04-21 20:08:17 (GMT) |
commit | d2a3e887caf524096070bbe8667b700520357b4b (patch) | |
tree | b034b66986b8c1e3a7b065bf1ac1a4fd83bc8686 /win/tclWinSerial.c | |
parent | 7ab2eee54bc6371397693ad5a6610e8d5efc4cc8 (diff) | |
download | tcl-d2a3e887caf524096070bbe8667b700520357b4b.zip tcl-d2a3e887caf524096070bbe8667b700520357b4b.tar.gz tcl-d2a3e887caf524096070bbe8667b700520357b4b.tar.bz2 |
Merge with 8.1.0 branch
Diffstat (limited to 'win/tclWinSerial.c')
-rw-r--r-- | win/tclWinSerial.c | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 733da67..a96f908 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSerial.c,v 1.2 1999/04/16 00:48:09 stanton Exp $ + * RCS: @(#) $Id: tclWinSerial.c,v 1.3 1999/04/21 20:08:17 redman Exp $ */ #include "tclWinInt.h" @@ -46,7 +46,10 @@ TCL_DECLARE_MUTEX(serialMutex) */ #define SERIAL_EOF (1<<2) /* Serial has reached EOF. */ -#define SERIAL_EXTRABYTE (1<<3) /* Extra byte consumed while waiting for data */ +#define SERIAL_EXTRABYTE (1<<3) /* Extra byte consumed while waiting for data + */ +#define SERIAL_ERROR (1<<4) + /* * This structure describes per-instance data for a serial based channel. */ @@ -950,9 +953,8 @@ WaitForRead( int blocking) /* Indicates whether call should be * blocking or not. */ { - DWORD timeout, errors; + DWORD timeout; HANDLE *handle = infoPtr->handle; - COMSTAT stat; while (1) { /* @@ -984,25 +986,6 @@ WaitForRead( return 1; } - if (ClearCommError(infoPtr->handle, &errors, &stat)) { - /* - * If there are errors, then signal an I/O error. - */ - - if (errors != 0) { - errno = EIO; - return -1; - } - } - - /* - * If data is in the queue return 1 - */ - - if (stat.cbInQue != 0) { - return 1; - } - /* * if there is an extra byte that was consumed while * waiting, but no data in the queue, return 0 @@ -1010,8 +993,10 @@ WaitForRead( if (infoPtr->readFlags & SERIAL_EXTRABYTE) { return 0; + } else if ((infoPtr->readFlags & SERIAL_ERROR) == EIO) { + return -1; } - + ResetEvent(infoPtr->readable); SetEvent(infoPtr->startReader); } @@ -1041,9 +1026,8 @@ SerialReaderThread(LPVOID arg) { SerialInfo *infoPtr = (SerialInfo *)arg; HANDLE *handle = infoPtr->handle; - DWORD mask = EV_RXCHAR; DWORD count; - + for (;;) { /* * Wait for the main thread to signal before attempting to wait. @@ -1073,12 +1057,6 @@ SerialReaderThread(LPVOID arg) infoPtr->readFlags |= SERIAL_EXTRABYTE; } - } else { - /* - * There is an error, signal an EOF. - */ - - infoPtr->readFlags |= SERIAL_EOF; } /* |