How can you go about adding a debug statement to the ArduPilot code. I made some changes and wanted to log or print to screen during SITL testing.
Will the Serial.print work anywhere I put it without breaking something?
Or is there something already built into the code I can call or use?
Thanks,
-Matt

Hi Matt,
Serial.printf() will work almost everywhere (the exception is places like interrupt handlers).
If you only want the message in SITL, then you can instead use SITL_debug(), like this:
SITL_debug("some message\n");
Cheers, Tridge
Permalink Reply by Greg Fletcher on April 26, 2012 at 10:18pm Hi Matt,
I have used Serial.print ('' ") for debugging quite a bit. Just pit it in a slow loop so you can read it and the digits don't flicker, and comment out other prints as needed. Like here at the end of the fast loop.
// ------------------------------
set_servos();
///test/// gcs_update();
///test/// gcs_data_stream_send();
}
static void medium_loop()
Add you stuff to the medium or slow loop.
Andrew I'm a bit confuse.
I wrote this code (bits of Test code) in ArduPlane:
-----------------------------------
case 4:
medium_loopCounter = 0;
delta_ms_medium_loop = millis() - medium_loopTimer;
medium_loopTimer = millis();
if (g.battery_monitoring != 0){
read_battery();
}
//****Test Code
SITL_debug("Sitl:Hey!\n");
Serial.print ("Serial:Hey!\n");
//****End Test Code
slow_loop();
break;
--------------------------------------
I do see "Serial:Hey!".... in APM console but not the SITL one...
maybe I missed something.... please help.
Cheers,
-Eric
Permalink Reply by Matt Landowski on April 28, 2012 at 5:21pm Thanks, for all the replies definately helped a ton.
I tired to go the route of writing my own flash log outputs in the Log.pde, just glad to know there is an easier way.
Thanks!
Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.1299 members
24 members
48 members
51 members
111 members
© 2013 Created by Chris Anderson.
Powered by
