发布时间:2019-09-05 07:07:48编辑:auto阅读(1856)
在windows中,使用Python进行串口编程需要安装一个Serial模块pyserial:
下载地址:https://pypi.python.org/pypi/pyserial下载完成后得到一个pyserial-3.2.1-py2.py3-none-any.whl文件,下面进行安装
编程测试程序
import serial
import serial.tools.list_ports
plist = list(serial.tools.list_ports.comports())
if len(plist) <= 0:
print("the serial port can't find")
else:
plist_0 = list(plist[0])
serialName = plist_0[0]
serialFd = serial.Serial(serialName, 9600, timeout=60)
print("check which[%s] port was really used>" % serialFd.name)
while True:
data = serialFd.read()
print(data)
上一篇: python 钩子函数详解
下一篇: Python——生成矩阵
47863
46424
37314
34760
29332
25990
24945
19967
19564
18050
5806°
6433°
5948°
5975°
7080°
5926°
5963°
6456°
6418°
7798°