Home > Back-end >  How to capture a serial port parity error message
How to capture a serial port parity error message

Time:09-28

With a serial port transfer files between two computers, sending the use of odd parity, the receiver station using parity, sending and receiving data to normal, but I now need to detect the parity error message, and give prompt, now is, can't capture the error message, I use a synchronous serial port,
Use the several functions
SetCommMask (hCommFile EV_ERR);//////set monitoring error event
ClearCommError (hCommFile, incremented, @ stat);
WaitCommEvent (hCommFile dwEventMask, NULL)////.
And then he stay in this way, WaitCommEvent, that is to say there has been no incidents

CodePudding user response:

Without a serial port control? Simple cport and spcomm will do,
API directly, trouble

CodePudding user response:

WaitCommEvent under the second parameter to confirm whether there is a problem?

CodePudding user response:

I found parity check allows debugging results DCB. FParity setting is not successful, I set it to true, but to read when he has now become a 0,
DCB DCB.
GetCommState (hCom, & amp; DCB);//get the current state of serial port information
Int a=DCB. FParity; The variable///debugging time observation, discover 0
Int b=DCB. Parity;
DCB. FParity=1;//setting allows parity
DCB. Parity=EVENPARITY;///accidentally bit check
SetCommState (hCom, & amp; DCB);//set the serial port information
A=DCB. FParity;//the problem is out of here, a result is 0.
B=DCB. Parity;
Why would this fParity level setting is invalid, please?
  • Related