LOG inside work_queue


We are curently creating our own module on PX4 stack.
Log functions like PX4_LOG do not work inside work_queue() but they work great outside.

we also tried to send info to mavlink with mavlink_log_info function (throught status text message)
We tried to use:
mavlink_log_info(&mavlink_log_pub, "test"); static orb_advert_t mavlink_log_pub = NULL; ← as global var
Without success.

Thanks for your attention

I don’t see why they shouldn’t wor. How did you create your module? What specifically did you try and what did you see? PX4_INFO, PX4_WARN, etc?

For mavlink_log (and uORB subscriptions in general) you need to make sure the orb_subscribe happens in the thread that actually runs the work queue cycle. As a quick hack you can lazily initialize it in the first cycle if it’s still a nullptr.

As you can see with these screenshots the mavlink_log_pub variable is initialized as null at start.
You can also see when we try to send debug message on the last picture.

We can see log messages when we call the service while we are not in work_queue but nether inside.
The counter (var cycle_count declared in struct) is incremented properly (the cycle is well executed).

Thanks for your time

Are you sure that portion of the cycle code is even running? Does a regular printf at the top of new_gps_cycle() work?

No, we can’t see when we printf at the top of new_gps_cycle().
We are sure that new_gps_cycle() is running because we had add lines to new_gps_main() to catch argument “test” and it will printf the count_cycle’s var which increments properly.

We only use Tools/mavlink_shell.py with USB’s port of PX4. Is it possible to see logs inside work_queue with this method?


No, you’ll need a real console. https://dev.px4.io/en/debug/system_console.html