Home > Software engineering >  A serial port receives no display
A serial port receives no display

Time:05-04

Using online download sscom debugging software, can receive a serial port, the software use CPORT controls,
MFC using Activex serial port Control: Microsoft Communications Control, Version 6.0, debugging found to into the oncomm function, but did not show,
Using the virtual serial port, can show, but the use of external serial port, no display,
The code is as follows:
The VARIANT variant_inp;//the Variant is a special kind of data type, in addition to the fixed-length String data and user defined type, can contain any kind of data,
COleSafeArray safearray_inp;
LONG len, k;
BYTE rxdata [2048].//set An 8-bit BYTE array integer that is not signed.
Cstrings strtemp;
If (m_ctrlComm get_CommEvent ()==2)//event value of 2 signifies a character
the receive buffer{
//the following you can according to their own communication protocol join processing code
Variant_inp=m_ctrlComm. Get_Input ();//read buffer
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
Strtemp. The Format (_T (" % c "), bt);//the character into temporary variables strtemp store
M_strRXData +=strtemp;//add receive corresponding string edit box
}
}
The UpdateData (FALSE);//update the content of the edit box
  • Related