Enabling debug messages and logging for driver development

I’m working on an I2C magnetometer driver and see a few “DEVICE_DEBUG” messages in the code, which seems to map to PX4_LOG_NAMED_COND in px4_log.h

see src/drivers/magenetometer/hmc5883.cpp line 411 as an example of DEVICE_DEBUG

I’m connected to the Nuttx console using an FTDI cable. How do I build and upload my firmware so I can access these debug messages? It looks like px4_log.h looks at “DEBUG_BUILD” being defined but I don’t see where I set that anywhere.

I also don’t have these messages being written to a log on the sd card, either.

Did you figure this out? I’m also interested in knowing how to see log messages. I thought they would appear in console, but obviously need to enable the messages somewhere.

(I’m connected to the FMU console and can also connect to the IO console in Pixhawk 4)

I never did. I ended up just printing debug messages similar to how mixer_multirotor.cpp does it.

//#define debug(fmt, args...)do { } while(0)
#define debug(fmt, args...)do { printf("[mixer] " fmt "\n", ##args); } while(0)

switch out the commented line to suppress the message printing.

debug("hello world");

Ah, that’s a good tip, thanks.
Do you think you could use the PX4_INFO style messages?
Just found them in:
http://dev.px4.io/v1.9.0/en/apps/hello_sky.html

Or do they have to be enabled somewhere ?
Thanks

Yeah, those work. I like my version because its easy to turn off the print statements by just commenting a single line. PX4_INFO is pretty much just a printf function.

OK, good point, that’s a good capability to have.