-
June 15th, 2017, 06:14 AM
#1
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
-
June 15th, 2017, 08:24 AM
#2
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
-
June 15th, 2017, 09:09 AM
#3
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
-
June 15th, 2017, 09:22 AM
#4
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?
-
June 15th, 2017, 12:01 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|