I am trying to convert an app to asyncio and I am using this as a reference:
https://github.com/peterhinch/micropyth ... -irq_event
However, no matter what I do I am getting the following error:
Code: Select all
Uncaught exception in IRQ callback handler
MemoryError:
Code: Select all
class MyDevice:
def __init__(self, uart ...):
self.uart = uart
# asyncio event set by the hard UART interrupt handler
self.rx_event = IRQ_EVENT()
self.uart.irq(self.on_serial_rx_data, machine.UART.IRQ_RXIDLE, True)
asyncio.create_task(self.handle_serial_rx())
def on_serial_rx_data(self, *args, **kwargs):
'''
Callback called as an ISR whenever there are characters waiting in the RX buffer.
'''
# Set the asyncio event and return ASAP
self.rx_event.set()
async def handle_serial_rx(self,):
while True:
await self.rx_event.wait() # Wait for the next interrupt
# Do stuff that does allocate memory...