diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2014-02-25 08:02:17 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2014-02-25 08:02:17 (GMT) |
commit | 8f14151916be38caa40822e4876fdf79ea1a984a (patch) | |
tree | f565eb7d145dd3bfe969e419fa5343061fc8cd7f /win/tclWinSerial.c | |
parent | 1a8dc819d6bcc0e11cfb42723b9a529943b7f63b (diff) | |
parent | ada7d66e9f05028322ed8f6cbb063ba19696cd06 (diff) | |
download | tcl-8f14151916be38caa40822e4876fdf79ea1a984a.zip tcl-8f14151916be38caa40822e4876fdf79ea1a984a.tar.gz tcl-8f14151916be38caa40822e4876fdf79ea1a984a.tar.bz2 |
Do not reopen a win serial channel for serial detection. There are issues with some Bluetooth virtual com. Fix bug [2413550], patch by Rolf Schroedter
Diffstat (limited to 'win/tclWinSerial.c')
-rw-r--r-- | win/tclWinSerial.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index b9c9a9f..6487fe4 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1410,23 +1410,22 @@ SerialWriterThread( /* *---------------------------------------------------------------------- * - * TclWinSerialReopen -- + * TclWinSerialOpen -- * - * Reopens the serial port with the OVERLAPPED FLAG set + * Opens or Reopens the serial port with the OVERLAPPED FLAG set * * Results: - * Returns the new handle, or INVALID_HANDLE_VALUE. Normally there - * shouldn't be any error, because the same channel has previously been - * succeesfully opened. + * Returns the new handle, or INVALID_HANDLE_VALUE. + * If an existing channel is specified it is closed and reopened. * * Side effects: - * May close the original handle + * May close/reopen the original handle * *---------------------------------------------------------------------- */ HANDLE -TclWinSerialReopen( +TclWinSerialOpen( HANDLE handle, const TCHAR *name, DWORD access) @@ -1434,16 +1433,22 @@ TclWinSerialReopen( SerialInit(); /* + * If an open channel is specified, close it + */ + + if ( handle != INVALID_HANDLE_VALUE && CloseHandle(handle) == FALSE) { + return INVALID_HANDLE_VALUE; + } + + /* * Multithreaded I/O needs the overlapped flag set otherwise * ClearCommError blocks under Windows NT/2000 until serial output is * finished */ - if (CloseHandle(handle) == FALSE) { - return INVALID_HANDLE_VALUE; - } handle = CreateFile(name, access, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + return handle; } |