PeterSteele
New member
I have a program set up with two threads, one intended to read incoming data from the 631 and another that writes data to the 631. The read thread uses WaitCommEvent so that it sleeps until there is data to read. The write thread uses WriteFile to send packets to the 631 com port. When the first WriteFile is performed, the read thread wakes up as expected and processes the incoming response data that was generated as a result of the WriteFile operation. After it has read the data, it issues another WaitCommEvent and then goes back to sleep. So far so good.
The problem occurs when the write thread then issues its next WriteFile operation. Instead of returning immediately from the call as expected, it just hangs, and the read thread that is sleeping on the call to WaitCommEvent continues to sleep. The only way I can wake these threads up is by pressing a button on the 631 keypad. When I do this the WriteFile immediately completes and the WaitCommEvent call wakes up. The read thread then proceeds to read incoming data for both the WriteFile that had hung as well as the event data generated by the key press.
So why does WriteFile hang? The read/write threads work exactly as I intended on the first write attempt but after that the WriteFile operation hangs. Am I missing something obvious?
The problem occurs when the write thread then issues its next WriteFile operation. Instead of returning immediately from the call as expected, it just hangs, and the read thread that is sleeping on the call to WaitCommEvent continues to sleep. The only way I can wake these threads up is by pressing a button on the 631 keypad. When I do this the WriteFile immediately completes and the WaitCommEvent call wakes up. The read thread then proceeds to read incoming data for both the WriteFile that had hung as well as the event data generated by the key press.
So why does WriteFile hang? The read/write threads work exactly as I intended on the first write attempt but after that the WriteFile operation hangs. Am I missing something obvious?
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.