Home > other >  How to deal with the lower machine can take the initiative to send data serial communication
How to deal with the lower machine can take the initiative to send data serial communication

Time:09-21

PC serial port to send the machine temperature command,
(waiting for? Returned directly, and the other the receiving thread to read data)


send button press (assuming the trigger) : a machine under
send data: temperature machine


Dear, could you tell me how you handle the situation? PC to read the next bit machine temperature information, because the machine can take the initiative to send data, if after send to read temperature directly read data, will read the key data, so as to make a mistake, is currently the PC to send and receive is two threads processing,
This, I call to read the temperature information, the actual is sent instructions to read the temperature, which is asynchronous processing,
And if I want to send while reading temperature directly blocked waiting for implementation, simulation of the PC machine under direct call API, this reference have any Suggestions or open source licenses

CodePudding user response:

Send and receive the best one thread, or synchronous more troublesome,

Sending and receiving thread:
Send the request - blocking pause at a specific time, read the data - processing data

CodePudding user response:

Agree with upstairs, reliable
  • Related