Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serial Port Cable Unplugged

In .Net's SerialPort object, is there a way to determine if a serial port gets unplugged or plugged in.

like image 506
maxfridbe Avatar asked Jun 29 '09 19:06

maxfridbe


People also ask

What are the symptoms of the serial port failure?

Typical symptoms associated with serial, parallel, or game port failures include the following: A 199, 432, or 90x IBM-compatible error code displays on the monitor (printer port). The printer's Online light is on but no characters are printed when print jobs are sent to the printer.

How do I fix a serial port problem?

Go to Device Manager > Ports (COM & LPT) > mbed Serial Port, then right-click and select "properties". Choose "Port Settings" Tab, and click "Advanced" Under "COM Port Number", try selecting a different COM port.

How do you check RS-232 port is working or not?

By looping the transmit and receive pins, you can test serial cable port communication by checking if the serial ports connections transmit and receive valid information. This is called a loopback test and can be used to test rs232 communication. Use a screwdriver to loop pins for testing.

Does serial port provide power?

Serial cards derive power from the PCI or PCI Express slot on the motherboard. When you power serial devices from the serial card ports, the power provided by the slot may not be enough to power all of the devices and you should connect additional sources of power from the power supply.


3 Answers

Unlike USB, the serial port does not have any built-in way to detect a physical change in link status. A limited form of "device ready/not ready" signalling can be done using some of the pins (namely DTR, DSR, and sometimes DCD), but this doesn't seem like exactly what you're looking for (it's not built in to RS232 -- the device must support it, you mainly use it to talk to modems.)

So, in short: no, in the general case. If you know/can program the device you're trying to communicate with, and you know that it will hold a certain line high (for example), you could poll it looking for that line to go high. But if you plug in a device which isn't programmed to do something predictable like that, then there's really no way to tell. (Some devices may hold DSR high by default but it's in no way a sure bet.)

like image 81
andersop Avatar answered Sep 22 '22 15:09

andersop


Most serial devices have some type of ack response to a query. just send a simple query and wait for response. If you don't get it, the device is not there or at least not responding.

like image 24
Jim C Avatar answered Sep 22 '22 15:09

Jim C


I haven't tried it, but look at the SerialPort.PinChanged event and DsrChanged.

Whenever there's any normal device plugged in to the serial port and switched on, then I'd expect the port's DSR pin to be asserted; and conversely if that device is unplugged, or when it's switched off, then I'd expect the DSR pin state to change/drop.


The usual meaning of the various pins is:

  • DSR: device is plugged in and switched on
  • CTS: device is ready to receive data (this may be down even when a device is plugged in, e.g. when the device has a limited on-board buffer and uses this pin to flow-control data transfer from the PC)
  • DCD: device (modem) has established a connection over the phone line to another modem (so anything you send is treated as data to be transferred to the remote modem)

Of these, the one that answers your OP is DSR.

like image 43
ChrisW Avatar answered Sep 23 '22 15:09

ChrisW