Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi,

First, sorry, I don't know much software, so please excuse my posting, if this is in the wrong spot. I have a consultant doing a meter program using MS Visual C++ 2010, and he is having trouble fixing a bug, so I thought I would see if anybody has a suggestion.

The application connects to a com port (115200, no handshaking), and displays an angle. The data can come quite fast at times. He occasionally misses the last sets of values (the last value sent is the most important one). He claims it is something to do with Windows.

When I use Hyperterm, it never fails, so I seem to think it shouldn't be a problem.

Any comments/suggestions?

Thanks,

Mark
Posted
Comments
SoMad 3-Jul-12 2:21am    
Is it possible for you to go to a lower baud rate (obviously on both sides) to see if that works without missing any values?

Soren Madsen

As others have said, I'd suspect that the code is currently polling the receive queue, rather than having a dedicated thread sucking it dry, and pushing it into a buffer somewhere

20 years ago, I was comfortably getting 115k2 out of a 30Mhz DOS machine with a 16550UART, so these days it's not a problem for the hardware - Windows however, is extremely 'lumpy' in terms of performance if you don't talk to hardware effectively - i.e. on a second thread

I'd wager there's a single thread reading the com port, writing to disk - the latency in disk IO is delaying the poller sufficiently for the UART buffer to get swamped
 
Share this answer
 
Comments
[no name] 3-Jul-12 8:34am    
This has to be it.
SoMad 3-Jul-12 18:20pm    
I agree, assuming they are using an on-board COM port. I have seen several virtual COM ports that have issues when you use a high baud rate.

Soren Madsen
Obviously it cannot be to do with Windows if Hyperterminal never misses the values (as you've suggested, Mark).

"Something to do with Windows" is the old classic excuse for bugs in app software.
 
Share this answer
 
v2
Hi Mark,
If your consultant is using unmanaged code, make sure he's using overlapped I/O. This helped me with a similar issue a few years ago.
In any case, have him google 'SERIAL PORT I/O'. The APIs are similar to file APIs, but the devil, as always, hides in the details.

Hope this helps,
Pablo.
 
Share this answer
 
Comments
[no name] 3-Jul-12 0:14am    
Which can be summed up by asking whether the COM port is being polled from the main thread or whether a separate thread is running to monitor the port using overlapped I/O.
How many bytes of data are received from the device in a single message. Perhaps there is more data coming and it's simply not being read.

It's quite common for the com port receive buffer to only hold 16 bytes (16550 FIFO), so anything over that might require two reads.

Good luck.
 
Share this answer
 
First, thanks to all for the suggestions. I will run these past him to see if anything helps. Unfortunately, he won't be able to work on if for a week or longer. Is there a way to attach the SerialPort.cpp file here? I have no issues with anybody seeing it.

Thanks again,

Mark
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900