使用Go串口库如何检查线路状态(RS232)

huangapple go评论105阅读模式
英文:

how to check line status(RS232) using Go serial library

问题

我在使用树莓派向电压设备发送命令时,遇到了检查线路状态(忙碌或空闲)的困难。在Go语言中是否有任何函数可以检查线路状态,还是我需要编写一个单独的函数来实现?请帮帮我。

英文:

I am facing difficulty in checking line status( busy or clear) to send commands from Raspberry pi to voltage device. is there any function to check the line status in Go language or else i need to write a separate function for it???? please help me out.

答案1

得分: 3

你正在使用的库提到它不支持硬件流控制,所以看起来你需要自己修改它。

然而,还有另一个Go串口库https://github.com/schleibinger/sio,它允许你读取/设置RTS、CTS、DTR和DSR引脚。如果你正在使用通过USB的虚拟串口,这应该可以实现你想要的功能。源代码只有一个文件,相关的方法在底部附近。

然而,如果你正在使用树莓派的GPIO引脚,这个库对你来说不适用。

英文:

The library you're using mentions that it doesn't support hardware flow control, so it looks like you'd have to modify it yourself.

However, there is another Go serial library https://github.com/schleibinger/sio that allows you to read/set the RTS,CTS,DTR and DSR pins. If you are using a virtual serial port over USB this should allow you to do what you want to do. The source code is only 1 file--the relevant methods are near the bottom.

However, if you are using the Raspberry Pi's GPIO pins, this library won't work for this.

huangapple
  • 本文由 发表于 2013年8月31日 12:44:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/18544569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定