Output from Pixhawk 2

I would like to put printf or some sort of log messages in the source code for debugging purposes. I would like to do this in SITL and in hardware (Pixhawk 2). I can’t seem to figure out how to do this properly. What is the best way to do this? I’ve tried a lot of things and looked through the docs with no luck. I’d even be happy to write the messages to a file (on sd card or computer in SITL). Any help would be VERY much appreciated. Developing code is at a standstill till I can figure this out.

Does this help? http://dev.px4.io/tutorial-hello-sky.html

Thanks for the pointer. I’ll see if I can make one of those methods work. It still would be nice if I could write to a log file instead of having to put it on mavlink or in a parameter.

Just add a printf in the code and it will be displayed directly on NSH. If you are interested in the value of a topic you can also use listeners

I tried using printf and did not see any output, but I may have other problems that are keeping me from getting to the printf code. I’ll try it again.

hello, did you figure out how to add printf to the sitl ?

As the sample shows “PX4_INFO(“Hello Sky!”);” is the way to do it. If that is getting filtered out try PX4_WARN, because PX4_INFO calls px4_log_modulename which contains this test: if (level >= _PX4_LOG_LEVEL_WARN && orb_log_message_pub) { //only publish important messages…

I never tried sitl but on the hardware there is no way to get printout from px4io process since it is on another processor. Print from other processes show up on the console just fine.

yes i know what you are saying … that is why i have had to resort to sitl since px4io can’t print. But i thired printf in sitl and it works just fine … it throws the output on the console