Set a breakpoint debugging, found that bt is successfully received, but is displayed in a cstrings gibberish, why?
The code is as follows:
void uav ground control terminal Dlg: C: OnCommMscomm1 ()
{
//TODO: add message handler code here
The VARIANT VARIANT_Input;
COleSafeArray SafeArray_Input;
LONG len, k;
BYTE RXData [1024].
Cstrings strtemp;
If (m_mscom get_CommEvent ()==2)
{
VARIANT_Input=m_mscom. Get_Input ();//read buffer
SafeArray_Input=VARIANT_Input;//the VARIANT type variables into COleSafeArray type
Len=SafeArray_Input. GetOneDimSize ();
For (k=0; KSafeArray_Input. GetElement (& amp; K, RXData + k);//type into a BYTE array
For (k=0; K & lt; Len. K++)
{
Char bt=* (char *) (RXData + k);
Strtemp. The Format (_T (" % c ", bt));
M_EditReceive +=strtemp;//receive the edit box inside
}
M_EditReceive +="\ r \ n";
The UpdateData (false);
M_Edit. SetSel (1, 1);
This - & gt; SetDlgItemTextW (IDC_EDIT1 m_EditReceive);//will m_EditReceive content displayed to ID IDC_EDIT1 edit box at the end of the position of the
M_Edit. LineScroll (m_Edit. GetLineCount () - 1, 0).//the vertical scroll bar to scroll to the last
}
Checked for a long time and I don't know why, inquire, not very grateful!
CodePudding user response:
UNicode '2'=0 x0032; 2 bytesSee
Strtemp. The Format (_T (" % c ", bt));
The results of
CodePudding user response:
Char bt [2]={0};Bt [0]=* (char *) (RXData + k);
CodePudding user response:
Set a breakpoint to check the raw data directly, if not consistent, may be inconsistent port parameters, such as length of baud rate, data bits, etcCodePudding user response:
OrWCHAR WCH=(WCHAR) bt;