Click here to Skip to main content
15,117,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the SerialDataReceivedEventHandler in a comms class to receive data. I am polling data approx, once every 1.5 secs with a call from a timer on my form. I have a system timer to test for any timeouts if a reply is not received within 1 sec - time to transmit and receive data is 200 ms max.

Every so often I get a timeout. I have snooped the data between the 2 devices and used a port monitor - the delay is in the C# program and it is taking approx 3 seconds to see all the returned data!

Any ideas? Could I try a 'lock' around the send receive?
Posted

1 solution

You'd only need a lock if you have multiple people trying to communicate with the SerialPort object. If you do, I would recommend locking it because I doubt your communications would allow for an interruption.

I'm not 100% clear on your explaination of the system setup, but the issue may be on your polling side. If you just so happen to have data sent JUST after a poll, you'll potentially hit your timeout. I'd see if increasing your polling rate changes your system's behavior.
   

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