我是Pyserial和硬件领域的新手。我试图运行http://pyserial.sourceforge.net/shortintro.html#opening-serial-ports中给出的示例应用程序
import serial
ser = serial.Serial(0) # open first serial port
print ser.portstr # check which port was really used
ser.write("hello") # write a string
ser.close()
我用python文件编写了这个程序并运行它。现在,如果我想测试这个应用程序来检查我是否发送了正确的字符串(例如:超级终端或其他什么),我该怎么做呢。有人能引导我吗?在
另一种测试物理串行端口的快速方法是用电线/螺丝刀、鳄鱼钳或任何你手头上的东西,把RX和TX(接收和发送)桥接在一起。在这一点上,你发出的一切都会被循环到你身上。您可以在下面使用以下代码片段接收它:
这段代码正常工作的关键是将RX和TX桥接在一起。很多教程都会告诉你如何做到这一点。在
使用虚拟串行端口进行测试。在
对于Windows,我在Linux上使用com0com和socat。 然后,使用Putty可视化发送。在
相关问题 更多 >
编程相关推荐