gpt4 book ai didi

python - 串行测试

转载 作者:行者123 更新时间:2023-11-28 17:51:32 24 4
gpt4 key购买 nike

我是 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 文件中编写了这个程序并运行它。现在,如果我想测试此应用程序以检查我是否发送了正确的字符串(例如:Hyperterminal 或其他东西),我该怎么做。谁能指导我?

最佳答案

virtual serial port

使用虚拟串行端口进行测试。

对于 Windows,我使用 com0comsocat对于 Linux。然后,使用 Putty 可视化您的发送。

关于python - 串行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8971112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com