Update of /cvsroot/pure-data/externals/iem/comport/comport In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12924
Modified Files: comport.c Log Message: write_serial: Windows version checks GetOverlappedResult to avoid Tx overruns
CVSCVS: Committing in .
Index: comport.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/comport/comport/comport.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** comport.c 4 Oct 2006 01:24:20 -0000 1.24 --- comport.c 16 Oct 2006 21:30:29 -0000 1.25 *************** *** 14,17 **** --- 14,18 ---- MP 20060924 added comport_enum to list available ports in Windows MP 20060925 add devices message to enumerate actual devices, info just outputs current port state + MP 20061016 write_serial checks for GetOverlappedResult to avoid tx buffer overflow errors */
*************** *** 496,500 **** if (!GetCommTimeouts(fd, &(x->old_timeouts))) { ! post("[comport] Couldn't get old timeouts for serial device"); }
--- 497,501 ---- if (!GetCommTimeouts(fd, &(x->old_timeouts))) { ! post("[comport] Couldn't get old timeouts for serial device (%d)", GetLastError()); }
*************** *** 508,515 **** if (!SetCommTimeouts(fd, &timeouts)) { ! post("Couldn't set timeouts for serial device"); return INVALID_HANDLE_VALUE; } ! x->comport = com_num;/* output on next tick */ return fd; --- 509,520 ---- if (!SetCommTimeouts(fd, &timeouts)) { ! post("Couldn't set timeouts for serial device (%d)", GetLastError()); return INVALID_HANDLE_VALUE; } ! if (!SetupComm(x->comhandle, 4096L, 4096L))/* try to get big buffers to avoid overruns*/ ! { ! post("[comport] Couldn't do SetupComm (%d)", GetLastError()); ! } ! x->comport = com_num;/* output on next tick */ return fd; *************** *** 540,546 **** OVERLAPPED osWrite = {0}; DWORD dwWritten; ! DWORD dwToWrite = 1; DWORD dwErr; ! char cErr[100];
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); --- 545,551 ---- OVERLAPPED osWrite = {0}; DWORD dwWritten; ! DWORD dwToWrite = 1L; DWORD dwErr; ! DWORD numTransferred = 0L;
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); *************** *** 556,564 **** if (dwErr != ERROR_IO_PENDING) { ! sprintf(cErr, "WriteFile error: %d", (int)dwErr); ! post(cErr); return 0; } } CloseHandle(osWrite.hEvent); return 1; --- 561,573 ---- if (dwErr != ERROR_IO_PENDING) { ! post("WriteFile error: %d", (int)dwErr); return 0; } } + if (!GetOverlappedResult(x->comhandle, &osWrite, &numTransferred, TRUE)) + {/* wait for the character to be sent */ + dwErr = GetLastError(); + post("WriteFile:GetOverlappedResult error: %d", (int)dwErr); + } CloseHandle(osWrite.hEvent); return 1;