本文整理汇总了Python中MOD类的典型用法代码示例。如果您正苦于以下问题:Python MOD类的具体用法?Python MOD怎么用?Python MOD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MOD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetData
def GetData(TIMEOUT_DWNLD):
SER.send('Ready to wait for response\r')
timeout = MOD.secCounter() + TIMEOUT_DWNLD
timer = timeout - MOD.secCounter()
HTML_UC_END = '</RESPONSE>'
HTML_LC_END = '</response>'
data = ''
mesg = ''
while ((data.find('NO CARRIER') == -1) and (timer >0) ):
SER.send('...Downloading\r')
datatmp = MDM.receive(5)
data = data + datatmp
timer = timeout - MOD.secCounter()
wd.feed()
if(data.find('HTTP/1.1 200') == -1):
mesg = 'Update server ERROR: ' + data[0:12]
SER.send(mesg)
SER.send('\r')
SER.send(data)
SER.send('\r')
data = -1
else:
mesg = 'Update server SUCCEFULL: ' + data[0:12]
SER.send(mesg)
SER.send('\r')
Log.appendLog(mesg)
return data
示例2: mdmResponse
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: mdmResponse
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
示例4: sendATData
def sendATData(self, atcom, atres, trys = 1, timeout = 1, csd = 1):
mdm_timeout = int(self.config.get('TIMEOUT_MDM'))
s = MDM.receive(mdm_timeout)
result = -2
while(1):
if(csd):
self.tryCSD()
if(self.config.get('DEBUG_AT') == '1'):
self.debug.send('DATA AT OUT: ' + atcom)
s = ''
MDM.send(atcom, mdm_timeout)
timer = MOD.secCounter() + timeout
while(1):
s = s + MDM.receive(mdm_timeout)
if(s.find(atres) != -1):
result = 0
break
if(s.find('ERROR') != -1):
result = -1
break
if(MOD.secCounter() > timer):
break
if(self.config.get('DEBUG_AT') == '1'):
self.debug.send('DATA AT IN: ' + s[2:])
trys = trys - 1
if((trys <= 0) or (result == 0)):
break
MOD.sleep(15)
return (result, s)
示例5: configSMS
def configSMS():
try:
#Enable TEXT format for SMS Message
res = sendAtCmd('AT+CMGF=1' ,properties.CMD_TERMINATOR,0,5)
res = sendAtCmd('AT+CNMI=2,1' ,properties.CMD_TERMINATOR,0,5)
#SIM status control - to avoid the 'sim busy' error
print 'SIM Verification Cycle'
SIM_status = sendAtCmd('AT+CPBS?' ,properties.CMD_TERMINATOR,0,5)
if SIM_status.find("+CPBS")<0:
print 'SIM busy! Please wait!\n'
while SIM_status.find("+CPBS:")< 0 :
SIM_status = sendAtCmd('AT+CPBS?' ,properties.CMD_TERMINATOR,0,5)
MOD.sleep(2)
print 'SIM Ready'
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> ATC'
print 'METHOD -> configSMS()'
return
示例6: exitSocketDataMode
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
示例7: waitRegister
def waitRegister():
while(1):
RX_API.resetWDT()
r, d = sendAT('AT+CREG?', '+CREG: 0,1')
if(r == 0):
break
MOD.sleep(20)
示例8: receiveReponse
def receiveReponse ( ):
timeout = MOD.secCounter() + 10
str = ""
length = ""
newlinepos = 0
while ( MOD.secCounter() < timeout ):
newlinepos = str.find("\n\r")
if ( (newlinepos != -1) and not length ):
newlinepos = newlinepos + 2
pos = str.find("Content-Length:") + 15
while ( str[pos] != '\n' ):
length = "%s%s" % (length, str[pos])
pos = pos + 1
length = int(length) + newlinepos
else:
MOD.sleep(5)
str = str + MDM.receive(1)
if ( length and len(str) >= length ):
return str[newlinepos:(newlinepos+length)]
return 0
示例9: wait4SIMReady
def wait4SIMReady():
#SIM status control - to avoid the 'sim busy' error
# The following sequence loops forever until SIM card is ready for use
try:
res = ATC.sendAtCmd("AT#SIMDET?",ATC.properties.CMD_TERMINATOR,0,2) #query Sim detection style
if (res.find("#SIMDET: 2")< 0):
res = ATC.sendAtCmd('AT#SIMDET=2',ATC.properties.CMD_TERMINATOR,0,2) #Ensure detection is automatic via SIMIN and not forced
res = ATC.sendAtCmd('AT&P0',ATC.properties.CMD_TERMINATOR,0,2) #Save Profile
res = ATC.sendAtCmd('AT&W0',ATC.properties.CMD_TERMINATOR,0,2) #Save Settings
print 'SIM Verification Cycle'
SIM_status = ATC.sendAtCmd('AT+CPBS?' ,ATC.properties.CMD_TERMINATOR,0,5) #We aren't using AT+CPIN? because there are too many possible answers
#This lets us know that the SIM is at least inserted
if SIM_status.find("+CPBS")<0:
print 'SIM busy! Please wait!\n'
while SIM_status.find("+CPBS:")< 0 :
SIM_status = ATC.sendAtCmd('AT+CPBS?' ,ATC.properties.CMD_TERMINATOR,0,5)
MOD.sleep(2)
print 'SIM Ready'
except:
printException("wait4SIMReady()")
return
示例10: isGprsAttached
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
示例11: eraseSector
def eraseSector ( sector_address ):
addr = mbytewrap(sector_address, 0x00)
msg = '\x20%s' % addr
writeEnable()
writ = SPIobj.readwrite(msg)
MOD.sleep(3) # Stay within safeties for sector erase (abs.max 450ms)
return writ
示例12: delAll
def delAll():
res = MDM.send("AT+CMGF=1\r", 0)
res = MDM.receive(3)
res = MDM.send("AT+CNMI=2,1\r", 0)
res = MDM.receive(3)
if res.find("OK") != -1:
print "OK for AT+CNMI=2,1"
else:
print "ERROR for AT+CNMI=2,1"
# SIM status control - to avoid the 'sim busy' error
print "SIM Verification Cycle"
a = MDM.send("AT+CPBS?\r", 0)
SIM_status = MDM.receive(10)
if SIM_status.find("+CPBS") < 0:
print "SIM busy! Please wait!\n"
while SIM_status.find("+CPBS:") < 0:
a = MDM.send("AT+CPBS?\r", 0)
SIM_status = MDM.receive(10)
MOD.sleep(2)
print "SIM Ready"
# receive the list of all sms
MDM.send('AT+CMGL="ALL"\r', 0)
smslist = ""
MemSMS = MDM.receive(20)
smslist = MemSMS
while MemSMS != "":
MemSMS = MDM.receive(20)
smslist = smslist + MemSMS
# listsms = MemSMS.splitlines()
listsms = smslist.split("\n")
listIndex = [] # the list of index to delete
for string in listsms:
if string.find("+CMGL:") != -1: # find the index of each sms
start = string.find(":")
end = string.find(",")
myindex = string[(start + 1) : end]
myindex = myindex.strip()
listIndex.append(myindex)
print string
if listIndex == []:
print "No SMS in SIM"
# delete all sms
for index in listIndex:
print "Deleting sms index: " + index
MDM.send("AT+CMGD=", 0)
MDM.send(index, 0)
MDM.send("\r", 0)
res = MDM.receive(20)
res = res.replace("\r\n", " ")
print res
return 1
示例13: iterateCmd
def iterateCmd(comando, parametro, TIMEOUT_CMD, numCheck):
while( numCheck >= 0):
numCheck = numCheck -1
res = sendCmd(comando, parametro, TIMEOUT_CMD)
if(res.find('OK') != -1):
return 1
MOD.sleep(TIMEOUT_CMD)
if(numCheck == 0):
return -1
示例14: checkNetwork
def checkNetwork():
MOD.sleep(20)
REC_TIME = 200
for _ in range(10):
MDM.send("AT+CREG?\r",0)
res = MDM.receive(REC_TIME)
if (res.find('0,1')!=-1): return 1
else: MOD.sleep(50)
return 0
示例15: reboot
def reboot():
# This method does return a response. After the AT#REBOOT command executes the GSM module will
# reset and the script will restart depending on the #STARTMODESCR settings.
MOD.sleep(15) #required to halt Python thread and allow NVM Flash to update
print "Rebooting Terminus!"
sendAtCmd('AT#REBOOT',properties.CMD_TERMINATOR,0,20)
return