I have a issue with a script that is supposed to check the balance for my mobile pre-paid SIM card. The command is ATD*111# and it works okay with "screen".
When I use it in a script, I get this error:
Error XML Parse Error: not well-formed (invalid token)
Error On character 256 of line number 1.
Here is the script:
- Code: Select all
#!/usr/bin/env python
import serial
import time
indigo.server.log ("Starting...") #indigo log message
ser = serial.Serial('/dev/tty.GI505 Modem', 115200, timeout=2) #serial port is /dev/tty.GI505 Modem, baudrate 115200
ser.write('ATD*111# \r')
time.sleep(.5)
res = ser.read(size=100) #read result from modem
time.sleep(1)
ser.close()
indigo.server.log ("Modem result codes: " + "\r" + res) #indigo log message
However, the strange thing is that it works when I add another 0 in the AT command. The modem doesn't give the correct output since the AT command is incorrect, but the script works.
- Code: Select all
#!/usr/bin/env python
import serial
import time
indigo.server.log ("Starting...") #indigo log message
ser = serial.Serial('/dev/tty.GI505 Modem', 115200, timeout=2) #serial port is /dev/tty.GI505 Modem, baudrate 115200
ser.write('ATD*1110# \r')
time.sleep(.5)
res = ser.read(size=100) #read result from modem
time.sleep(1)
ser.close()
indigo.server.log ("Modem result codes: " + "\r" + res) #indigo log message
The modem then reports:
ATD*1110#
+CUSD: 2,"Unexpected Data Value",15
Which is expected since there is a zero that shouldn't be there.
Any ideas why the script doesn't work with ATD*111# but it works with ATD*1110# ? Did I miss something?