Lopy4 : lora callback issue



  • Hello,
    the code

    from network import LoRa                                                                                                                              
                                                                                                                                                          
    def onReceive(interface):                                                                                                                             
        print("LoRa RX Event")                                                                                                                            
                                                                                                                                                          
    lora_Interface = LoRa(LoRa.LORA, region=LoRa.EU868,
                          frequency = 868100000,bandwidth=LoRa.BW_125KHZ,
                          sf=7, coding_rate=LoRa.CODING_4_5,
                          preamble=8,  power_mode=LoRa.ALWAYS_ON,
                          public=False)
    
    lora_Interface.callback(trigger=LoRa.RX_PACKET_EVENT,
                            handler=onReceive)
    

    works well.
    But if I add at the end

    while True:
           pass
    

    the callback is no longer run.

    If I stop using ctrl-c, the callback is called.

    Is this normal?
    Is the callback not an interrupt?

    Thanks
    Thierry



  • This post is deleted!

  • Global Moderator

    I think @d-alvrzx is correct here. You need some 'idle' time on the CPU for the callback to be registered. I believe its not a hardware routine that is used for the callback, but merely on top of the RTOS.



  • @Thierry Something similar happened to me awhile back, but not with Lora callbacks, but with threads. I remember what I ended up doing was adding a short sleep (something like sleep_ms(10)) to the main loop. That way the loop would yield occasionally, and threads would execute correctly. Maybe try doing this?

    This is the thread where this was discussed: https://forum.pycom.io/topic/5805/main-thread-blocks-auxiliary-threads-thread-module/6?=1600903682512


Log in to reply
 

Pycom on Twitter