Bug 341 - WaitCommEvent() failed and/or other issues with a serial port DMM
Summary: WaitCommEvent() failed and/or other issues with a serial port DMM
Status: RESOLVED FIXED
Alias: None
Product: libserialport
Classification: Unclassified
Component: Other (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: High blocker
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
: 563 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-25 20:13 CET by Uwe Hermann
Modified: 2015-03-29 22:45 CEST (History)
1 user (show)



Attachments
Debug log (115.14 KB, text/plain)
2014-03-25 20:13 CET, Uwe Hermann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Hermann 2014-03-25 20:13:50 CET
Created attachment 70 [details]
Debug log

There seems to be some issue with libserialport when used with e.g. a UNI-T UT61D multimeter via RS232 cable (and additional USB2serial FTDI adapter), e.g. on Windows XP SP3. I'll try Windows 7 or such later.

Example errors:
sp: sp_nonblocking_read returning SP_ERR_FAIL: WaitCommEvent() failed: Falscher Parameter.^M

Full log attached.
Comment 1 Martin Ling 2014-09-24 13:23:37 CEST
This is looking similar to #421, which has an explanation attached.
Comment 2 Martin Ling 2014-09-24 16:34:58 CEST
Possible fix in this commit, needs testing:

https://github.com/martinling/libserialport/commit/e4bb554e406c1641bf93745d79b9a9c54bd4dce6
Comment 3 Uwe Hermann 2015-02-15 19:55:24 CET
The fix for #421 doesn't affect this issue apparently, still happening here. Will report more info later on.
Comment 4 Martin Ling 2015-03-25 19:45:36 CET
OK, I think the issue is that we've not been handling the case where WaitCommEvent() returns immediately after a read. We're still assuming that an overlapped wait operation is running and checking its status with GetOverlappedResult at the next read, which is bogus and screws things up such that WaitCommEvent() fails on the next call.

I'm working on figuring out what the right fix is.
Comment 5 Martin Ling 2015-03-25 21:49:59 CET
Can you try with this change:

https://github.com/martinling/libserialport/commit/01284d267cdbe0286761b1cc76947e6016466e8a

Compiled but not tested at all here as yet.
Comment 6 Martin Ling 2015-03-27 23:54:15 CET
Uwe, the new debug logs you posted on IRC show that the ERROR_INVALID_PARAMETER failure has now gone but you are sometimes getting ERROR_OPERATION_ABORTED. I think this is arising from a receive error (parity, framing or overrun), combined with the fAbortOnError flag being set to TRUE.

Please try with this change too:
https://github.com/martinling/libserialport/commit/65f89b81819e2834fe51d661952f6b5fcdd23171
Comment 7 Martin Ling 2015-03-29 21:56:24 CEST
*** Bug 563 has been marked as a duplicate of this bug. ***
Comment 8 Uwe Hermann 2015-03-29 22:45:21 CEST
Merged both patches, thanks!

After a few tests with different hardware I think we can be pretty sure that fAbortOnError=FALSE does indeed prevent the 995 errors.

The resp. patches are:
34442106efcf0621f5bc2f77aab771407d9ae5c2
47fcf8ec8522d94f698b6c5a94deb30478f7ee26