In .Net's SerialPort object, is there a way to determine if a serial port gets unplugged or plugged in.
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.
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.
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.
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.
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.)
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.
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:
Of these, the one that answers your OP is DSR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With