通过批处理文件从串行 COM 端口切换引脚
我正在尝试使用串行端口的引脚之一来切换某些外部硬件。我希望能够调用批处理文件或类似的文件来打开/关闭引脚的输出。有没有一种简单的方法可以做到这一点?
理想情况下,我也希望能够使用 USB 端口来完成此操作,但我认为这会更难做到。是这样的吗,usb 端口上的一个引脚很容易翻转吗?
干杯,
马克
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用串行端口(甚至 USB 转 RS232 适配器)来完成此操作。
最简单的方法是调出 DSR/DTR 线路。打开这些线路的最简单方法是使用大多数软件打开端口。我可以为您提供更多帮助,但我不知道您的目标平台是什么。
请参阅此处的引脚分配: http://www.aggsoft.com/ rs232-pinout-cable/pinout-and-signal.htm
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
如果您有LPT(行式打印机终端),那将是您最好的选择。您还可以使用 USB-2-LPT 适配器。更多选项是 USB 数字 I/O 设备。您可能需要使用并行输出或具有数字 IO 引脚的设备(例如此)。尝试使用串行端口来控制外部设备将需要 UART 设备将串行信号转换为并行位。
(更有趣... 蓝牙转 GPIO)
编辑让一些快乐.. .
是的,您可以使用串行端口控制单个位输入/输出的硬件控制引脚。至于 USB-LPT 的问题,这可能取决于特定的硬件或平台 btu,我还没有遇到过这个问题。
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.