Am Dienstag, 22. Oktober 2013, 16:55:51 schrieb Alexandre Julliard:
Dmitry Timoshkov dmitry@baikal.ru writes:
This patch makes WaitCommEvent(EV_TXEMPTY) work when a serial device reports that the out queue is empty even after a successful write() which is the case for real COM ports and as well as for serial-USB adapters.
Take 2 removes special handling of FlushFileBuffers for a serial sevice, the tests show that it really should not reset the pending write state.
I'd like to see some feedback for this patch.
It doesn't work here:
../../../tools/runtest -q -P wine -T ../../.. -M kernel32.dll -p kernel32_test.exe.so comm.c && touch comm.ok comm.c:860: Test failed: WaitCommEvent failed with a timeout comm.c:881: Test failed: WaitCommEvent error 997 comm.c:882: Test failed: WaitCommEvent: expected EV_TXEMPTY, got 0 comm.c:887: Test failed: WaitCommEvent used 1003 ms for waiting comm.c:2226: Tests skipped: interactive tests (set WINETEST_INTERACTIVE=1) make: *** [comm.ok] Error 4
This is because the previous test fails: in the previous test wine actually write to the serial device and does not return with ERROR_INVALID_PARAMETER. These 17 bytes also need some time to be written and therefor this test fails with a timeout.
I proposed to add a sleep(TIMEOUT) if the previous test does not pass that is the write actually returns success or with error ERROR_IO_PENDING:
if (res || (!res && GetLastError() == ERROR_IO_PENDING)) /* if data has been sent: wait for termination */ Sleep(timeout);
This has been rejected because then the test passes even without changing the EV_TXEMPTY handling at all. This is because calling WaitCommEvent() while there are still bytes in the tx queue already works.
This does not mean that "Add support for pending write flag to the serial device" is not needed. It is needed to correctly signal EV_TXEMPTY if WaitCommEvent() is called later when the tx queue is already empty. I sent a patch (5 Sep) adding an additional test for this case (the patch was named
[PATCH 3/6] add another test for waiting for EV_TXEMPTY with WaitCommEvent(), try 2
It was part of a series of patches which implemented someting similar to Dmitry's patch so I hope Dmitry's patch goes in as it actually fixes an important bug.
Independently: TIMEOUT is to short anyway for (see my earlier emails and those of Francois Gouget, I attached the latter one).
Regards,