I believe the second approach would be the correct one to use, request a non-blocking IRQ RX transfer. I’m not sure if you have checked the GitHub examples about UART, if not here’s the link https://github.com/quark-mcu/qmsi/blob/master/examples/uart/main.c. In that example they set an async_xfer_desc variable, setting the data, data length and callback.
Now to define the xfer, I can’t think of an exact way to resolve this issue, but a possible workaround would be to set the length according to the maximum length of the buffer and set a signal that tells when the data has finished.
Thank you Pablo! I will check the example.