CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2017
    Posts
    2

    MFC Serial Port Delays in Reporting Number of Available Characters

    Hi,

    I'm trying to read packets of serial data in 'real-time', I time-stamp the packet data on capture and then write it to file. The packet size is 60 bytes and sent every 10ms (100Hz). I've tried using two methods of capture; a) polling the serial port every 10ms to see what's available and process what is there, and b) using EVENTS to process on a character by character basis. Both methods work for data rates 50Hz or less. When the rate is 100Hz the driver appears to not report the true number of bytes available; it appears to be using a coalescing algorithm so when I poll for the number of bytes it reports zero (0) for several calls and then suddenly reports 3960 bytes which is 66 packets. When I read that number of bytes there is indeed 66 packets of data. This is not useful as I need to receive the packet when they arrive at the serial port. Anyone know how to configure the serial port to allow the throughput of data in 'real-time'? I'm not using timeout; I use the SetCommTimeouts() function to set them all to zero (0). The EVENTS method also appears to hang-on to the bytes in the same manner.

    Thanks in advance

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: MFC Serial Port Delays in Reporting Number of Available Characters

    [moved from Visual C++ Bugs & Fixes forum because there is nothing to do with "sharing bugs/fixes in the various class libraries etc. of use to VC++ developers"]
    Victor Nijegorodov

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: MFC Serial Port Delays in Reporting Number of Available Characters

    1. About 10ms timer: https://social.msdn.microsoft.com/Fo...orum=vcgeneral

    2. From MSDN:
    ReadIntervalTimeout
    ... A value of zero indicates that interval time-outs are not used.
    ...
    A value of zero for both the ReadTotalTimeoutMultiplier and ReadTotalTimeoutConstant members indicates that total time-outs are not used for read operations.
    Is it what you want?
    Victor Nijegorodov

  4. #4
    Join Date
    Jun 2017
    Posts
    2

    Re: MFC Serial Port Delays in Reporting Number of Available Characters

    No I'm afraid it isn't what I want, I said in my original post "I'm not using timeouts; I use the SetCommTimeouts() function to set them all to zero (0)." I've tried setting FILE_FLAG_NO_BUFFERING in the call to FileCreate() and that has no effect either. Any more thoughts?

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MFC Serial Port Delays in Reporting Number of Available Characters

    What thread does the serial port reading code run in? Is it the main ui thread?

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