From 1d41268e4ceb32ba858570d957aa14646ad39020 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sun, 22 Feb 2015 08:18:02 -0600 Subject: [PATCH] Fixes to termios.c on W32 targets I was debugging termios.c and this patch fixes two small problems--two debug printf format problems and another one that causes an extra char to be read on timeout. The extra char problem is easily duplicated by using the "w" command under rigtctl. Most all other commands use fixed-length response strings which don't exhibit the problem. But since "w" does not know how long the response should be it loops until it times out. Every time it times out it would return 1 extra character (this was 100% repeatable on two different rigs). Turns out it was a simple typo in the code as the read was using the write event instead of the read event. --- lib/termios.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/termios.c b/lib/termios.c index 1133b63ec..6bf58ffca 100644 --- a/lib/termios.c +++ b/lib/termios.c @@ -509,7 +509,7 @@ static int ClearErrors( struct termios_list *index, COMSTAT *Stat ) #ifdef DEBUG_ERRORS if ( ErrCode ) { - printf("%i frame %i %i overrun %i %i parity %u %i brk %i %i\n", + printf("%i frame %i %i overrun %li %i parity %u %i brk %i %i\n", (int) ErrCode, (int) ErrCode & CE_FRAME, index->sis->frame, @@ -1445,7 +1445,7 @@ int win32_serial_read( int fd, void *vb, int size ) #ifdef DEBUG_VERBOSE /* warning Roy Rogers! */ sprintf(message, " ========== ReadFile = %i %s\n", - ( int ) nBytes, (char *) dest + total ); + ( int ) nBytes, *((char *) dest + total) ); report( message ); #endif /* DEBUG_VERBOSE */ @@ -3306,7 +3306,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds, SetCommMask( index->hComm, index->event_flag ); ClearErrors( index, &Stat ); if ( !WaitCommEvent( index->hComm, &dwCommEvent, - &index->sol ) ) + &index->rol ) ) { /* WaitCommEvent failed probably overlapped though */ if ( GetLastError() != ERROR_IO_PENDING ) @@ -3320,7 +3320,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds, be needed */ ClearErrors( index, &Stat ); - wait = WaitForSingleObject( index->sol.hEvent, 100 ); + wait = WaitForSingleObject( index->rol.hEvent, 100 ); switch ( wait ) { case WAIT_OBJECT_0: