1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Added new setting 'OnlyWhenArmed' to debuglogsettings

This commit is contained in:
Corvus Corax 2013-11-19 19:29:24 +01:00
parent 3bfe74e73c
commit 77b7ba3089
2 changed files with 21 additions and 3 deletions

View File

@ -41,12 +41,14 @@
static DebugLogSettingsData settings;
static DebugLogControlData control;
static DebugLogStatusData status;
static FlightStatusData flightstatus;
static DebugLogEntryData *entry; // would be better on stack but event dispatcher stack might be insufficient
// private functions
static void SettingsUpdatedCb(UAVObjEvent *ev);
static void ControlUpdatedCb(UAVObjEvent *ev);
static void StatusUpdatedCb(UAVObjEvent *ev);
static void FlightStatusUpdatedCb(UAVObjEvent *ev);
int32_t LoggingInitialize(void)
{
@ -68,6 +70,7 @@ int32_t LoggingStart(void)
{
DebugLogSettingsConnectCallback(SettingsUpdatedCb);
DebugLogControlConnectCallback(ControlUpdatedCb);
FlightStatusConnectCallback(FlightStatusUpdatedCb);
SettingsUpdatedCb(DebugLogSettingsHandle());
UAVObjEvent ev = { .obj = DebugLogSettingsHandle(), .instId = 0, .event = EV_UPDATED_PERIODIC };
@ -85,11 +88,26 @@ static void StatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
DebugLogStatusSet(&status);
}
static void FlightStatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
FlightStatusGet(&flightstatus);
switch (settings.LoggingEnabled) {
case DEBUGLOGSETTINGS_LOGGINGENABLED_ALWAYS:
PIOS_DEBUGLOG_Enable(1);
break;
case DEBUGLOGSETTINGS_LOGGINGENABLED_ONLYWHENARMED:
PIOS_DEBUGLOG_Enable(flightstatus.Armed == FLIGHTSTATUS_ARMED_ARMED);
break;
default:
PIOS_DEBUGLOG_Enable(0);
}
}
static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
DebugLogSettingsGet(&settings);
PIOS_DEBUGLOG_Enable(settings.LoggingEnabled);
PIOS_DEBUGLOG_Printf("Logging enabled");
FlightStatusUpdatedCb(NULL);
PIOS_DEBUGLOG_Printf("On board logging enabled.");
}
static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)

View File

@ -1,7 +1,7 @@
<xml>
<object name="DebugLogSettings" singleinstance="true" settings="true" category="System">
<description>Configure On Board Logging Facilities</description>
<field name="LoggingEnabled" units="bool" type="enum" elements="1" options="False,True" defaultvalue="False" />
<field name="LoggingEnabled" units="" type="enum" elements="1" options="Disabled,OnlyWhenArmed,Always" defaultvalue="Disabled" />
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>