Ping-Pong Example Reset



  • Greetings,

    I am currently using two Lopy1.0 one which is plugged into a breadboard and the other attached to a pytrack. I am currently running the code you see below. Pretty much the basic Ping-Pong example. I have a question regarding that when this example Node_A hangs, due to saturation or some other natural reason, so my Node_A, which is always listening, just can never see the node_B 'Ping' . It won't find it again until I reset the Node_B which sends just the ping. What is that reset doing in Node_B? Intuitively I would have thought the Node_A would need to be reset, like if there was a buffer issue, however resetting Node_A has no effect and it continues to not see the 'Ping'
    (Side note: With the Timestamp from lora.stats(), where is that data coming from/how to decode that into meaningful data?)

    Node_A (Just listens and reports data)

    import socket
    import time
    import pycom
    
    
    #NODE A
    
    # Please pick the region that matches where you are using the device:
    # Asia = LoRa.AS923
    # Australia = LoRa.AU915
    # Europe = LoRa.EU868
    # United States = LoRa.US915
    lora = LoRa(mode=LoRa.LORA, frequency = 915000000, region=LoRa.US915)
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setblocking(False)
    
    pycom.heartbeat(False)
    pycom.rgbled(0x007f00) # green
    
    #TX_power is the value that is set on this chip not received.
    while True:
        if s.recv(64) == b'Ping':
            #print("Sending pong")
            data = lora.stats()
            print("Stats %s" % data)
            pycom.rgbled(0x0000ff) # blue
            time.sleep(.5)
            pycom.rgbled(0x00ff00) # green
            #s.send('Pong')
        #time.sleep(1)
    

    Node_B just sends

    import socket
    import time
    import pycom
    #NODE B
    
    # Please pick the region that matches where you are using the device:
    # Asia = LoRa.AS923
    # Australia = LoRa.AU915
    # Europe = LoRa.EU868
    # United States = LoRa.US915
    lora = LoRa(mode=LoRa.LORA, frequency = 915000000, region=LoRa.US915, tx_power = 20)
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setblocking(False)
    
    pycom.heartbeat(False)
    pycom.rgbled(0x007f00) # green
    
    while True:
        s.send('Ping')
        time.sleep(5)
        pycom.rgbled(0x0000ff) # blue
        time.sleep(1)
        pycom.rgbled(0x00ff00) # green


  • @burgeh The flashing just shows that the loop still continues. That's what I assumed, because of the print statement in the loop. But I wanted to see if still the RF signal is present.



  • @robert-hh Sorry misinterpreted that a little bit. Yes the node_B is still sending from what I can tell. Looking at the code it still flashes blue and green. However, looking at it now maybe the s.send is in some error state and may be just failing (but the code would still blink).



  • @burgeh I do not know. According to your tests, it is related to the sending device, that's why I wanted to tell, whether the device is still sending. If yes, either the content of could have changed (not "Ping"), or some other frequency was used, or ...... But I could net get a stable fault condition.



  • @robert-hh

    I've noticed these inconsistencies as well, I've had node A receiving the message for 4 to 5 hours and then just stop, I'll reset and it will stop after 10 minutes. Does the s socket (something with the recv) need something to be cleared if it only receives part of a message, that way it can recover?



  • @burgeh I have noticed initially some trouble to run that simple test, and just tried to do it again. I've seen some diverging behaviour:

    • in one attempt, the Node A stopped showing received permanently
      . in a second attempt it stopped for a while and then it recovered
    • in a third attempt, out of 400 messages of node B, one was skipped at node A

    It tried that because I wanted to tell, if at the time, node A does not get any messages any more, node B is still sending. But I could not create the first event any more.



Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.