Ejemplo n.º 1
0
def Npull(dest, payload):
    startTime = time.time()
    publish(
        clientEgress.clientEncapsulate(b'\x01', nodeID, dest, payload, secret))
    reply = rlinetest.newReadLine(zb, 12)
    if not (reply == b''):
        data = ReceiveV2.Receive(reply[:-2])
    curTime = time.time()
    while (curTime - startTime < 24):
        reply = rlinetest.newReadLine(zb, 12)
        if not (reply == b''):
            data = ReceiveV2.Receive(reply[:-2])
            if (isMyPull(data)):
                print('Npull sucess: ', data)
        curTime = time.time()
Ejemplo n.º 2
0
def zbRecv():
    global testlock
    while True:
        data = rlinetest.newReadLine(zb)
        #data = zb.readline()
        packetQueue.put(data[:-2])
        zb.flush()
Ejemplo n.º 3
0
def pullReceive():
    startTime = time.time()
    buff = rlinetest.newReadLine(zb, 12)
    print("PULLREC DEBUG")
    if not (buff == b''):
        data = ReceiveV2.Receive(buff[:-2])
    curTime = time.time()
    while (curTime - startTime < 24):
        buff = rlinetest.newReadLine(zb, 12)
        if not (buff == b''):
            print('buff is', buff[:-2])
            data = ReceiveV2.Receive(buff[:-2])
            if (isMyPull(buff)):
                return data
                #return buff[:-2]
        curTime = time.time()
    return None
Ejemplo n.º 4
0
def receive():
	#zb  = serial.Serial(SERPORT,timeout=12)
	data = rlinetest.newReadLine(zb,12)
	#zb.flush()
	print("received: (len:",len(binascii.hexlify(data)),") :",binascii.hexlify(data))
	if not (data==None):
		if(forMe(data)):
			return data[:-2]
	return None
Ejemplo n.º 5
0
def recPackets():
    global zbLock
    #global SERPORT
    #zb = serial.Serial('SERPORT', timeout=1)
    print("zb_recPackets")
    while True:
        try:
            zbLock.acquire()
            data = rlinetest.newReadLine(zb, 5)
            if (data != b''):
                ReceiveV2.Receive(data[:-2])
            zbLock.release()
            #pass
            #temp = b'\x00' # find a better delay
            time.sleep(.5)
            #print('')
            #parsePacket = ReceiveV2.Receive(data)
            #parsePacket = ReceiveV2.Receive(data[:-2], nodeID, secret)
        except KeyboardInterrupt:
            sys.exit()