Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COI think you are absolutely right. There is a reason, however, why I chose this approach. If I chose the synchronous approach, the WaitCommEvent() method would block my thread until an event specified by the mask would occur. This means that I would not be able to close my thread if no event occured, right? Or maybe it would be enough to close the serial port handle and the function would return then (with exception)?
      singulars
    2. COOn the other hand, I create two independent threads for this allows me to wait for a device's answer. Let's say I communicate with a modem. I write eg the "AT" command and I expect the modem to respond with "OK" or "ERROR". I reset an event (TEvent), call the WaitForSingleObject() method which returns when the event is set by the reading thread's OnRead method. If there was only one reading/writing thread, I would have to block the main application's thread to do the same :(. Am I right?
      singulars
    3. COIf there was only one serial port to communicate on I would probably use asynchronous I/O in the main thread. If there were more than one I would probably use asynchronous I/O in one worker thread. Also, whether to use synchronous or asynchronous I/O in a background thread depends on whether you know beforehand when data is to be received. If you just receive answers to requests, why use WaitCommEvent() at all? Just read directly, after setting up sensible timeout values. If the other side could send at any time WaitCommEvent() makes more sense of course.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload