Click here to Skip to main content
15,886,634 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
Python
##### 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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900