Toggle pin from serial COM port via batch file
I'm attempting to use one of the pins from the serial port to toggle some outside hardware. I want to be able to call a batch file or something similar to be able to turn on/off the output of the pin. Is there a simple way to do this?
Ideally i'd like to be able to do this with a USB port as well but I'd image it will be harder to do. Is this the case is it easy to flip one pin on a usb port?
开发者_高级运维Cheers,
Mark
You can do this with a serial port, even with a USB to RS232 adapter.
The easiest way to do it is to bring up the DSR/DTR lines. The easiest way to bring up those lines is by simply opening the port with most software. I could help you more, but I don't know what platform you're targeting.
See the pinout here: http://www.aggsoft.com/rs232-pinout-cable/pinout-and-signal.htm
If you have a LPT (Line Printer Terminal) that would be your best bet. You would also be able to use a USB-2-LPT adapter. More options would be USB Digital I/O device. You will probably want something that uses either parallel output or has digital IO pins (such as this). Trying to use a serial port to control something external will require a UART device to convert the serial signal into the parallel bits.
(Even more fun... Bluetooth to GPIO)
Edit to make some happy...
Yes you could control the hardware control pins for single bits of input/output with a serial port. As to the point about USB-LPT, that could be the case depending on the particular hardware or platform btu I have yet to run into it as an issue.
精彩评论