Re: Serial buffer flushing
Serial Communications have been discussed several times in this forum. Use the Search option to search for related articles.
Re: Serial buffer flushing
Well, why don't you show us the code you have, and let us try to figure what is the problem with it? It's hard to do that from the info you provided.
Re: Serial buffer flushing
Hai,
This is a program for serial data reception. Can you tell me how this code is working. It is programmed to receive 18 bytes (a configured data packet of 18 bytes) of data.......
Code is:
CTimerDlg::OnOnComm()
{
if(m_comm.GetCommevent() == 2) // m_comm is serial member variable
{
UCHAR *parray; // local array
COleVariant var;
var = m_comm.GetInput();
long comL;
HRESULT hr = SafeAraayGetUBound(var.parray , 1 , &comL);
if(hr == S_OK)
{
hr = SafeArrayAccessData(var.parray , (void**)&parray);
if(hr == S_OK)
{
for(int i=0;i<18;i++)
Rxdata[RxBuffcount++]=parray[i]; //local array
}
SafeArrayUnaccessData(var.parray);
if(RxBuffcount == 18) // if 18 bytes received proceed
{
Processdata(); // data processing
RxBuffcount = 0;
}
}
}
}
This is the code and all the time am getting the same data even if am transmitting different data.
My questions are:
1. How is this code working.
2. Is this code receiving data bytewise or not .
Plz help me.
Regards,
Guddappa T H