python调用串口,写入数据#!/usr/bin/python3importserialdefserialTest():try:port="COM3"bps=115200timeO=5ser=seria
python调用串口,写入数据
#!/usr/bin/python3
import serial
def serialTest():
try:
port = "COM3"
bps = 115200
timeO = 5
ser = serial.Serial(port, bps, timeout = timeO)
result = ser.write("python invoke serial".encode("gbk"))
print("write data: ", result)
ser.close()
except Exception as e:
print("ERROR: ", e)
if __name__ == "__main__":
serialTest()
以上这篇python3 实现调用串口功能就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
python3 调用 串口