SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By colinsauze
#33624
I'm using a GM862-GPS running firmware version 07.02.403 with a V3 RS232 breakout board and i'm having problems with the MDM commands in Python. I've not got a debug board (and the Telit Serial Port multiplexer for CMUX just freezes) and so i've used a combination of SER.send and an LED on a GPIO line for debugging.

What i'm basically seeing is I can use GPS, GPIO, SER and MOD commands without any problem but that MDM commands just seem to make my programs terminate.

When I run the following I see the "hello world" the LED i've attached to GPIO3 goes on but I never get any output from the result of the MDM.send command and it never reaches the code to turn the LED off.

Can anyone tell me what i'm doing wrong here?
Code: Select all
import SER
import MDM
import MOD
import GPIO

SER.set_speed('115200','8N1')
SER.send('Hello World\r\n')

GPIO.setIOdir(3,1,1)
GPIO.setIOvalue(3,1)

res = MDM.send('AT+CPIN?\r', 0)
SER.send('res='+res)
res = MDM.receive(10)
SER.send('res='+res)

GPIO.setIOvalue(3,0)
By evera79
#40780
It was also quite tough for me to get this at first...

Please notice that MDM.send(string,timeout) will only respond with an integer (1 if string passed or -1 if string has not passed)... Then if you try to concatenate this integer response with a string ("res="), code will break at

res = MDM.send('AT+CPIN?\r', 0)
SER.send('res='+res)


It's also important to notice that the actual VERBOSE response from the command can only be retrieved by MDM.receive(timeout), whose response is indeed a string... And also very important is the fact that the minimum time for response to arrive, is in most cases, little less than 1 sec... so I guess it won't hurt at all if you use 20 to 200 for timeout value.

try this instead
Code: Select all
import SER 
import MDM 
import MOD 
import GPIO 

SER.set_speed('115200','8N1') 
SER.send('Hello World\r\n') 

GPIO.setIOdir(3,1,1) 
GPIO.setIOvalue(3,1) 

res = MDM.send('AT+CPIN?\r',10) 
if res <> -1:
     res = MDM.receive(200) 
     SER.send('res='+res) 
else:
     SER.send('Not executed\n')

GPIO.setIOvalue(3,0)