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:
parent
736f96b297
commit
b28cdba46d
@ -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"
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user