I wrote a small "Debug" module that simply configures a com port and creates a queue to receive debug print messages that are then printed out of that com port. I wanted this because it moves the debug output to a different thread than what I'm debugging, so it should have less of an impact on the code being debugged. It also guarantees that debug code will not be intermingled between different threads.
In any case, I want to make some code compile to use this functionality if the module is compiled into the firmware, and I don't currently see a method to do this. There is specific switches for e.g. the GCS module, but I don't see anything general.
I added this to the CopterControl Makefile:
CDEFS += ${foreach MOD, ${OPTMODULES}, -DUSE_${MOD}}
, which seems to work. It adds a -DUSE_Debug, or -DUSE_GPS to the compile command line if the Debug or GPS modules are included respectively. The only problem is that I would rather have it define -DUSE_DEBUG, but I don't see a way to convert to uppercase in GNU make.
Does this seem like something that would be generally useful to others? Does anyone know of an existing way or better way of doing this?



United States
Austria








