RAK3172 Timers callback not processed

Good day,

Faced with strange behavior when using RUI3 version 4.1.1: at a random moment of time when using timers, their handlers stops being called (one or more, some system timers continue to be processed). Only resetting the device helps.

Only three timers are created: two RAK_TIMER_PERIODIC with 1sec and 5msec intervals, and one RAK_TIMER_ONESHOT with 10 minutes interval (it is not started yet).

We think that the problem is in the code responsible for creating a linked list of timers and selecting the next one to be processed.

What are you doing in the timer callbacks? Could it be that the processing time in the callback is larger than the interval?

Can you give more information about how you use the timers and timer callbacks?

1 Like

Good day, Bernd

On 5msec timer - Modbus RTU handler
On 1 sec - check GPIO states and set flags.

The Modbus handler can be processed longer than the 5 ms interval

You think this is a good way to do it?

If your timer function takes longer than the timer interval, that can indeed lead to problems.

Either make your timer interval longer or define the timer as one-shot. Process your ModBus data, then restart the timer with 5 seconds interval as one-shot again.

I thought timer callback events placed in queue list, and executed later in user space ( just have to remember not to overflow the queue size)

I will change processing of this timer

What if the timer events happen at the same time ?

If multiple timers hit “at the same time”, they are processed one by one.

I think your problem is with the 5 millisecond timer interval. That is very short and might block other tasks that are running in RUI3.

Not sure why you need a 5ms Modbus handler.
I have built devices with the RAK3172 using ModBus (both slave and master) and they work without such an resource intensive timer.

RUI3-RS485-Soil-Sensor
ModBus Slave and Master

Good day,

This small interval needed for minimal gap between request and response.
I changed timer from RUI3 to arduino-timer library called from “loop”