本文整理汇总了Python中SER.send方法的典型用法代码示例。如果您正苦于以下问题:Python SER.send方法的具体用法?Python SER.send怎么用?Python SER.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SER
的用法示例。
在下文中一共展示了SER.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkCon
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def checkCon(pin):
a = SER.send('DEBUG: Now in checkCon...\r\n')
#print '\r\ncheckCon PIN:',pin
res = MDM2.send('AT+CREG?\r',0)
res = MDM2.receive(30)
b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
c = SER.send(res);
if ( (res.find('0,1') > -1) or (res.find('0,5') > -1 ) ):
return 1
ret = ''
ret = setPin(pin)
if ( ret != 1 ):
GPIO.setIOdir(19,1,1)
return -1
timer = MOD.secCounter() + 120
while ( (res.find('0,1') == -1) and (res.find('0,5') == -1 ) ):
res = MDM2.send('AT+CREG?\r',0)
res = MDM2.receive(20)
b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
c = SER.send(res);
if ( MOD.secCounter() > timer ):
return -1
MOD.sleep(50)
MOD.sleep(20)
return 1
示例2: sendData
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def sendData(PIN,PO,HO,A,GU,GP,data,ll):
b = SER.send('\r\nIn sendData...sending\r\n' + data + '\r\n')
b = SER.send('\r\nHO=\r\n')
b = SER.send(HO)
b = SER.send('\r\npO=\r\n')
b = SER.send(PO)
b = SER.send('\r\n')
a = openGPRS(PIN,A,GU,GP)
a = openSD(HO)
res = MDM2.send('POST /' + PO + ' HTTP/1.1 Connection: close\r\n', 0)
res = MDM2.send('HOST: ' + HO + '\r\n', 0)
res = MDM2.send('User-Agent: Terminal Connect\r\n', 0)
res = MDM2.send('Content-Type: application/x-www-form-urlencoded\r\n', 0)
res = MDM2.send('Content-Length: '+ str(ll) +'\r\n\r\n', 0)
res = MDM2.send(data, 0)
res = MDM2.send('\r\n\r\n', 0)
cnt = 20
res = MDM2.receive(20)
a = SER.send('\r\nResponse from server ------------------------\r\n')
while ( (res.find('EOT') == -1) and (cnt > 0) ):
a = SER.send(res)
res = MDM2.receive(20)
cnt = cnt - 1
a = SER.send(res)
res = closeCon()
a = SER.send('\r\nend -----------------------------------------\r\n')
return res
示例3: ProcessSBMCommand
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def ProcessSBMCommand():
while(1):
PrintDebug("SBS Command Process")
#PrintDebug("Waiting for command")
# COMMAND_START = 0
# COMMAND_END = 1
#if(len(GlobalVaria.UartData) > DATA_LEN):
#PrintDebug("Data is more than the defined limit")
#PrintDebug("Wiating on seriel port")
GlobalVaria.UartData = GlobalVaria.UartData + SER.read()
PrintDebug(GlobalVaria.UartData)
startIndex = GlobalVaria.UartData.find('\x02')
endIndex = GlobalVaria.UartData.find('\x03')
PrintDebug("Start Index:" + str(startIndex))
PrintDebug("end Index:" + str(endIndex))
if(startIndex != -1 and endIndex!= -1):
GlobalVaria.SBMBuffer = GlobalVaria.UartData[startIndex:endIndex+1]
PrintDebug("Command: " + GlobalVaria.SBMBuffer)
SER.send('\x02')
FindSbmCmnd(GlobalVaria.SBMBuffer[1])
GlobalVaria.UartData = GlobalVaria.UartData[endIndex+1:]
PrintDebug("Remaining:" + GlobalVaria.UartData)
else:
SER.send('\0x03')
break
示例4: WriteUploadDataToFile
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def WriteUploadDataToFile():
PrintDebug("Writting Data to File")
InfileHandler = -1
GlobalVaria.sbmInFileLength1 = 0
GlobalVaria.SBMBuffer = GlobalVaria.SBMBuffer[2:-1]
GlobalVaria.SBMBuffer = GlobalVaria.SBMBuffer + '\0'
GlobalVaria.sbmInFileLength1 = FileSize(GlobalVaria.SBM_DATA_INFILE1)
if(GlobalVaria.sbmInFileLength1 > 49000):
if((FileCheck(GlobalVaria.SBM_DATA_INFILE2)== -1) and (FileCheck(GlobalVaria.SBM_DATA_OUTFILE)== 1)):
rename(GlobalVaria.SBM_DATA_INFILE1,GlobalVaria.SBM_DATA_INFILE2)
GlobalVaria.sbmInFileLength1 = 0
GlobalVaria.sbmInFileLength2 = FileSize(GlobalVaria.SBM_DATA_INFILE2)
else:
GlobalVaria.InFileLenExceededflag = '1';
SER.send('\0x02')
return
try:
InfileHandler = open(GlobalVaria.SBM_DATA_INFILE1,'a')
except IOError:
SER.send('\x03')
return 0
InfileHandler.write(GlobalVaria.SBMBuffer)
writeedlen = len(GlobalVaria.SBMBuffer)
GlobalVaria.sbmInFileLength1 = FileSize(GlobalVaria.SBM_DATA_INFILE1)
GlobalVaria.sbmInFileLength2 = 0
InfileHandler.close()
InfileHandler = -1
PrintDebug("Writting Complated")
示例5: calendarProcessing
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def calendarProcessing():
global CALENDAR
if(CALENDAR > (int(CFG.get('ALIVESMS')) - 1)):
calendar.writeCalendar(0)
CALENDAR = 0
SER.send('Send heartbeat SMS\r')
sendAlert('Device is alive.')
示例6: transmitMessage
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def transmitMessage ( message ):
# If the socket is not open, we'll dial.
if Module.socketIsSuspended() == 0:
SER.send('Dail socket, state is: %s\n' % Module.ATcommand('AT#SS=1'))
if Module.socketDail( Config.API ) == 0:
SER.send('Failed to open a socket\n')
return 0
elif Module.socketResume() == 0:
SER.send('Failed socket resume\n')
response = Module.makeRequest(URL, ('[%s]' % message))
if ( response == 0 ):
SER.send('Request failed\n')
else:
updateSettings(response)
if ( Module.sendEscapeSequence() == 0 ):
SER.send('Failed to escape, not in command mode\n')
return 0
示例7: send
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def send(self, msg):
message = str(MOD.secCounter()) + ' # ' + msg + '\r\n'
max_len = int(self.config.get('TCP_MAX_LENGTH'))
print message
if (self.config.get('DEBUG_SER') == '1'):
SER.send(message)
if (self.config.get('DEBUG_TCP') == '1'):
if((len(self.tcpLogBuffer) + len(message)) < max_len):
self.tcpLogBuffer = self.tcpLogBuffer + message
示例8: log
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def log(m):
t = util.timestamp()
d = '%s: %s\r' % (t, m)
SER.send(d)
try:
f = open( log_file, 'a' )
f.write(d)
f.close()
except:
return
示例9: ringProcessing
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def ringProcessing():
ring = gsm.checkRing()
if(ring != ''):
SER.send('Ringing with number: %s\r' % (ring))
if(ring in CFG.getList('WHITE')):
executeCommand(command.Command('OUT1', '1'))
else:
SER.send('Phone is not in Whitelist\r')
# MOD.sleep(40)
gsm.hangUp()
示例10: iterateHTTPCmd
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def iterateHTTPCmd(comando, parametro, TIMEOUT_CMD, numCheck):
while( numCheck >= 0):
numCheck = numCheck - 1
res = Helper.sendCmd(comando, parametro, TIMEOUT_CMD)
SER.send(res + ' ' + comando + '=' + parametro)
if(res.find('CONNECT') != -1) :
return 1
MOD.sleep(TIMEOUT_CMD)
if(numCheck == 0):
SER.send(res + ' ' + comando + '=' + parametro)
return -1
示例11: enviarAT
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def enviarAT(comando,timeout,respuesta_esp):
comando_aux=comando
comando_aux=comando_aux.replace('\n',"(N)")
comando_aux=comando_aux.replace('\r',"(R)")
global debug
if (debug==1):
SER.send("\r\nout:"+comando_aux)
res_envio=MDM.send(comando,20)
res_envio=MDM.send('\r\n',20)
respuesta=RecibirDesdeModem(timeout,respuesta_esp)
return respuesta
示例12: lastIndexOf
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def lastIndexOf(data,text) :
Temp = data.find(text)
SER.send(str(Temp)+'\r\n')
while Temp != -1 :
Index = Temp
Temp = data.find(text,Temp + len(text))
SER.send('Index = '+str(Index)+', Temp = '+str(Temp)+'\r\n')
return Index
示例13: init
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def init():
try:
# Init the module configuration
command.send_at_command("AT#SELINT=2")
# Set the command mode
command.send_at_command("AT&K0")
# Configure GPS speed
# command.send_at_command("AT$GPSS=57600")
except Exception, err:
SER.send("Erro ao iniciar o modulo: %s\n"%err)
示例14: initNetworkRelated
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def initNetworkRelated ( ):
# Unlock SIM card by entering PIN;
Module.unlockSIM()
SER.send('Done unlockSIM\n')
if ( Module.attachNetwork( 20 ) == 0 ):
SER.send('Failed attachNetwork\n')
SER.send('Done attachNetwork\n')
if ( Module.connectNetwork( Config.APN ) == 0 ):
SER.send('Failed connectNetwork\n')
SER.send('Done connectNetwork\n')
示例15: rebootCounterProcessing
# 需要导入模块: import SER [as 别名]
# 或者: from SER import send [as 别名]
def rebootCounterProcessing(delta):
global REBOOT_COUNTER
global CALENDAR
if((delta < 0) or (delta > 100)):
delta = 5
REBOOT_COUNTER = REBOOT_COUNTER + delta
SER.send('Current reboot counter: %d\r' % REBOOT_COUNTER)
if(REBOOT_COUNTER > int(CFG.get('REBOOTPERIOD'))):
SER.send('Terminal reboot.\r')
if(int(CFG.get('ALIVESMS')) > 0):
CALENDAR = CALENDAR + 1
calendar.writeCalendar(CALENDAR)
MOD.sleep(30)
gsm.reboot()