Do the RtsEnable or DtrEnable properties provide a signal?
I want to know if I put them in my code, is the computer sending any signal to the device?
SerialPort myport = new SerialPort("COM1");
myport.DtrEnable = true;
myport.RtsEnable = true;
I need to send a signal to certain pins on a device. Since I know Dtr and Rts are using pins 4 and 7. So when I write the code above, will my computer send a signal to pins 4 and 7? Or is there an easy way to send a signal to a specific pin?
source to share
In theory: Yes. Whatever you plugged into your serial port, you will see something. It won't be data, but if he checks his contact states, he will know that you have done something.
In practice: Maybe. The ability to accurately determine these pin states is highly dependent on the cable used. Here's a recent post that touches on cable-related issues with these pin states.
source to share
Of course, these properties control the state of the acknowledgment signals. Their use is not arbitrary, but a properly designed serial port device draws attention to them. DTR is a Data Ready terminal, usually connected to DSR (Data Ready) on the device. The device assumes that your computer is simply not turned on or the cable is unplugged when the DSR is turned off. It will not send anything and ignores anything you send when the signal is off.
RTS is a request to send, usually connected to CTS (Clear To Send) on the device. Typically used for flow control, it prevents the device from sending too much data and overflowing the receive buffer. Disgusting problem that is very difficult to recover, data is completely lost.
Typically you should set the SerialPort.Handshake property to HandShake.RequestToSend for the driver to do this automatically. A very common mistake is to leave it set to Handshake.None, now you have to enable these signals yourself. Of course, you run the risk of a buffer overflow, although you will have to write very slow code to ever get into the danger zone. It's done.
These signals can be used in hobby projects to control, say, a reed switch. Beware that the voltages on the signal lines are unpredictable (fluctuations from +/- 5 to 24 volts) and may not supply many amplifiers (typically 20 milliamps maximum). You need at least a diode, usually a transistor, to switch a heavier load. Ask about it at electronics.stackexchange.com
source to share