本文整理汇总了Python中GPS.getLastRMC方法的典型用法代码示例。如果您正苦于以下问题:Python GPS.getLastRMC方法的具体用法?Python GPS.getLastRMC怎么用?Python GPS.getLastRMC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPS
的用法示例。
在下文中一共展示了GPS.getLastRMC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SMSCommand
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import getLastRMC [as 别名]
#.........这里部分代码省略.........
#Did we timeout or get an ERROR during the SMS sending?
if (rtnList[1].find("timeOut")!=-1 or rtnList[1].find("ERROR") != -1):
rtnList[0] = -4
elif (StatusQuery != -1):
#Status query for the module, pass back the current configuration values and location
#This is the first elif to catch the STATUS check without accidentally triggering the general AT check
mySER.sendUART("Status Query :\r\n")
#Check the CELL LED Status to report
rtnList = ATC.sendAtCmd('AT#GPIO=1,2' ,ATC.properties.CMD_TERMINATOR,5)
#GPIO: 2,0
if (rtnList[1].find('#GPIO: 2') != -1):
CELL_LED = 'ON'
else:
CELL_LED = 'OFF'
#Check the GPS/USER LED Status to report
rtnList = ATC.sendAtCmd('AT#GPIO=2,2' ,ATC.properties.CMD_TERMINATOR,5)
#GPIO: 2,0
if (rtnList[1].find('#GPIO: 1,1') != -1):
USER_LED = 'ON'
else:
USER_LED = 'OFF'
#The following are available through the included GPS module:
#GPS.getActualPosition(), returns all fields like AT$GPSACP would
#GPS.getLastGGA()
#GPS.getLastGLL()
#GPS.getLastGSA()
#GPS.getLastGSV()
#GPS.getLastRMC()
#GPS.getLastVTG()
#GPS.getPosition(), this gives LAT/LONG in numeric format
#For the purposes of this demo, RMC will be used
CurrentLocation = GPS.getLastRMC()
QueryResponse = str("Unit: " + ATC.properties.IMEI+ "\r\n" +
"Status LED: " + CELL_LED + "\r\n" +
"USER LED: " + USER_LED + "\r\n" +
"Current Location: " + CurrentLocation + "\r\n")
mySER.sendUART(QueryResponse)
rtnList = sendSMS(QueryResponse,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
rtnList[0] = 0
#Did we timeout or get an ERROR during the SMS sending?
if (rtnList[1].find("timeOut")!=-1 or rtnList[1].find("ERROR") != -1):
rtnList[0] = -4
elif (ATCMD != -1):
#AT command found, execute the command and pass back the response to the main program.
#Using this instead of the sendatcommand method because it doesn't parse possibly useful information in an open ended response.
#res = MDM.send(inStr, 0)
#res = MDM.sendbyte(0x0d, 0)
#Grab the response of the command in it's entirety
#ATCMDResponse = ATC.mdmResponse(ATC.properties.CMD_TERMINATOR, 10)
ATCMDResponse = ATC.sendAtCmd(inStr ,ATC.properties.CMD_TERMINATOR,5)
#Did we get an ERROR from the AT command?
if (ATCMDResponse[1].find("ERROR") != -1):
rtnList[0] = -2
#Pass it to the UART and also send an SMS with the response.
mySER.sendUART(ATCMDResponse[1] + "\r\n\r\n")
rtnList = sendSMS(ATCMDResponse[1],SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
rtnList[0] = 0
#Did we timeout or get an ERROR during the SMS sending?
if (rtnList[1].find("timeOut")!=-1 or rtnList[1].find("ERROR") != -1):
rtnList[0] = -4
else:
#Unrecognized SMS
mySER.sendUART("Unrecognized/Unsupported Command Received: " + inStr + "\r\n\r\n")
rtnList = sendSMS("Unrecognized/Unsupported SMS Received: " + inStr,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
rtnList[0] = -3
#Did we timeout or get an ERROR during the SMS sending? Otherwise just return the -3
if (rtnList[1].find("timeOut")!=-1 or rtnList[1].find("ERROR") != -1):
rtnList[0] = -4
except:
print sys.exc_info()
rtnList[0] = -1
return rtnList
示例2: SMSCommand
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import getLastRMC [as 别名]
#.........这里部分代码省略.........
tmpReturn = 0
elif (ReceivedCmd == 'IGNITIONFOLLOW = FALSE'):
JANUS_CONFIG.Config.IGNITIONFOLLOW = 'FALSE'
JANUS_SER.sendUART("Ignition Follow : " + JANUS_CONFIG.Config.IGNITIONFOLLOW + "\r\n")
res = sendSMS("Ignition Follow : " + JANUS_CONFIG.Config.IGNITIONFOLLOW,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
tmpReturn = 0
else:
JANUS_SER.sendUART("Unrecognized/Unsupported Command Received: " + ReceivedCmd + "\r\n")
res = sendSMS("Unrecognized/Unsupported Command Received: " + ReceivedCmd,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
tmpReturn = -2
#Did we timeout or get an ERROR during the SMS sending?
if (res.find("timeOut")!=-1 or res.find("ERROR") != -1):
tmpReturn = -4
#If we sucessfully changed the configuration amd sent the message, update and save the configuration file.
if (tmpReturn == 0):
res = JANUS_CONFIG.UpdateConfig()
if (res == -1):
JANUS_SER.sendUART("Configuration Save Error.\r\n\r\n")
res = sendSMS("Configuration Save Error.",SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
return
else:
JANUS_SER.sendUART("Configuration file updated.\r\n\r\n")
elif (StatusQuery != -1):
#Status query for the module, pass back the current configuration values and location
#This is the first elif to catch the STATUS check without accidentally triggering the general AT check
JANUS_SER.sendUART("Status Query :\r\n")
#The following are available through the included GPS module:
#GPS.getActualPosition(), returns all fields like AT$GPSACP would
#GPS.getLastGGA()
#GPS.getLastGLL()
#GPS.getLastGSA()
#GPS.getLastGSV()
#GPS.getLastRMC()
#GPS.getLastVTG()
#GPS.getPosition(), this gives LAT/LONG in numeric format
#For the purposes of this demo, GLL will be used
CurrentLocation = GPS.getLastRMC()
QueryResponse = str("Unit: " + ATC.properties.IMEI+ "\r\n" +
"Switch Reporting: " + JANUS_CONFIG.Config.NOSWITCH + "\r\n" +
"Ignition Reporting: " + JANUS_CONFIG.Config.IGNITION + "\r\n" +
"Status LED: " + JANUS_CONFIG.Config.SLED + "\r\n" +
"User LED: " + JANUS_CONFIG.Config.ULED + "\r\n" +
"Auto ON: " + JANUS_CONFIG.Config.AUTOON + "\r\n" +
"Report Interval: " + JANUS_CONFIG.Config.INTERVAL + "\r\n" +
"Ignition Follow: " + JANUS_CONFIG.Config.IGNITIONFOLLOW + "\r\n" +
"Current Location: " + CurrentLocation + "\r\n")
JANUS_SER.sendUART(QueryResponse)
res = sendSMS(QueryResponse,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
tmpReturn = 0
#Did we timeout or get an ERROR during the SMS sending?
if (res.find("timeOut")!=-1 or res.find("ERROR") != -1):
tmpReturn = -4
elif (ATCMD != -1):
#AT command found, execute the command and pass back the response to the main program.
#Using this instead of the sendatcommand method because it doesn't parse possibly useful information in an open ended response.
#res = MDM.send(inStr, 0)
#res = MDM.sendbyte(0x0d, 0)
#Grab the response of the command in it's entirety
#ATCMDResponse = ATC.mdmResponse(ATC.properties.CMD_TERMINATOR, 10)
ATCMDResponse = ATC.sendAtCmd(inStr ,ATC.properties.CMD_TERMINATOR,3,2)
#Pass it to the UART and also send an SMS with the response.
JANUS_SER.sendUART(ATCMDResponse + "\r\n")
res = sendSMS(ATCMDResponse,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
tmpReturn = 0
#Did we timeout or get an ERROR during the SMS sending?
if (res.find("timeOut")!=-1 or res.find("ERROR") != -1):
tmpReturn = -4
#Did we get an ERROR from the AT command?
if (ATCMDResponse.find("ERROR") != -1):
tmpReturn = -2
else:
#Unrecognized SMS
JANUS_SER.sendUART("Unrecognized/Unsupported SMS Received: " + inStr + "\r\n")
tmpReturn = -3
res = sendSMS("Unrecognized/Unsupported SMS Received: " + inStr,SMSInfo.OriginatingPN,ATC.properties.CMD_TERMINATOR,3,180)
tmpReturn = 0
#Did we timeout or get an ERROR during the SMS sending? Otherwise just return the -3
if (res.find("timeOut")!=-1 or res.find("ERROR") != -1):
tmpReturn = -4
except:
printException("SMSCommand()")
return tmpReturn
示例3: main
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import getLastRMC [as 别名]
#.........这里部分代码省略.........
res = ATC.getUnitInfo()
# Start timeout timer
timerB = timers.timer(0)
timerB.start(int(myApp.INTERVAL))
SwitchPos = 'Open' #Default State for Switch
IgnPos = 'Inactive' #Default State for Switch
FirstTimeThrough = 'TRUE' #Initialize flag for the first time running the connection/loop
SENDSTRING = [] #Initialize the string list being sent to the server
StringCount = 0
# Loop forever, without this loop the script would run once and exit script mode. On reboot or power-on the script would run once more
while (1):
while (1):
MOD.watchdogReset()
#Update NMEA Data
#The following are available through the included GPS module:
#GPS.getActualPosition(), returns all fields like AT$GPSACP would
#GPS.getLastGGA()
#GPS.getLastGLL()
#GPS.getLastGSA()
#GPS.getLastGSV()
#GPS.getLastRMC()
#GPS.getLastVTG()
#GPS.getPosition(), this gives LAT/LONG in numeric format
#For the purposes of this demo, RMC will be used
#The returned value gives a \r\n at the end so we must strip it for proper usage.
GPSPositionTemp = ''
GPSPositionTemp = GPS.getLastRMC()
GPSPositionTemp = GPSPositionTemp.rstrip()
#Update switch and ignition information
#We simply clear after the report is sent, so by default it's sent as Open/Inactive until it's read as the opposite.
#We're polling the MCU signals and then signaling back "we got the information" so we only read once, giving us one or both events to report
# 0: Pass, Switch is triggered
# 1: Pass, Ignition is triggered
# 2: Pass, BOTH are triggered
# -1: Exception
# -2: Pass, Neither is triggered
EventCheck = JANUS_IO.SW_IGN_Status()
if (EventCheck == 0): #Switch has been triggered
SwitchPos = 'Closed'
#JANUS_SER.sendUART("SwitchPos : " + SwitchPos + "\r\n")
elif (EventCheck == 1): #Ignition has been triggered
IgnPos = 'Active'
#JANUS_SER.sendUART("IgnPos : " + IgnPos + "\r\n")
elif (EventCheck == 2): #Both have been triggered
SwitchPos = 'Closed'
IgnPos = 'Active'
#JANUS_SER.sendUART("IgnPos : " + IgnPos + "\r\n")
#JANUS_SER.sendUART("SwitchPos : " + SwitchPos + "\r\n")
if (myApp.SMS_ENABLED == 'TRUE'):
res = JANUS_SMS.CheckNewSMS()
#If a new SMS is found and is valid, pass it to the command logic
if (res != '0'):
#We have received a new SMS, let's find what it wants us to do.
#JANUS_SER.sendUART("SMS Data : " + str(res) + "\r\n")
示例4: main
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import getLastRMC [as 别名]
#.........这里部分代码省略.........
mySER.sendUART("GPS Initialized. \r\n\r\n")
mySER.sendUART("Initializing SMS. \r\n")
# Setup SMS
rtnList = mySMS.configSMS()
if rtnList[0] == 0:
mySER.sendUART("SMS Initialized. \r\n\r\n")
else:
return
# Update Unit information
rtnList = ATC.getUnitInfo()
if (rtnList[0] == -1) or rtnList[1] == "ERROR":
raise UserWarning
# Loop forever, without this loop the script would run once and exit script mode. On reboot or power-on the script would run once more
while 1:
# MOD.watchdogReset()
RegCheck = 0 # Initialize check
mySER.sendUART("Checking Modem Registration. \r\n")
# Wait until module is registered to GSM Network
rtnList = NETWORK.isRegistered(180) # Wait 180 seconds for module to obtain GSM registration
if (rtnList[0] == -1) or (rtnList[0] == -2) or rtnList[1] == "ERROR":
raise UserWarning
if rtnList[0] == 0:
RegCheck = 1
mySER.sendUART("Modem Registered. Waiting for SMS. \r\n\r\n")
# Loop forever, without this loop the script would run once and exit script mode. On reboot or power-on the script would run once more
while RegCheck == 1:
# MOD.watchdogReset()
# Update NMEA Data
# The following are available through the included GPS module:
# GPS.getActualPosition(), returns all fields like AT$GPSACP would
# GPS.getLastGGA()
# GPS.getLastGLL()
# GPS.getLastGSA()
# GPS.getLastGSV()
# GPS.getLastRMC()
# GPS.getLastVTG()
# GPS.getPosition(), this gives LAT/LONG in numeric format
# For the purposes of this demo, RMC will be used
# The returned value gives a \r\n at the end so we must strip it for proper usage.
# sleep for 1 second to let the GPS catch up otherwise we eventually get a response that .rstrip errors on
time.sleep(1)
GPSPositionTemp = ""
GPSPositionTemp = GPS.getLastRMC()
GPSPositionTemp = GPSPositionTemp.rstrip()
rtnList = mySMS.CheckNewSMS()
# If a new SMS is found and is valid, pass it to the command logic
if rtnList[0] == 1:
# We have received a new SMS, let's find what it wants us to do.
mySER.sendUART("SMS Received.\r\n")
mySER.sendUART("SMS Data : " + str(rtnList[1]) + "\r\n")
rtnList = mySMS.SMSCommand(rtnList[1])
# 0: Pass, action carried out and SMS sent back
# -1: Exception
# -2: Pass, Unrecognized change command or AT command received though
# -3: Unrecognized SMS
# -4: Error sending an SMS to the originating P/N
if rtnList[0] == -1:
return
rtnList = NETWORK.isRegistered(10) # Check Registration on the fly
if (rtnList[0] == -1) or (rtnList[0] == -2):
RegCheck = 0
mySER.sendUART("\r\nRegistration not available, checking status.\r\n")
# What is the signal strength?
rtnList = ATC.sendAtCmd("AT+CSQ", ATC.properties.CMD_TERMINATOR, 0, 5)
mySER.sendUART("Signal Strength (AT+CSQ): " + rtnList[1] + "\r\n")
# Still registered?
rtnList = ATC.sendAtCmd("AT+CREG?", ATC.properties.CMD_TERMINATOR, 0, 5)
mySER.sendUART("Registration Check (AT+CREG?): " + rtnList[1] + "\r\n")
break
except UserWarning:
print "Controlled Script exit"
except:
print sys.exc_info()
rtnList[0] = -1
return