this how to change?A serial port to send and receive data also showed that the contents of how to send to receive box, such as:
Send: send twice the world//, send each other today, and then send the world
Receive: world
The world
Today
The world
My code is as follows:
//receiving data
LONG CSerialPortTestDlg: : OnComm (WPARAM ch, LPARAM port)
{
M_strEditReceiveMsg +=(char) ch;
The UpdateData (FALSE);
return 0;
}
//send data
Void CSerialPortTestDlg: : OnBnClickedButtonSend ()
{
//TODO: add the control notification handler code
Cstrings str1;
if (! M_bSerialPortOpened)
{
return;
}
The UpdateData (true);
M_SerialPort. WriteToPort (LPCTSTR m_strEditSendMsg) (char *);
GetDlgItemText (IDC_EDIT_SEND, str1);
The UpdateData (false);
Str1 +=_T (" \ r \ n ");
Int. LastLine=m_EditRecv LineIndex (m_EditRecv GetLineCount () - 1);
M_EditRecv. SetSel (lastLine + 1, lastLine + 2, 0).
M_EditRecv. ReplaceSel (str1);//in the last line to add new content
}
CodePudding user response:
this online a lot of recommend you use Mscomm controlhttp://blog.chinaunix.net/uid-14607221-id-2794664.html
CodePudding user response:
That if using this method, how to change my code, I also checked online for a long time, not only to check the post, and a great god don't too tired, about it