本文整理汇总了Python中SER.read方法的典型用法代码示例。如果您正苦于以下问题:Python SER.read方法的具体用法?Python SER.read怎么用?Python SER.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SER
的用法示例。
在下文中一共展示了SER.read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readUART
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
def readUART():
# This function receives data from the DTE
try:
rtnList = [-1,-1] #[return status,return data]
# return status:
# -2: Timeout
# -1: Exception occurred
# 0: No errors occurred, no return data
# 1: No errors occurred, return data
rtnList[1] = ''
rtnList[1] = mySER.read()
if (rtnList[1] == -1):
return rtnList
rtnList[0] = 1
except:
print sys.exc_info()
rtnList[0] = -1
return rtnList
示例2: ProcessSBMCommand
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [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
示例3: readUART
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
def readUART():
# This function receives data from the DTE
try:
res = ''
res = SER.read()
except:
printException("readUART()")
return(res)
示例4: receive
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
def receive(self, size):
data = ''
while(1):
rcv = SER.read()
if(len(rcv) > 0):
self.buffer = self.buffer + rcv
if(len(self.buffer) > size):
break
else:
break
if(len(self.buffer) > 0):
data = self.getBuffer(size)
self.debug.send('Data received from serial port: ' + str(len(data)) + ' bytes')
return data
示例5: GetLineaDesdeSerial
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
def GetLineaDesdeSerial(timeout_seg):
global debug
data=""
nueva_data=""
nueva_linea=0
timeout=MOD.secCounter()+timeout_seg
if (debug==1):
SER.send("\r\nin Esperando linea desde serial")
while ((nueva_linea==0) and (MOD.secCounter())):
nueva_data = SER.read()
data=data+str(nueva_data)
if ((data.find('\n')!=-1) or (data.find('\r')!=-1)):
data=data.replace('\n'," ")
data=data.replace('\r'," ")
nueva_linea=1
if (debug==1):
SER.send("\r\nin Nueva linea obtenida")
return data
return data
示例6: acceptCommandInput
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
def acceptCommandInput ( ):
received = SER.read()
SER.send("Read: %s\n" % received)
if received.find('QUIT') == 0:
return 1
elif received.find('LOG') == 0:
Module.CPUclock(3)
generateLog()
Module.CPUclock(0)
elif received.find('CONFIG') == 0:
updateSettings(received[7:])
elif received.find('STATE') == 0:
SER.send("\nsessionStart: %s\nactiveSector: %s\nreadSector: %s\n\n" % (Storage.sessionStart, Storage.activeSector, Storage.readSector))
elif received.find('READ') == 0:
setReadsector(received)
elif received.find('CREAD') == 0:
SER.send("\nCONFIG:%s,%s,%s,\n\n" % (IMEI, Config.Mode, Config.Interval))
return 0
示例7:
# 需要导入模块: import SER [as 别名]
# 或者: from SER import read [as 别名]
import SER
import MOD
SER.set_speed('38400')
MOD.sleep(100)
SER.send('AT+UART=115200,1,0\r\n')
MOD.sleep(10)
SER.send('AT+UART?\r\n')
out = SER.read()
SER.set_speed('115200')
MOD.sleep(100)
SER.send(out)
SER.send('\nEND')