ScheduledWorkItem on serial port - synchronize with incoming data

Hi,
I am currently developing a driver for a sensor that connects over UART. I created ScheduledWorkItem with wq_config_t pointing to the selected serial port.

As I can schedule a task on selected intervals or given delays, I was wondering if there is an option to wake up a task after the serial port has received some data to read.

Also, I can’t fully understand the delay_us part on ScheduleOnInterval(). Is this the maximum allowed delay that can occur during scheduling given task?

Thanks in advance for any help!

You can just use the readAtLeast function in the Serial class to wait for data. Your task will poll/sleep while it waits for bytes.

1 Like

Thanks, this is all I needed!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.