micropython/lora, modem.set_irq_callback() #13180
-
In a previous distro I was using a callback, so attempted to migrate what I was familiar with to micropython/lora. The documentation is excellent, but I am struggling to get this method to work. In my main loop: data = [0, 0]
print('Initialising modem ...')
modem = get_modem()
print("Main loop started")
receiver = Receiver(modem)
def main():
global data
# install the callback
modem.set_irq_callback(my_rx_irq)
# loop waiting for a received message/
while(True):
print (f'Received msg in main: {data[0]}\n')
sleep(.1) and my callback: def my_rx_irq():
global receiver
global data
while True:
sender_id, data = receiver.recv(wait=True)
if data:
break
data = data.decode('utf-8')
data = data.split(',')
print (f'Received msg in IRQ: {data[0]}\n')
sleep(.1) I come up against the following error when the transmitter sends a message:
line 52 Do I need to call:
... before proceeding? I suspect there are other parameters I have to pass into Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
@davefes the callback that you pass to You may be getting confused by how AsyncModem uses this, but remember that in this case, with |
Beta Was this translation helpful? Give feedback.
-
Using the callback at the top of the post. I can see that I get the correct message in the IRQ but the message is not reflected consistently in the main loop. I expect that the main loop should continue from where ever it was interrupted. Or is there something else I need to do? Edit: Using the reliable_delivery sender example at one end and the above script on the receiving end I get this sequence:
I expected to see The data is being past-around using a global variable. Any suggestions? |
Beta Was this translation helpful? Give feedback.
@davefes The package server is fixed. If you
mip install
you should get the latest now.