1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

SanityCheck: Trigger sanity check code on callbacks from the appropriate settings.

The only downside is that it needs to update on the TaskInfo object which means
since htat updates periodically this code runs more often that really needed since
the modules only start at first.  However, leaving that connection out means it
misses the initial set of modules.
This commit is contained in:
James Cotton 2012-10-25 21:49:53 -05:00
parent 736f96b297
commit b28cdba46d
2 changed files with 18 additions and 4 deletions

View File

@ -29,7 +29,6 @@
#include "openpilot.h"
#include <pios_board_info.h>
#include "sanitycheck.h"
#include "hwsettings.h"
#include "taskinfo.h"
#include "manualcontrolsettings.h"
#include "systemalarms.h"

View File

@ -43,6 +43,7 @@
#include "sanitycheck.h"
#include "objectpersistence.h"
#include "flightstatus.h"
#include "manualcontrolsettings.h"
#include "systemstats.h"
#include "systemsettings.h"
#include "i2cstats.h"
@ -88,6 +89,7 @@ static bool mallocFailed;
// Private functions
static void objectUpdatedCb(UAVObjEvent * ev);
static void configurationUpdatedCb(UAVObjEvent * ev);
static void updateStats();
static void updateSystemAlarms();
static void systemTask(void *parameters);
@ -168,14 +170,19 @@ static void systemTask(void *parameters)
// Listen for SettingPersistance object updates, connect a callback function
ObjectPersistenceConnectQueue(objectPersistenceQueue);
// Whenever the configuration changes, make sure it is safe to fly
SystemSettingsConnectCallback(configurationUpdatedCb);
ManualControlSettingsConnectCallback(configurationUpdatedCb);
TaskInfoConnectCallback(configurationUpdatedCb);
// Run this initially to make sure the configuration is checked
configuration_check();
// Main system loop
while (1) {
// Update the system statistics
updateStats();
// TODO: Make this only be called when configuration settings change
configuration_check();
// Update the system alarms
updateSystemAlarms();
#if defined(I2C_WDG_STATS_DIAGNOSTICS)
@ -307,6 +314,14 @@ static void objectUpdatedCb(UAVObjEvent * ev)
}
}
/**
* Called whenever a critical configuration component changes
*/
static void configurationUpdatedCb(UAVObjEvent * ev)
{
configuration_check();
}
/**
* Called periodically to update the I2C statistics
*/