Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Python GPS
Hi code project members
i'm developping a python script for tracking which will be uploaded to gm862-gps module
once the evk3 (mother_board) is connected to my laptop by the rs232-usb connector, i uploaded this python code on:
##### Constants #####

TRUE = 1
FALSE = 0
LOOP = 1
SPEEDLIMIT = 30
 
##### Modules #####

#Use serial
import SER
 
#Use build in module
import MOD
 
#Use AT command interface
import MDM
 
#Use GPS
import GPS
 
###### General Functions ######

#Debug message
def errorsmg(msgtext):
somme = msgtext #msgtext = msgtext.replace('\r', '\\r')
#msgtext = msgtext.replace('\n', '\\n')
print (somme)
 
SER.send(msgtext + '\r\n')
#f = open('log.txt','ab')
#f.write(msgtext + '\n')
#f.close()

#GPS status
def gps_status(gpspos):
debugmsg('Retrieving GPS status')
 
gpspos_parts = gpspos.split(',')
 
if ( (gpspos_parts[5] == '2') or (gpspos_parts[5] == '3') ): #2D or 3D fix
#debugmsg('GPS fix "' + gpspos_parts[5] + '" ie valid');
status = TRUE
else:
#debugmsg('GPS fix "' + gpspos_parts[5] + '" ie not valid');
status = FALSE
 
return status
 
###### SMS Library Functions ######

#Setup SMS
def sms_setup():
 
debugmsg('Setting up SMS')
 
MDM.send('AT+CMGF=1\r', 0)
res = MDM.receive(50)#5 sec
MOD.sleep(1)#wait 0.1sec

debugmsg('SMS setup: ' + res)
 
def testspeed(gpspos):
 
#debugmsg('Test if speed is over limit')

gpsdataparts = gpspos.split(',')
currentspeed = gpsdataparts[7]
debugmsg('Time is ' + gpsdataparts[0] + ' UTC time')
debugmsg('latitude is ' + gpsdataparts[1])
debugmsg('longtitude is ' + gpsdataparts[2])
debugmsg('heading is ' + gpsdataparts[6])
debugmsg('Speed is ' + gpsdataparts[7] + ' km/hr')
debugmsg('date is ' + gpsdataparts[9])
 
if (gps_status(gpspos) == TRUE):
debugmsg('Has GPS Fix')
if (float(gpsdataparts[7]) < 60.0):
debugmsg('Speed UNDER the speed limit')
 
else:
debugmsg('Has NO GPS Fix to be tested for overspeeding')
 

 
SER.set_speed('115200','8N1')
SER.send('\r\n--------------------\r\n\r\n')
 
debugmsg('Running...');
 
#Set verbose error reporting
MDM.send('AT+CMEE=2\r', 0)
MDM.receive(50)#5 sec
MOD.sleep(1)#wait 0.1sec

#Setup SMS
sms_setup()
 
#Main loop
while (LOOP==1):
 
debugmsg('Entering loop')
 
#Retrieve current position
gpspos = GPS.getActualPosition()
 
debugmsg('Position: %s' % gpspos)
 
#Retrieve GPS fix status
gps_statusnow = gps_status(gpspos)
 
#Save last valid position
#If position fix valid, or none recorded already, use last retrieved
if ( (gps_statusnow == TRUE) or (gps_statusnow == FALSE) ):
testspeed(gpspos)
 
debugmsg('Powersave for 10 seconds')
 
#Powersave for 10 seconds
MOD.powerSaving(10)
would you like to tell me why i upload it on the gm862-gps, and it still do not execute ?
thx in advance
Posted 29-Jun-13 12:51pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100