Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Lopy4 : lora callback issue

    Scheduled Pinned Locked Moved LoPy
    4 Posts 3 Posters 78 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      Thierry
      last edited by Thierry

      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

      D 1 Reply Last reply Reply Quote 0
      • D Offline
        d.alvrzx @Thierry
        last edited by

        @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

        1 Reply Last reply Reply Quote 2
        • G Offline
          Gijs
          last edited by

          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.

          T 1 Reply Last reply Reply Quote 2
          • T Offline
            Thierry @Gijs
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom