def getStatus(destination): pynvc.receive(10) pynvc.sendcmd(destination, pynvc.APPMSG, [3]); reply = pynvc.receive(100) # Receive reply if reply != None and reply[1] == 4: return reply[2:] else: reply = pynvc.receive(100) # Receive reply if reply != None and reply[1] == 4: return reply[2:] else: return None
def testRot13(destination, input): print "--- Input: ", input pynvc.sendcmd(destination, pynvc.APPMSG, [ord(c) for c in input]) print "--- Sent" src, reply = pynvc.receive(5000) # Receive reply print "--- Received reply" pynvc.sendcmd(destination, pynvc.APPMSG_R, [pynvc.APPMSG_STATUS_ACK]) print "Reply:", [chr(c) for c in reply[1:]] # Strip of the leading 0x7e (APPMSG) command
#!/usr/bin/python import time import pynvc messages_in_progress = {} pynvc.init(0) while(True): src, message = pynvc.receive(1000) if message == None: continue command = message[0] debugtext = ''.join(chr(i) for i in message[1:]) #print '%d %d "%s"' % (command, len(debugtext), debugtext) if command == pynvc.DEBUG_TRACE_PART: if not messages_in_progress.has_key(src): messages_in_progress[src] = "" messages_in_progress[src] += debugtext elif command == pynvc.DEBUG_TRACE_FINAL: if messages_in_progress.has_key(src): debugtext = messages_in_progress[src] + debugtext messages_in_progress[src] = "" print ("[%s node %d] %s" % (time.strftime("%H:%M:%S ", time.localtime()), src, debugtext.rstrip()))
def getRunLevelTest(destination): pynvc.sendcmd(destination, pynvc.GETRUNLVL) src, received_data = pynvc.receive(5000) if not received_data == None: print "Received runlevel:", received_data[1]
def listen(): while True: src, received_data = pynvc.receive(5000) if received_data != None: print "Received ", len(received_data), " bytes: ", received_data