How to do the LogError() function from ISR routine

I use the FreeRTOS with CoreMQTT lib, it supports LogError() as log output.
However, it calls “xQueceSend()” in the LogError(), so it cannot call from ISR, but there is no Log output fucntion allowed to call from ISR.

Is there any workaround?

You can write a version which calls xQueceSendFromISR. Printing logs from an ISR is almost never a good idea. What problem are you trying to solve?

1 Like

Generally, ISR(interrupt service routine) should be kept as short as possible. (I totally agree - “almost never a good idea”)

Kind Regards,

As mentioned, printing logs from an ISR has loads of problems. Not the least is that if you try to output much, your chance of the Queue filling is just too high. It is best to have a Queue dedicated to error information that the ISR writes “raw” data (so small, and thus Queue can be made reasonably long) on error, and have a task drain the Queue and generate the log messages. If that Queue fills, you just lose messages (and maybe you set an overrun flag so you know that), and you log that.

Generally, ISRs shouldn’t be doing much work on the data anyway, so most of the logging can be done in a task.

Thank you for your comment. I use V10.4.3 LTS Patch 2 of FreeRTOS kernel.

I would like to output the log when the peripheral interrupt for error happened.
I think it can solve to use que to take the log massage to the other log task that is not interrupt.
However, I think it is easyer to provide log API which can be called by ISR routine.

What do you plan to do that with that log? Is that only for debugging purpose? If yes, you can create another wrapper using xQueceSendFromISR as I mentioned above? Alternatively, you can keep incrementing a counter and examine that in the debugger later.

1 Like

Hi Aggarg

Yes, the log is just for debugging purpose to know what error happened when using Peripherals in their interrupts.
I agree your proposal to create another wrapper using xQueceSendFromISR.
I expected there was any API to support output the log in ISR routine, because Users want to use it in ISR sometimes.