Home > Software engineering >  MFC serial port communication
MFC serial port communication

Time:09-17

Normal is 79 bytes read from the buffer bytes. But if read 79 * 2 bytes should be how to solve this problem?

CodePudding user response:

Agreement, unpacking, don't assume that a serial port can read until the length of the specific data

CodePudding user response:

reference 1/f, walk every step response:
agreement, unpacking, don't assume that serial port to read until the length of the specific data
now is continuing to send data. Then get a discriminant frame head frame tail frame data to check after operation into a thread to parse. So I continued to send this can occur when a frame is a frame to read 79 bytes results got 158 bytes. So there is a problem of packet loss

CodePudding user response:

Not with the discriminant frame head frame check? 158 is not two frames? What's the problem?

CodePudding user response:

The
reference 3 floor sichuanwww response:
is not with the discriminant frame head frame check? 158 is not two frames? What's the problem?
I am a frame of a frame of discrimination and hair also is a frame of a frame of hair. The equivalent of each time should read 79 bytes from the buffer

CodePudding user response:

Try to send before PurgeComm empty send and receive buffer
Reasonable agreement should have timeout detection, error retry the function such as

CodePudding user response:

I wonder if he is sent to a buffer to use first comstat structure to judge of the number of bytes received. So I will this structure empty can

CodePudding user response:

Before sending to empty a try, a serial port is asynchronous, not think about the question and answer

CodePudding user response:

A serial port is asynchronous, transceiver is independent,

CodePudding user response:

A bite to eat, read words one by one
  • Related