想通过代码获取发送AT指令的返回值,代码如下:
import serial
import serial.tools.list_ports
port_list = list(serial.tools.list_ports.comports())
if len(port_list) <= 0:
print "The Serial port can't find!"
else:
print "ok"
port_list_0 = list(port_list[0])
com = port_list_0[0]
print com
com1 = serial.Serial(com,timeout = 50)
com1.write('4b cd 71 00 02')
com1.inWaiting()
result = com1.read(com1.inWaiting())
print result
但是给出的结果没有返回值,是:
ok
COM28
[Finished in 0.2s]
想获取发送指令“4b cd 71 00 02”的返回值,但是给的结果是:
ok
COM28
[Finished in 0.2s]