本文整理汇总了Python中SER.setDCD方法的典型用法代码示例。如果您正苦于以下问题:Python SER.setDCD方法的具体用法?Python SER.setDCD怎么用?Python SER.setDCD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SER
的用法示例。
在下文中一共展示了SER.setDCD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import SER [as 别名]
# 或者: from SER import setDCD [as 别名]
#.........这里部分代码省略.........
if (rtnList[1].find('EXITSCR') != -1):
print '\r\nExit Command Found\r\n'
return
rtnList = NETWORK.isRegistered(10) #Fast reg check
if (rtnList[0] == -1) or (rtnList[0] == -2): #unavailable, drill down discretely and show the status
RegCheck = 0
rtnList = ATC.sendAtCmd('AT+CREG?',ATC.properties.CMD_TERMINATOR,5)
mySER.sendUART("Registration Unavailable, Status: " + rtnList[1] + "\r\n")
break #exit loop
rtnList = NETWORK.isDataAttached(myApp.CGMM, 10) #Fast data check
if (rtnList[0] == -1) or (rtnList[0] == -2): #unavailable, drill down discretely and show the status
DataCheck = 0
rtnList = ATC.sendAtCmd('AT+CGREG?',ATC.properties.CMD_TERMINATOR,5)
mySER.sendUART("Data Unavailable, Status: " + rtnList[1] + "\r\n")
break #exit loop
#Open socket in online mode
mySER.sendUART("Opening socket to server: " + myApp.IP + ":" + myApp.PORT + "\r\n")
rtnList = SOCKET.openSocket(myApp.IP,myApp.PORT,1,myApp.USERNAME,myApp.PASSWORD,myApp.PROTOCOL,0)
if (rtnList[0] == -1) or (rtnList[0] == -2): raise UserWarning
#Check for open connection, this catches both online and command mode operations
if (rtnList[1] == "OK" or rtnList[1] == "CONNECT"):
mySER.sendUART("Socket opened successfully.\r\n")
else:
mySER.sendUART("Connection failed to open, trying again. \r\n")
#Check for open socket
DCD = MDM.getDCD()
if (DCD == 1):
#Set DCD on USIF0
SER.setDCD(1)
#Forward CONNECT Message to Serial Port
mySER.sendUART('\r\nConnected to Server\r\n')
myIO.USER_LED('ON')
#######################################
## Data exchange loop
#######################################
##Loop while Socket connected. This loop operates on the notion that we are in online mode, so we are not using send_CM
while(1):
#Pet the watchdog
MOD.watchdogReset()
#Check for DCD active on MDM
DCD = MDM.getDCD()
if (DCD == 1):
#Outbound
#Get data from serial port, use function return
rtnList = mySER.readUART()
if (len(rtnList[1])!=0):
#Forward data to open socket if it's not empty and not the exit script command
#check for exit prompt, let's use command EXITSCR
if (rtnList[1].find('EXITSCR') != -1): #exit found
print '\r\nExit Command Found\r\n'
print 'Exiting data mode\r\n'
rtnList = SOCKET.exitDataMode()
print 'Closing the socket\r\n'
rtnList = SOCKET.closeSocket(1)
return
print rtnList[1] #Debug
res = MDM.send(rtnList[1],1)
#Inbound
#Get data from open socket connection, straight MDM read
res = MDM.read()
if (len(res)!=0):
#Forward socket data to serial port
print res #Debug
mySER.sendUART(res)
#When socket is closed exit loop via this path
#Will guarantee that '\r\nNO CARRIER\r\n' is sent every time
if (DCD == 0):
#Clear DCD on USIF0
SER.setDCD(0)
myIO.USER_LED('OFF')
#Get any remaining data from closed socket connection, straight MDM read
res = MDM.read()
if (len(res)!=0):
#Forward socket data to serial port
mySER.sendUART(res)
break #exit loop to registration checks
except UserWarning:
print 'Controlled Script exit'
except:
print sys.exc_info()
rtnList[0] = -1
return