コード例 #1
0
ファイル: cptaskmanager.py プロジェクト: johncobb/EchoBase
 def task_handler(self):
     while not self.closing:
         rf_data = self.rfThread.queue_get()
         time.sleep(.0001)
         
         if(len(rf_data) == 43):
         
             data = cpcobs.decode(rf_data)
 
             if (checksumValid(data) == False):
                 print 'Invalid Checksum'
                 continue
             print 'Queued Message Received!!!'
             msg = AppMessage()
             msg.messageType = ord(data[0])
             msg.nodeType = ord(data[1])
             msg.extAddr = (ord(data[2])) + (ord(data[3])<<8) + (ord(data[4])<<16) + (ord(data[5])<<24) + (ord(data[6])<<32) + (ord(data[7])<<40) + (ord(data[8])<<48) + (ord(data[9])<<56)
             msg.shortAddr = (ord(data[10])) + (ord(data[11])<<8)
             msg.softVersion = (ord(data[12])) + (ord(data[13])<<8) + (ord(data[14])<<16) + (ord(data[15])<<24)
             msg.channelMask = (ord(data[16])) + (ord(data[17])<<8) + (ord(data[18])<<16) + (ord(data[19])<<24)
             msg.panId = (ord(data[20])) + (ord(data[21])<<8)
             msg.workingChannel = ord(data[22])
             msg.parentShortAddr = (ord(data[23])) + (ord(data[24])<<8)
             msg.lqi = ord(data[25])
             msg.rssi = ord(data[26])
             msg.type = ord(data[27])
             msg.size = ord(data[28])
             msg.battery = (ord(data[29])) + (ord(data[30])<<8) + (ord(data[31])<<16) + (ord(data[32])<<24)
             msg.temperature = (ord(data[33])) + (ord(data[34])<<8) + (ord(data[35])<<16) + (ord(data[36])<<24)
             msg.light = (ord(data[37])) + (ord(data[38])<<8) + (ord(data[39])<<16) + (ord(data[40])<<24)
             
             packet = json.dumps(msg, cls=MyEncoder)
             self.inetThread.enqueue_packet(packet)
             
     time.sleep(1)
コード例 #2
0
ファイル: cptaskmanager.py プロジェクト: CPHT/echobaseppp
 def handler_rfqueue(self):
     
     rf_encoded = self.rfThread.queue_get()
     
     # TODO: Sanity check (Redundant: checked in cprf.py)
     if(len(rf_encoded) >= CpDefs.RfMsgLen):
         
         # Decode cobs encoding
         rf_decoded = cpcobs.decode(rf_encoded)
         
         # Validate checksum
         if (checksumValid(rf_decoded) == False):
             print 'Invalid Checksum'
             return
         
         if(CpDefs.LogVerboseTaskMgr):
             print 'Queued Message Received!!!'
         
         try:
             #self.handleNetworkThrottlingMacAddress(rf_decoded)
             self.handleNetworkThrottlingCompositeAddress(rf_decoded)
         except Exception, e:
             print "CpTaskManager::handler_rfqueue ERROR: ", e