1 import serial 2 3 uart = serial.Serial(‘COM31‘,115200,serial.EIGHTBITS,serial.PARITY_NONE,serial.STOPBITS_ONE,timeout=1,write_timeout=1) 4 uart.open() 5 uart.rts = 1 6 uart.dtr = 1 7 cmd = b‘ATI‘+b‘\x0D‘+b‘\x0a‘ 8 write_len = uart.write(cmd) 9 rsp_str = uart.read(512) 10 print("rsp:%s"%(rsp_str.decode(‘utf-8‘))) 11 uart.close()
原文:https://www.cnblogs.com/Wokky/p/10306651.html