SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By fireball003
#45481
Hi,
I was unable to send GPS data or any data using python script. But all the parts (like connecting to GPRS, successfully sending data to server getting GPS data etc) work perfect when I send AT command manually.

Please have a look at the code and suggest me what to modify-
Code: Select all
import MDM
import MOD

ip='IP'
apn = 'gpinternet'
server = '0.0.0.0'
MDM.send('AT+CGDCONT=1,'+ip+','+apn+','+server+'\r',0)
res = MDM.receive(20)
print res
username = 'whatever'
password = 'whatever'
MDM.send('AT#USERID='+username+'\r',0)
res = MDM.receive(20)
print res
MDM.send('AT#PASSW='+password+'\r',0)
res = MDM.receive(20)
print res


MDM.send("AT#GPRS=1\r",0)
res = MDM.receive(80)
print res

MDM.send('AT$GPSACP\r',0)
gps = 'This is GPS data:'+MDM.receive(30)
gps = gps.replace(' ','')
gps = gps.replace('\r','') 
gps = gps.replace('\n','') 
gps = gps.replace('OK','')
print gps

web = 'www.e-secretary.net'
MDM.send('AT#SKTD=0,80,'+web+'\r',0)
res = MDM.receive(50)
print res

req1 = 'GET /gps/dgl.php?name='+gps+' HTTP/1.0'
req2 = 'Host: '+web
req3 = 'Connection: keep-alive'
MDM.send(req1,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(10)
MDM.send(req2,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(10)
MDM.send(req3,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
MDM.sendbyte(0x0d,0)
MDM.sendbyte(0x0a,0)
res = MDM.receive(100)
print res


Also please suggest me an easy way to debug python modules easily without using hardware debugger.

Is there any way to show output or responses or variable values in rsterm or terminal?

Thanks in advance.
By incognico
#45664
Is there any way to show output or responses or variable values in rsterm or terminal?
import the SER module and use the serial comms for your debugging -

import SER
SER.set_speed('115200','8N1')

Then just change all your "print" lines to SER.send

Good luck!
By fireball003
#45669
Thanks a lot for your reply !! That was really helpful to me. I just lost faith on python interpreter in that module.

However it seems I am making silly mistake. Will you please look at my program and tell me where the problem is? Or can you send me any sample GPS data sending program using python?

Thanks a lot.
By jasonharper
#45672
Is the string "ThisisGPSdata:" supposed to be part of the parameter you send to the server?
By fireball003
#45673
Yes, But that is nothing.That was just to check the string add.

Thank you
By incognico
#45678
Do you get any output when running the code...?

Post it up.
By fireball003
#45954
Hi,
I was trying for several days but couldn't make a way out. I tried the following-

1. Simple code hello.py -

import SER
SER.set_speed('115200','8N1')
SER.send("Hello world")
SER.sendbyte(0x0d)
SER.receive(10)

2. then I connected to Rsterm at 115200 speed with hardware flowcontrol where DTR pin was set low.
3. Upload hello.py in the module . Then execute it using AT#EXECSCR

and it showed me nothing.

Now where am I missing something so that I can't see the output in the terminal?

FYI it is for sure that the code executes properly. Because I tried my simple "sms gps data" code which ran and sent me sms. But I didnt see any SER.send values.

Please help me here to see teh output in the terminal or Rsterm.

Thanks in advance.