Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I have an application that needs to be send responses within 80ms. As the receiver side application is so time critical, it causes timeout exception hence all the operations are failed.
I am working with baud rate of 10400 bps. I have used Serialport.ReadTimeOut and SerialPort.WriteTimeout functions for setting timeouts.
and the time out set were 6s and 1ms respectively.

Is there any wy to speed up the serial port communication. Plz help
Is it possible to use WIN32 API in C#.net?
Posted
Updated 28-Aug-14 20:03pm
v2
Comments
gggustafson 27-Aug-14 9:43am    
Timeouts on a serial port are caused by a number of items: baud rate at BOTH endpoints; timeout settings at BOTH endpoints; the amount of data being passed (remember there is usually an MTU involved); whether or not "Nageling" is occurring; the load on each endpoint machine (if one gets bogged down its response will increase); load on the network (if a network is used). The solution may be that you need to build a device driver for your application. Or drop down into the Win32 API (.Net Framework can add lots of time-consuming operations).

You should collect some data. You could use ping to determine the connection speed. It may be that you are sending too much data.

Good luck
Utheen 27-Aug-14 10:15am    
Thank you so much, will try to use WIN32API.
S Houghtelin 27-Aug-14 13:42pm    
What device are you using that uses a baud rate of 10400? 10400 is a non-standard rate and may very well be the reason you are having issues. 80ms is more than enough time for a response after a receive event. The .net serialports has it's issues but none that I've come across that couldn't be overcome including high throughput data rates.

Perhaps you could post some of the code you are using, perhaps there is a setting you are overlooking.
Regards
Utheen 29-Aug-14 2:02am    
I tested this code with standard baud rate of 9600, but the timeout exception occurred again.
Our application at the receiving end shows the No response error due to system.Timeout exception.
gggustafson 29-Aug-14 11:10am    
We need the exact error, not a paraphrase. We also need to see the code where the exception occurs.

1 solution

while (bytesRcvd<<bytesexpd)>
{

bytesRcvd+= serialPort.Read(rdBytes, bytesRcvd, bytesExpd- bytesRcvd);

}
bytesExpd= (int)rdBytes[1];
while (bytesRcvd<bytesexpd)>
{

bytesRcvd+= serialPort.Read(rdBytes, bytesRcvd, bytesExpd- bytesRcvd);

}
 
Share this answer
 
v2

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