예제 #1
0
def sketch_loop():
   global sketchQueue
   global sketchRun
   global proxyCmdBuffer
   global proxyRxBuffer

   toSend = []
   rxBytes = []

   target = 1
   temperature = 80
   rssi = -60
   timestamp = 0

   WRITE = 2
   SREG_TARGET = 7
   SREG_PING = 11
   PING = 1

   while sketchRun:
      for target in range(2,6):
         # set target
         toSend = Protocol.form_packet(cmd=WRITE, addr=SREG_TARGET, data=target)
         for b in toSend:
            proxyCmdBuffer.write(b)

         #get response
         rxBytes = []
         rxBytes.append(ord(proxyRxBuffer.read()))
         rxBytes.append(ord(proxyRxBuffer.read()))

         for i in range(rxBytes[-1]):
            rxBytes.append(ord(proxyRxBuffer.read()))
         rxBytes.append(ord(proxyRxBuffer.read()))      

############## get data
         toSend = Protocol.form_packet(cmd=WRITE, addr=SREG_PING, data=PING)
         for b in toSend:
            proxyCmdBuffer.write(b)

         #get response
         rxBytes = []
         rxBytes.append(ord(proxyRxBuffer.read()))
         rxBytes.append(ord(proxyRxBuffer.read()))

         for i in range(rxBytes[-1]):
            rxBytes.append(ord(proxyRxBuffer.read()))
         rxBytes.append(ord(proxyRxBuffer.read()))         

         rssi = -((rxBytes[3]^0xff)+1)
         temperature = rxBytes[4]
         timestamp = time.time()
         sketchQueue.put({'timestamp':timestamp, 'id':target, 'network':'BP', 'data':{'temp':temperature, 'rssi':rssi} })
         time.sleep(0.1)
예제 #2
0
target = 1
temperature = 80
rssi = -60
timestamp = 0

WRITE = 2
SREG_TARGET = 7
SREG_PING = 11
PING = 1

for frame in range(0,frameNumber):
	nodeDataList = []
	for target in range(2,6):
		# Set target node
		toSend = Protocol.form_packet(cmd=WRITE, addr=SREG_TARGET, data=target)
		for b in toSend:
			proxyCmdBuffer.write(b)

		#get response
		rxBytes = []
		rxBytes.append(ord(proxyRxBuffer.read()))
		rxBytes.append(ord(proxyRxBuffer.read()))

		for i in range(rxBytes[-1]):
			rxBytes.append(ord(proxyRxBuffer.read()))

		rxBytes.append(ord(proxyRxBuffer.read()))