Serial Port communication
-
Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance
-
Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance
-
Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance
It's a bit of an odd scenario since real serial ports don't tend to disappear, and it doesn't seem this possibility was taken into account when Microsoft wrote the SerialPort class: There's no event that indicates Com-port "disappearance" in it. I guess your best option would be to start a separate thread that polls
SerialPort.IsOpen
every now and then: Most likely this will throw the error you got earlier when you disconnect the USB adapter, so you can catch that to see if the port's still there... Of course, you'll need to catch it at any other reference to SerialPort as well, that's just decent programming. Alternatively, there might be a class somewhere in the .Net framework that monitors USB devices, don't have any experience with that. Could very well be a p/invoke kind of thing.Standards are great! Everybody should have one!
-
Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance
I Need Some Code For Detecting Seriao Port As COM post Of My System. But Every where written in .Net2.0 Serialport.Port name space is used but iam develope my project in .Net1.1 then plaese Help ME Thanks In Advance