Home > Software engineering >  Completion of SerialPort judgment
Completion of SerialPort judgment

Time:09-23

Now doing a interface, use the SerialPort class, need to open the serial port, after sending a frame data, and then immediately change the baud rate,
Found before sending, baud rate has been changed, as a result, I send the frame data is wrong,
: : SendMessage ((port - & gt; M_pOwner) - & gt; M_hWnd, WM_COMM_TXEMPTY_DETECTED, 0, (LPARAM) port - & gt; M_nPortNr);
I call the above news, found or not, for instance to send 1024 bytes, it is not in accordance with the last few bytes before the baud rate to but according to the changed baud rate, that didn't change the baud rate, at the completion of a send
Question: how to judge the data has been sent finished? , genuflect is begged for help to solve the problem!

CodePudding user response:

SetCommMask WaitCommEvent waiting EV_TXEMPTY events
Or ClearCommError judge COMSTAT parameters cbOutQue==0


  • Related