win32termios: fix in tcflush

Under Windows, the Icom transceive messages do not get flushed
properly. Returned data is cached in windows serial buffer and
are received by hamlib as response to initial request.
Lada suggested to add PURGE_RXCLEAR flag to tcflush (lib/termios.c),
actually clearing and making the buffer empty.

Look at http://msdn.microsoft.com/en-us/library/windows/desktop/aa363428%28v=vs.85%29.aspx
PURGE_RXABORT only terminates overlapped reads but not input buffer.

Nate suggested to add the PURGE_TXCLEAR flag to the output queue as well.

Signed-off-by: Ladislav Vaiz <spam@nagano.cz>
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Hamlib-3.0
Stephane Fillod 2013-05-06 08:35:00 +02:00
rodzic d331253f42
commit 683cc7eedd
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -2593,23 +2593,23 @@ int tcflush( int fd, int queue_selector )
switch( queue_selector )
{
case TCIFLUSH:
if ( !PurgeComm( index->hComm, PURGE_RXABORT ) )
if ( !PurgeComm( index->hComm, PURGE_RXABORT|PURGE_RXCLEAR ) )
{
goto fail;
}
break;
case TCOFLUSH:
if ( !PurgeComm( index->hComm, PURGE_TXABORT ) )
if ( !PurgeComm( index->hComm, PURGE_TXABORT|PURGE_TXCLEAR ) )
{
goto fail;
}
break;
case TCIOFLUSH:
if ( !PurgeComm( index->hComm, PURGE_TXABORT ) )
if ( !PurgeComm( index->hComm, PURGE_TXABORT|PURGE_TXCLEAR ) )
{
goto fail;
}
if ( !PurgeComm( index->hComm, PURGE_RXABORT ) )
if ( !PurgeComm( index->hComm, PURGE_RXABORT|PURGE_RXCLEAR ) )
{
goto fail;
}