commit 94d3d4a5a389037a98ac150f0828b1d5b4c36a24 Author: PAN Lei Date: Mon Feb 7 09:13:45 2022 +0100 first commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..75660ab --- /dev/null +++ b/main.py @@ -0,0 +1,33 @@ +import serial + +serial_list=[] +ser = serial.Serial("COM74", 115200, timeout=1) + + +def changeToSMSMode(): + cmd = "AT+CMGF=1\r" # text mode + sendCommand(cmd) + msg = ser.read(64) + print(msg) + + +def sendCommand(cmd: str): + print("send command {}".format(cmd)) + ser.write(cmd.encode()) + msg = ser.read(100) + print(msg) + + +if __name__ == '__main__': + #enable verbose logs + cmd = "AT+CMEE=2\r" + sendCommand(cmd) + #check pin + cmd_check_pin = "AT+cpin?\r" + sendCommand(cmd_check_pin) + # cmd = "AT\r" + # sendCommand(cmd) + # msg = ser.read(64) + # print(msg) + # changeToSMSMode() +