IO Serial COM Exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I write a dll use vb.net 2005 to read data from a serial port and use this
dll in a C# 2005 application. It works well except when I close the port.
After I close the port, sometimes the dll stopped at the readline statement
in data_received function. But the port closed already, why this function is
still fired? ( is it because the delay message? I guess ) I catch the
exception and try to throw a excption, but the dll stopped at the throw
exception statement. This problem is not always there, but sometimes, lets
say 1 of 5. The error message in debug mode is "System.IO.IOException was
unhandled".

Your help are always appreciated
 
Hi,

This (probably) is a problem in the device driver handling the serial port.
I say this because I have seen it with USB serial devices, but not with
internal ports that use physical UARTs instead of the virtual UART that is
furnished by a USB adapter.

You can download DesktopSerialIO.dll for VS2005 from my homepage. I have
tested it with several USB devices, and it (so far) does not have this
problem. Let me know if it works for you. The API that it provides is
similar the SerialPort, but not exactly the same, so you will have to do a
small amount of "porting."

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Thank you, Richard

Sorry for the late reply.
I'm trying to use your dll; one question, how the CommPort (an Integer)
relate to Serial Port ( a string, COM1, COM2...)?

Rgds,

Taoge
 
Hi Richard,

Is the InputString same as ReadLine?
If set the PortOpen property to false, is the Port closed and released? Or
should I use dispose to release the port?

Thanks
 
Back
Top