Re: SerialPort.WriteTimout
James Berry <[email protected]> Wed, 9 Jan 2008 17:47:36 +0000
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Portmon (sysinternals) is a free serial port monitoring tool http://technet.microsoft.com/en-gb/sysinternals/bb896644.aspx -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Don Clark Sent: 09 January 2008 17:23 To: [email protected] Subject: Re: [DOTNET-WINFORMS] SerialPort.WriteTimout Peter - One other thing to look for. Is all of the data that you're transmitting to the port data that the device can accept? Perhaps you're unknowingly sending a control string to the device and causing it to stop receiving data. If the device stops accepting data you'll get a timeout exception. A couple of things that I've done to figure this out in the past. 1) Set the timeout to infinite to see if the device can accept all of the data. 2) Use a serial port spy to see what data is being transmitted between the serial port and the device. I use a program named Advanced Serial Port Monitor (about $60) and it has saved me many times. Don -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Tuesday, January 08, 2008 7:28 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] SerialPort.WriteTimout Thanks, Don. I have a very small test c# (2.0) app that opens a serial port, sets the baud rate and a few other items, and then writes a stream of 50 chars. Doesn't seem to present a problem. I have a much larger, more complicated c# app that also writes to a serial port with similar port settings and less characters and I keep getting a write timeout error. So it doesn't seem to be the hardware. I am looking for other places I might have screwed up (and yes, I do know the port is open! :-)). Peter -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Don Clark Sent: Tuesday, January 08, 2008 5:31 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] SerialPort.WriteTimout It's not always just the length of the data and the baud rate. I've seen write timeouts happen when using virtual serial port controls even though given the baud rate and the length of the data there was ample time to complete the operation. The most recent drivers for the siLabs 210x USB to Serial chips seem to be especially slow. With a write timeout of 400ms I was sometimes unable to write 2 characters to my device at 38400 baud. If the write operation isn't completed during the timeout period a timeoutexception will be thrown. Don -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Tuesday, January 08, 2008 1:58 PM To: [email protected] Subject: [DOTNET-WINFORMS] SerialPort.WriteTimout I have been searching for info on what actually will cause a WriteTimeout error to happen on a serialport object in net 2.0. There are lots of articles that talk about a Write operation not being able to complete in the time allotted. However, besides having a series of bytes to be written that when taking into the account the baud rate cannot complete in the allotted time, I can't think of another reason for this error to occur - nor can I find reference to when it will occur. Any ideas or places you could point me, please? Sincerely, Peter