mscomm32.ocx inserts additional bytes to a binary stream???

  • Thread starter Thread starter arrowlike
  • Start date Start date
A

arrowlike

In a VC6 program, a mscomm32.ocx is added to the project and read the
binary incoming RS232 data stream (from a GPS receiver). I use another
commercial serial port debug program to send out a binary file through
com port, read and record the com port data into a disk file. After
file comparison, no error occurs. When the GPS receiver is connected,
my program drops or adds one or two bytes in each data block which is
about 200 bytes. The data block size is seldom correct.
I believe the receiver contains no error, coz it uses embedded MCU.
Then, anyone met the similar mistake before? Maybe CString type
converts one special byte into two bytes stealthily?

Many thank in advance.

The implementation code is listed below:

VARIANT variant_inp;
COleSafeArray safearray_inp;
LONG len,k;

BYTE rxdata[2048];
CString strtemp;
if(m_ctrlComm.GetCommEvent()==2)
{
variant_inp=m_ctrlComm.GetInput();
safearray_inp=variant_inp;
len=safearray_inp.GetOneDimSize();
for(k=0;k<len;k++)
safearray_inp.GetElement(&k,rxdata+k);
for(k=0;k<len;k++)
{
BYTE bt=*(char*)(rxdata+k);
strtemp.Format("%c",bt);
m_strRXData+=strtemp;
}
}
 
Hi,

I have experienced the same problem, while working with MS COM OCX supplied
with Windows CE 3.0 where junk characters are appended, this occurs when the
you are working with Higher Baud Rates(11500).

As i understand it is a bug in the OCX, what i have done is written my own
OCX control from the basic API CreateFile instead of using the COM OCX.

Please let me know if you require the sample code, i can sent it to you.

Sumanth
Project Manager
ELICO Ltd
 
Back
Top