Hi everyone, I am coding the python script for check balance of the sim on module GSM A6, here is my python code:
port = serial.Serial("/dev/ttyAMA0",baudrate=9600,timeout=1)
port.write('AT+CMGF=0'+'\r\n')
time.sleep(2)
port.write('AT+CSCS="HEX"'+'\r\n')
time.sleep(2)
port.write('AT+CUSD=1,"*101#",15'+'\r\n')
time.sleep(60)
while True:
if port.inWaiting() > 0:
reply = port.readline()
if '+CUSD:' in reply:
reply = reply[reply.find(',"'):reply.find('",')]
print reply
else:
break
port.flushInput()
port.flushOutput()
port.close()
The response from serial sometime I can get full, some time it was corrupted like this:
+CUSD: 1, "D8B41B344687DF20580C879BC56A��MN�&���
How can I fix that ?