CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    16

    Angry 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

  2. #2
    Join Date
    Jul 2005
    Posts
    767

    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!

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Mar 2007
    Posts
    16

    Angry 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
  •  





Click Here to Expand Forum to Full Width

Featured