variant_inp=m_MSComm. Get_Input ();//read bufferbut can appear the situation of the program crashes, o great god solve will buffer the hexadecimal data read is shown in the edit box,
Safearray_inp=variant_inp;//the VARIANT type variables into ColeSafeArray type
Len=safearray_inp. GetOneDimSize ();//to get effective data length
For (k=0; KSafearray_inp. GetElement (& amp; K, rxdata + k);//type into a BYTE array
For (k=0; K{
BYTE bt=* (char *) (rxdata + k);//character
If (m_ctrlHexDiaplay GetCheck ())
Strtemp. The Format (" % 02 x ", bt);//in hexadecimal characters into temporary variables strtemp deposit, note here to join an empty partition
The else
Strtemp. The Format (" % c ", bt);//the character into temporary variables strtemp store
M_EditReceive +=strtemp;//add receive corresponding string edit box
}
CodePudding user response:
There may be cross-border cases
Variant_inp=m_MSComm. Get_Input ();//read buffer
Safearray_inp=variant_inp;//the VARIANT type variables into ColeSafeArray type
Len=safearray_inp. GetOneDimSize ();//to get effective data length
BOOL bHexFlag=m_ctrlHexDiaplay. GetCheck ();
For (k=0; K{
BYTE bt;
Safearray_inp. GetElement (& amp; K, & amp; Bt);//type into a BYTE array
If (bhexFlag)
Strtemp. The Format (" % 02 x ", bt);//in hexadecimal characters into temporary variables strtemp deposit, note here to join an empty partition
The else
Strtemp. The Format (" % c ", bt);//the character into temporary variables strtemp store
M_EditReceive +=strtemp;//add receive corresponding string edit box
}
CodePudding user response:
variant_inp=m_mscomm. Get_Input ();//read buffer
Safearryay_inp=variant_inp;//the VARIANT type variables into ColeSafeArray type
Len=safearryay_inp. GetOneDimSize ();//to get effective data length
//to accept data
For (k=0; K{
Safearryay_inp. GetElement (& amp; K, rxdata + k);//type into a BYTE array
}
Sleep (1);
For (k=0; K{
BYTE bt=* (char *) (rxdata + k);//character
Stremp. The Format (" % 02 x ", bt);
M_EditReceive +=stremp;
}
Code debug mode do not have what problem, at the time of the error, click on the lower left corner of the call stack, and then double-click down on, see the problem of the line of code, the line is that you can understand the wrong