Home > Software engineering >  VS MSCOMM control receiving data shown in the edit box.
VS MSCOMM control receiving data shown in the edit box.

Time:11-02

next piece of code to build an empty project can receive data and display, the same code will not be able to display the data in an existing program, strives for the great god and see what reason be?
Void
{

Cstrings temp.
The static unsigned int CNT=0;
The VARIANT variant_inp;
COleSafeArray safearray_inp;
Long len, k;
Unsigned intdata [1024]={0};
Byte rxdata [1024].//set the BYTE array
Cstrings strtemp;
M_EditMeasure1. Empty ();
If (m_mscomm get_CommEvent ()==2)//value of 2 signifies a character
the receive buffer{
cnt++;
Variant_inp=m_mscomm. Get_Input ();//read buffer
Safearray_inp=variant_inp;//variable conversion
Len=safearray_inp. GetOneDimSize ();//to get effective data length
For (k=0; K{
Safearray_inp. GetElement (& amp; K, rxdata + k);
}
Char c_char;
For (k=0; K{
Strtemp. The Format (_T (" % c "), * (rxdata + k));
Temp +=strtemp;
}
If (temp. GetLength ()==3)
{
Would be * ctemp=(would be *) temp. GetBuffer (0);
If (ctemp [0]==0 x55)
{
The UpdateData (TRUE);
Lf m_EditMeasure1. The Format (_T (" % "), (double) ((double) (ctemp [1] <8) + (double) ctemp [2]) * 5/16384);
//m_EditMeasure1. The Format (_T (02 02 "% d % d"), ctemp [1], ctemp [2]).//((ctemp [1] <8) + ctemp [2]));
The UpdateData (FALSE);
}
Else if (ctemp [0]==0 xaa)
{
The UpdateData (TRUE);
Lf m_EditMeasure2. The Format (_T (" % "), ((double) (ctemp [1] <8) + (double) ctemp [2]) * 5/16384);
The UpdateData (FALSE);
//m_EditMeasure2. The Format (_T (02 02 "% d % d"), ctemp [1], ctemp [2]).//((ctemp [1] <8) + ctemp [2]));
}
}
}
The UpdateData (FALSE);
}

CodePudding user response:

I this program mainly realize the serial port to send to come over to 0 x55 * * * * or 0 xaa * * * * length data into three decimal output edit box shows,

CodePudding user response:

Just test found engineering properties in the Unicode character set case, the code is available, not set wouldn't work, how to modify the code??
  • Related