|
-
April 2nd, 2007, 10:57 PM
#1
Serial buffer flushing
I am reciving data (16 bytes) from system serially every 20ms and I want to receive the recent data every 20ms which am not able to do. So I thought of flushing the serial buffer to receive the recent data. Can anybody tell me how to flush the serial buffer. Its urgent plz.
Thanks,
Guddappa T H
-
April 3rd, 2007, 12:57 AM
#2
Re: Serial buffer flushing
Serial Communications have been discussed several times in this forum. Use the Search option to search for related articles.
One's mistake cannot be your excuse!
-
April 3rd, 2007, 01:30 AM
#3
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.
-
April 3rd, 2007, 04:50 AM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|