本文整理汇总了Python中MOD.watchdogReset方法的典型用法代码示例。如果您正苦于以下问题:Python MOD.watchdogReset方法的具体用法?Python MOD.watchdogReset怎么用?Python MOD.watchdogReset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOD
的用法示例。
在下文中一共展示了MOD.watchdogReset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isGprsAttached
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def isGprsAttached(timeOut):
# This function waits until the GPRS attaches
exitLoop = -1
try:
#Start timeout counter
timerA = timers.timer(0)
timerA.start(timeOut)
#Wait until registered to GSM Network
while (exitLoop == -1):
MOD.watchdogReset()
res = ATC.sendAtCmd('AT+CGREG?',ATC.properties.CMD_TERMINATOR,0,5)
if (res[res.rfind(',')+1:len(res)] == '5' or res[res.rfind(',')+1:len(res)] == '1'):
exitLoop = 0
break
if timerA.isexpired():
break #Exit while
except:
printException("isGprsAttached()")
return exitLoop
示例2: mdmResponse
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def mdmResponse(theTerminator, timeOut):
# This function waits for AT Command response and handles errors and ignores unsolicited responses
# Input Parameter Definitions
# theTerminator: string or character at the end of a received string that indicates end of a response
# timeOut: number of seconds command could take to respond
try:
print 'Waiting for AT Command Response'
#Start timeout counter
timerA = timers.timer(0)
timerA.start(timeOut)
#Wait for response
res = ''
while ((res.find(theTerminator)<=-1) and (res.find("ERROR")<=-1) and (res != 'timeOut')):
MOD.watchdogReset()
res = res + MDM.receive(10)
pass
if timerA.isexpired():
res = 'timeOut'
except:
printException("mdmResponse()")
return res
示例3: exitSocketDataMode
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def exitSocketDataMode():
try:
#Exit data mode
delaySec(11) ##this time is based on esc sequence guard time
#Start timeout counter
timerA = timers.timer(0)
timerA.start(20)
#Sending +++
print 'Sending Data Mode escape sequence'
res = MDM.send('+++', 10)
#Wait for response
res = ''
while ((res.find("OK")<=-1) and (res != 'timeOut')):
MOD.watchdogReset()
res = res + MDM.receive(50)
pass
if timerA.isexpired():
res = 'timeOut'
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> ATC'
print 'METHOD -> exitSocketDataMode()'
print res
return res
示例4: mdmResponse
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def mdmResponse(theTerminator, timeOut):
# This function waits for AT Command response and handles errors and ignores unsolicited responses
# Input Parameter Definitions
# theTerminator: string or character at the end of a received string which indicates end of a response
# timeOut: number of seconds command could take to respond
try:
print 'Waiting for AT Command Response'
#Start timeout counter
timerA = timers.timer(0)
timerA.start(timeOut)
#Wait for response
res = ''
while ((res.find(theTerminator)<=-1) and (res.find("ERROR")<=-1) and (res != 'timeOut')):
MOD.watchdogReset()
res = res + MDM.receive(10)
pass
if timerA.isexpired():
res = 'timeOut'
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> ATC'
print 'METHOD -> mdmResponse(' + theTerminator + ',' + timeOut + ')'
return res
示例5: loop
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def loop(gps_log_file):
gps_data = get_formated_gps_data()
if gps_log_file != None and gps_data != None and gps_data != "":
if get_speed(gps_data) > SPEED_LOWER_LIMIT: # write only if speed is greater than 10 km/h
gps_log_file.write("%s\n"%gps_data)
gps_log_file.flush()
MOD.watchdogReset()
else:
# close the log file
gps_log_file.flush()
gps_log_file.close()
示例6: delaySec
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def delaySec(seconds):
try:
if(seconds<=0): return
timerA = timers.timer(0)
timerA.start(seconds)
while 1:
MOD.watchdogReset()
if timerA.isexpired():
break
except:
printException("delaySec()")
return
示例7: tryCSD
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def tryCSD(self):
ring = MDM2.getRI()
if(ring == 1):
at_timeout = int(self.config.get('TIMEOUT_AT'))
a, s = self.sendAT('ATA\r', 'CONNECT', 1, 10, 0)
if(a == 0):
self.debug.send('CSD CONNECTED')
while(ring == 1):
rcv = self.serial.receive(int(self.config.get('TCP_MAX_LENGTH')))
if(len(rcv) > 0):
self.sendMDM2(rcv)
rcv = self.receiveMDM2()
if(len(rcv) > 0):
self.serial.send(rcv)
ring = MDM2.getRI()
MOD.watchdogReset()
self.debug.send('CSD DISCONNECTED')
else:
self.debug.send('CSD CONNECT ERROR')
示例8: exitDataMode
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def exitDataMode():
try:
#Exit data mode
##Lookup the Escape Sequence Guard Time
## Future Use
# Delay to meet Escape Sequence Guard Time
## Remove Hard Coded Escape Sequence Guard Time
delaySec(1)
#Start timeout counter
timerA = timers.timer(0)
timerA.start(20)
##Lookup the Escape Sequence
## Future Use
#Sending +++
## Remove Hard Coded Escape Sequence
res = MDM.send('+++', 10)
#Wait for response
res = ''
while ((res.find("OK")<=-1) and (res != 'timeOut')):
MOD.watchdogReset()
res = res + MDM.receive(50)
pass
if timerA.isexpired():
res = 'timeOut'
except:
printException("exitDataMode()")
print res
return res
示例9: delaySec
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def delaySec(seconds):
try:
if(seconds<=0): return
timerA = timers.timer(0)
timerA.start(seconds)
while 1:
MOD.watchdogReset()
if timerA.isexpired():
break
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> ATC'
print 'METHOD -> delaySec(' + seconds + ')'
return
示例10: getNetworkTime
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def getNetworkTime(timeOut):
# This function forces the Network to update RTC with GSM Network Time
tmpReturn = -1
try:
res = ATC.sendAtCmd("AT#NITZ=1",ATC.properties.CMD_TERMINATOR,0,2) #set NITZ command to update Network Time
res = ATC.sendAtCmd("AT+COPS=2",ATC.properties.CMD_TERMINATOR,0,2) #set COPS command to force GSM Registration to disconnect
#Start timeout counter
timerA = timers.timer(0)
timerA.start(timeOut)
#Wait until GSM module is not registered to Network
while (1):
MOD.watchdogReset()
res = ATC.sendAtCmd('AT+CREG?',ATC.properties.CMD_TERMINATOR,0,5)
if (res == "+CREG: 0,0"):
break
if timerA.isexpired():
return tmpReturn
res = ATC.sendAtCmd("AT+COPS=0",ATC.properties.CMD_TERMINATOR,0,2) #set COPS command to force GSM Registration
res = isGsmRegistered(timeOut)
if (res == 0):
tmpReturn = 0
res = ATC.sendAtCmd("AT+CCLK?",ATC.properties.CMD_TERMINATOR,0,2) #Query RTC Clock
except:
printException("getNetworkTime")
return tmpReturn
示例11: main
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def main():
try:
# Set Global Watchdog timeout in Seconds
MOD.watchdogEnable(300)
#######################################
## Initialization
#######################################
rtnList = [-1,-1] #[return status,return data]
# return status:
# -1: Exception occurred
# 0: No errors occurred, no return data
# 1: No errors occurred, return data
# 2: Error occurred
#Initialize the serial interface @ 115200, we must do this or nothing comes out the serial port
rtnList = mySER.init("115200",'8N1')
if (rtnList[0] == -1):
return
mySER.sendUART("Beginning the serial bridge program. \r\n\r\n")
# Set Global Watchdog timeout in Seconds
#MOD.watchdogEnable(300)
#Get configuration from demo.conf file, transpose into new local myApp class
myApp = conf.conf('/sys','demo.conf')
if myApp.CONF_STATUS != 0:
mySER.sendUART("Demo configuration error: " + str(myApp.CONF_STATUS))
return rtnList
mySER.sendUART("Configuration Loaded.\r\n")
rtnList = myIO.init()
if (rtnList[0] == -1) or (rtnList[0] == -2) or rtnList[1] == "ERROR": raise UserWarning
mySER.sendUART("\r\nInitializing Network Setup. \r\n")
#Set Network specific settings, wait for SIM card to be ready
rtnList = NETWORK.initNetwork(myApp.ENS)
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
#Initialize SOCKET communications
rtnList = SOCKET.init('1',myApp.APN)
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
mySER.sendUART("Network Setup Initialized. \r\n\r\n")
#Update Unit information
rtnList = ATC.getUnitInfo()
if (rtnList[0] == -1): 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()
#######################################
## Registration
#######################################
RegCheck = 0 #Initialize check
DataCheck = 0 #Initialize Check
#What is the signal strength?
rtnList = ATC.sendAtCmd('AT+CSQ',ATC.properties.CMD_TERMINATOR,5)
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
mySER.sendUART("Signal Strength (AT+CSQ): " + rtnList[1] + "\r\n")
#Wait until module is registered to GSM Network
mySER.sendUART("Checking Modem Registration. \r\n")
rtnList = NETWORK.isRegistered(180) #Wait 180 seconds for module to obtain GSM registration
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
if (rtnList[0] == 0): #Registered successfully
RegCheck = 1
mySER.sendUART("Modem Registered. \r\n\r\n")
#Wait until module is ready for data
mySER.sendUART("Checking Data Availability. \r\n")
rtnList = NETWORK.isDataAttached(myApp.CGMM, 180) #Wait 180 seconds for module to obtain GSM registration
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
if (rtnList[0] == 0): #Registered successfully
DataCheck = 1
mySER.sendUART("Modem ready for data. \r\n\r\n")
#check for exit prompt, let's use command EXITSCR
rtnList = mySER.readUART()
if (rtnList[1].find('EXITSCR') != -1):
print '\r\nExit Command Found\r\n'
return
#######################################
## Socket Connection
#.........这里部分代码省略.........
示例12: EONS
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
res = ATC.sendAtCmd('AT#AUTOBND=1',ATC.properties.CMD_TERMINATOR,3,2) #enable Quad band system selection
res = ATC.sendAtCmd('AT#PLMNMODE=1',ATC.properties.CMD_TERMINATOR,3,2) #enable EONS (enhanced operator naming scheme)
DEBUG.sendMsg("Connecting to network",RUN_MODE)
#Wait until registered to GSM Network
exitLoop = 1
while (exitLoop == 1):
res = ATC.sendAtCmd('AT+CREG?',ATC.properties.CMD_TERMINATOR,0,5)
DEBUG.sendMsg(".",RUN_MODE)
if (res[res.rfind(',')+1:len(res)] == '5' or res[res.rfind(',')+1:len(res)] == '1'):
exitLoop = 0
DEBUG.sendMsg("\r\nConnected to network\r\n",RUN_MODE)
MOD.watchdogReset()
#Setup SMS
ATC.configSMS()
#Send SMS
#Uncomment if SIM card is provisioned for SMS
#ATC.sendSMS("GPSDemo application is running",myApp.SMS,ATC.properties.CMD_TERMINATOR,3,180)
#Init GPRS
#Pass in: PDP Index, APN
ATC.initGPRS('1', myApp.APN, myApp.GPRS_USERID, myApp.GPRS_PASSWORD, RUN_MODE)
#Initalize CW20 Receiver
DEBUG.sendMsg("Initialize CW20 GPS Module\r\n",RUN_MODE)
CW20.initGPS('9600','8N1')
示例13: main
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def main():
try:
timerA = timers.timer(0)
timerA.start(1)
# Set Global Watchdog timeout in Seconds
MOD.watchdogEnable(300)
#Increase CPU speed at cost of increased current consumption
ATC.sendAtCmd('AT#CPUMODE=1',ATC.properties.CMD_TERMINATOR,0,5)
#Turn off GSM TX/RX
ATC.sendAtCmd('AT+CFUN=4',ATC.properties.CMD_TERMINATOR,0,5)
#Initialize MS20 Receiver
res = MS20.initGPS('9600','8N1')
if not(res == 0):
if (res == -1):
DEBUG_CF.sendMsg("MS20 Exception occurred\r\n",myApp.RUN_MODE)
elif (res == -3):
DEBUG_CF.sendMsg("NMEA Command response Checksum fail\r\n",myApp.RUN_MODE)
elif (res == -4):
DEBUG_CF.sendMsg("No NMEA Command response\r\n",myApp.RUN_MODE)
DEBUG_CF.sendMsg("Is NAVSYNC serial port connected to TRACE port via NULL MODEM cable?\r\n",myApp.RUN_MODE)
DEBUG_CF.sendMsg("For CF_EVAL_PCB001 V3.1 evaluation boards or newer => SW1, MODE1 = ON\r\n",myApp.RUN_MODE)
DEBUG_CF.sendMsg("See GSM865CF Plug-in Terminal GPS Demonstration User Guide for more info\r\n",myApp.RUN_MODE)
elif (res == -5):
DEBUG_CF.sendMsg("Incorrect NMEA command response\r\n",myApp.RUN_MODE)
elif (res > 0):
DEBUG_CF.sendMsg("MS20 Error Number: " + str(res) + "\r\n",myApp.RUN_MODE)
else:
DEBUG_CF.sendMsg("Unknown error\r\n",myApp.RUN_MODE)
MOD.sleep(40)
return
DEBUG_CF.sendMsg("MS20 Initialization Complete\r\n",myApp.RUN_MODE)
DEBUG_CF.sendMsg("GPS Application Version: " + MS20.GPSdata.APP_VER + "\r\n",myApp.RUN_MODE)
# Wait for GPS module to obtain position data
DEBUG_CF.sendMsg("Waiting for valid position",myApp.RUN_MODE)
#Poll NMEA GPGLL Sentence
if (MS20.pollNMEA('2',5) == 0): exitLoop = MS20.GPSdata.GPGLL.split(',')[6]
while(exitLoop != 'A'):
MOD.watchdogReset()
#Poll NMEA GPGLL Sentence
if (MS20.pollNMEA('2',5) == 0): exitLoop = MS20.GPSdata.GPGLL.split(',')[6]
DEBUG_CF.sendMsg(".",myApp.RUN_MODE)
DEBUG_CF.sendMsg("\r\nPosition acquired: " +str(timerA.count()) + " Seconds (Referenced to script start time)\r\n",myApp.RUN_MODE)
#Increase CPU speed during TX/RX only
ATC.sendAtCmd('AT#CPUMODE=2',ATC.properties.CMD_TERMINATOR,0,5)
#Activate Low Power mode, Turn off GSM TX/RX
ATC.sendAtCmd('AT+CFUN=5',ATC.properties.CMD_TERMINATOR,0,5)
#Set Network specific settings
res = NETWORK.initGsmNetwork(myApp.NETWORK,myApp.BAND)
if (res == -1):
return
DEBUG_CF.sendMsg("Network Initialization Complete\r\n",myApp.RUN_MODE)
#Wait for GSM Registration
DEBUG_CF.sendMsg("Waiting for GSM Registration",myApp.RUN_MODE)
#Check GSM registration
exitLoop = NETWORK.isGsmRegistered(1)
while(exitLoop != 0):
MOD.watchdogReset()
#Check GSM registration
exitLoop = NETWORK.isGsmRegistered(1)
DEBUG_CF.sendMsg(".",myApp.RUN_MODE)
DEBUG_CF.sendMsg("\r\nTerminal is registered to a GSM network\r\n",myApp.RUN_MODE)
#Init GPRS
GPRS.init('1',myApp.APN)
DEBUG_CF.sendMsg("GPRS Initialization Complete\r\n",myApp.RUN_MODE)
#Wait for GPRS attach
DEBUG_CF.sendMsg("Waiting for GPRS Attach",myApp.RUN_MODE)
#Check GPRS Attach
exitLoop = NETWORK.isGprsAttached(1)
while(exitLoop != 0):
MOD.watchdogReset()
#Check GPRS Attach
exitLoop = NETWORK.isGprsAttached(1)
DEBUG_CF.sendMsg(".",myApp.RUN_MODE)
DEBUG_CF.sendMsg("\r\nTerminal is attached to GPRS service\r\n",myApp.RUN_MODE)
#Record IMEI number
myApp.IMEI = ATC.sendAtCmd('AT+CGSN',ATC.properties.CMD_TERMINATOR,0,5)
DEBUG_CF.sendMsg("IMEI #: " + myApp.IMEI + "\r\n",myApp.RUN_MODE)
# Start timeout timer
timerB = timers.timer(0)
#.........这里部分代码省略.........
示例14: main
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def main():
try:
# Set Global Watchdog timeout in Seconds
MOD.watchdogEnable(300)
res = JANUS_SER.init("115200",'8N1')
if (res == -1):
return
#Set Network specific settings
res = NETWORK.initGsmNetwork(myApp.NETWORK,myApp.BAND)
if (res == -1):
return
#Init GPRS
GPRS.init('1',myApp.APN)
#Inform Application that a Data Connection is not available
JANUS_SER.set_DCD(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):
MOD.watchdogReset()
#Wait until module is registered to GSM Network
res = NETWORK.isGsmRegistered(180) #Wait 180 seconds for module to obtain GSM registration
if (res == -1):
return
#Wait until module is attached to GPRS
res = NETWORK.isGprsAttached(180) #Wait 180 seconds for module to obtain GPRS Attachment
if (res == -1):
return
#############################################################################################################################
## Opening Socket Connection to Server
#############################################################################################################################
res = GPRS.openSocket(myApp.IP,myApp.PORT,1,myApp.USERNAME,myApp.PASSWORD,myApp.PROTOCOL,0)
#Inform Application that a Data Connection is not available
DCD = MDM.getDCD()
if (DCD == 1):
JANUS_SER.set_DCD(1)
#Forward CONNECT Message to Serial Port
JANUS_SER.sendUART('\r\nCONNECT\r\n')
##Loop while Socket connected
while(1):
MOD.watchdogReset()
#Forward serial port data to socket connection
DCD = MDM.getDCD()
if (DCD == 1):
#Get data from serial port
res = JANUS_SER.readUART()
if (len(res)!=0):
#Forward data to open socket
res = MDM.send(res,1)
#Forward socket data to serial port
DCD = MDM.getDCD()
if (DCD == 1):
#Get data from open socket connection
res = MDM.receive(1)
if (len(res)!=0):
#Forward socket data to serial port
JANUS_SER.sendUART(res)
#When socket is closed exit loop via this path
#Will guarantee that '\r\nNO CARRIER\r\n' is sent every time
DCD = MDM.getDCD()
if (DCD == 0):
#Inform Application that a Data Connection is not available
JANUS_SER.set_DCD(0)
ATC.delaySec(1)
#Get any remaining data from closed socket connection
res = MDM.receive(1)
if (len(res)!=0):
#Forward socket data to serial port
JANUS_SER.sendUART(res)
break
except:
print "Script encountered an exception"
print "Exception Type: " + str(sys.exc_type)
print "MODULE -> TerminusS2E"
return
示例15: sendEMAIL
# 需要导入模块: import MOD [as 别名]
# 或者: from MOD import watchdogReset [as 别名]
def sendEMAIL(theEmailToAddress,theEmailSubject,theEmailBody,theTerminator,userID,userPassword,retry,timeOut):
#This function sends email
# Input Parameter Definitions
# theEmailSubject: The text Email Subject
# theEmailBody: The text Email Body
# theTerminator: string or character at the end of AT Command
# retry: How many times the command will attempt to retry if not successfully send
# timeOut: number of [1/10 seconds] command could take to respond
try:
tmpReturn = -1
while (retry != -1):
#Activate PDP if needed
res = sendAtCmd('AT#SGACT?',properties.CMD_TERMINATOR,0,20)
if (res!="#SGACT: 1,1"):
delaySec(1)
res = sendAtCmd('AT#SGACT=1,1,"' + str(userID) + '","' + str(userPassword) + '"' ,properties.CMD_TERMINATOR,0,180)
DEBUG.sendMsg(res + '\r\n',RUN_MODE)
if (res=='ERROR'):
return tmpReturn
print 'AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0'
res = MDM.send('AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0', 0)
res = MDM.sendbyte(0x0d, 0)
res = mdmResponse('\r\n>', timeOut)
print res
res = MDM.send(theEmailBody, 0)
res = MDM.sendbyte(0x1a, 0)
#Start timeout counter
timerA = timers.timer(0)
timerA.start(timeOut)
#Wait for response
res = ''
while ((res.find(theTerminator)<=-1) and (res.find("ERROR")<=-1) and (res != 'timeOut')):
MOD.watchdogReset()
res = res + MDM.receive(10)
pass
if timerA.isexpired():
res = 'timeOut'
if((res.find("ERROR") > -1) or (res == 'timeOut')):
retry = retry - 1
else:
retry = -1
tmpReturn = 0
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> ATC'
print 'METHOD -> sendEMAIL(' + theEmailToAddress + ',' + theEmailSubject + ',' + theEmailBody + ',' +theTerminator + ',' + retry + ',' + timeOut + ')'
print res
return tmpReturn