LONG CTEST1Dlg: : OnCommunication (WPARAM ch, LPARAM port)
//LONG CTEST1Dlg: : OnComm (WPARAM ch, LPARAM port)
{
If (m_ctrlEditRXData GetLineCount () & gt;
=15){
M_strEditRXData. Empty ();
The UpdateData (FALSE);
}
The UpdateData (TRUE);
Cstrings strtemp;
M_strPortRXData +=(char) ch;
DataProcessTemp (m_strPortRXData mids (0, 2));
M_strEditRXData +=ch;
The UpdateData (FALSE);
return 0;
}
Void CTEST1Dlg: : DataProcessTemp (cstrings stRXData)
{
Cstrings data1, data2;
BYTE db1, db2;
Char * temp=(char *) (LPCTSTR stRXData);
Db1=Hex2ten (temp [0]);
Db2=Hex2ten (temp [1]);
Data1=dtob (db1);
Data2=dtob (db2);
If (data1 [3]=='1')
The state (x0000ff00 IDC_STATIC0, 0);
The else
The state (xaaaaaaaa IDC_STATIC0, 0);
If (data1 [2]=='1')
The state (x0000ff00 IDC_STATIC1, 0);
The else
The state (xaaaaaaaa IDC_STATIC1, 0);
If (data1 [1]=='1')
The state (x0000ff00 IDC_STATIC2, 0);
The else
The state (xaaaaaaaa IDC_STATIC2, 0);
If (data1 [0]=='1')
The state (x0000ff00 IDC_STATIC3, 0);
The else
The state (xaaaaaaaa IDC_STATIC3, 0);
If (data2 [3]=='1')
The state (x0000ff00 IDC_STATIC4, 0);
The else
The state (xaaaaaaaa IDC_STATIC4, 0);
If (data2 [2]=='1')
The state (x0000ff00 IDC_STATIC5, 0);
The else
The state (xaaaaaaaa IDC_STATIC5, 0);
If (data2 [1]=='1')
The state (x0000ff00 IDC_STATIC6, 0);
The else
The state (xaaaaaaaa IDC_STATIC6, 0);
If (data2 [0]=='1')
The state (x0000ff00 IDC_STATIC7, 0);
The else
The state (xaaaaaaaa IDC_STATIC7, 0);
}
CodePudding user response:
Of watching, what is your problem?CodePudding user response:
Receive can parse, according to the business needs to ask to ask what problem?Each byte, find the main part of the data to realize the corresponding business,
CodePudding user response:
How logical problems, how to assemblyCodePudding user response:
Due to the use of serial communication is slow, in order to improve the efficiency of the data in the buffer to send or receive, in order to distinguish between data from the buffer pool, the usual processing method is send for every piece of data and a data prefixes and suffixes, the receiver from the data in the buffer lookup prefix, find and then find the suffix, the contents of the data needed to, I wonder if the original poster in order to find the "prefix"?CodePudding user response:
How to get points