diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 98629f335..a06fdbbd0 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -115,6 +115,7 @@ SRC += $(MODGPS)/GPS.c $(MODGPS)/buffer.c ## OPENPILOT: SRC += $(OPSYSTEM)/openpilot.c SRC += $(OPSYSTEM)/op_logging.c +SRC += $(OPSYSTEM)/alarms.c SRC += $(OPUAVTALK)/uavtalk.c SRC += $(OPUAVOBJ)/uavobjectmanager.c SRC += $(OPUAVOBJ)/uavobjectsinit.c diff --git a/flight/OpenPilot/Modules/Example/examplemodevent.c b/flight/OpenPilot/Modules/Example/examplemodevent.c index 7edc4a489..d27a0d691 100644 --- a/flight/OpenPilot/Modules/Example/examplemodevent.c +++ b/flight/OpenPilot/Modules/Example/examplemodevent.c @@ -44,6 +44,7 @@ * */ +#include "openpilot.h" #include "examplemodevent.h" #include "exampleobject1.h" // object the module will listen for updates (input) #include "exampleobject2.h" // object the module will update (output) diff --git a/flight/OpenPilot/Modules/Example/examplemodperiodic.c b/flight/OpenPilot/Modules/Example/examplemodperiodic.c index 611e49876..ac25c60f3 100644 --- a/flight/OpenPilot/Modules/Example/examplemodperiodic.c +++ b/flight/OpenPilot/Modules/Example/examplemodperiodic.c @@ -44,6 +44,7 @@ * */ +#include "openpilot.h" #include "examplemodperiodic.h" #include "exampleobject2.h" // object that will be updated by the module #include "examplesettings.h" // object holding module settings diff --git a/flight/OpenPilot/Modules/Example/examplemodthread.c b/flight/OpenPilot/Modules/Example/examplemodthread.c index 5f601452a..fb2c0973a 100644 --- a/flight/OpenPilot/Modules/Example/examplemodthread.c +++ b/flight/OpenPilot/Modules/Example/examplemodthread.c @@ -43,6 +43,7 @@ * http://www.openpilot.org/OpenPilot_Application_Architecture */ +#include "openpilot.h" #include "examplemodthread.h" #include "exampleobject1.h" // object the module will listen for updates (input) #include "exampleobject2.h" // object the module will update (output) diff --git a/flight/OpenPilot/Modules/Example/inc/examplemodevent.h b/flight/OpenPilot/Modules/Example/inc/examplemodevent.h index bcfdd052b..2d5309615 100644 --- a/flight/OpenPilot/Modules/Example/inc/examplemodevent.h +++ b/flight/OpenPilot/Modules/Example/inc/examplemodevent.h @@ -26,8 +26,6 @@ #ifndef EXAMPLEMODEVENT_H #define EXAMPLEMODEVENT_H -#include "openpilot.h" - int32_t ExampleModEventInitialize(); #endif // EXAMPLEMODEVENT_H diff --git a/flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h b/flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h index 36367d4bd..dd51df193 100644 --- a/flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h +++ b/flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h @@ -26,8 +26,6 @@ #ifndef EXAMPLEMODPERIODIC_H #define EXAMPLEMODPERIODIC_H -#include "openpilot.h" - int32_t ExampleModPeriodicInitialize(); #endif // EXAMPLEMODPERIODIC_H diff --git a/flight/OpenPilot/Modules/Example/inc/examplemodthread.h b/flight/OpenPilot/Modules/Example/inc/examplemodthread.h index 3297ac940..9b3880261 100644 --- a/flight/OpenPilot/Modules/Example/inc/examplemodthread.h +++ b/flight/OpenPilot/Modules/Example/inc/examplemodthread.h @@ -26,8 +26,6 @@ #ifndef EXAMPLEMODTHREAD_H #define EXAMPLEMODTHREAD_H -#include "openpilot.h" - int32_t ExampleModThreadInitialize(); #endif // EXAMPLEMODTHREAD_H diff --git a/flight/OpenPilot/Modules/System/inc/systemmod.h b/flight/OpenPilot/Modules/System/inc/systemmod.h index 1c6f7abd1..84c300c7f 100644 --- a/flight/OpenPilot/Modules/System/inc/systemmod.h +++ b/flight/OpenPilot/Modules/System/inc/systemmod.h @@ -26,8 +26,6 @@ #ifndef SYSTEMMOD_H #define SYSTEMMOD_H -#include "openpilot.h" - int32_t SystemModInitialize(void); #endif // SYSTEMMOD_H diff --git a/flight/OpenPilot/Modules/System/systemmod.c b/flight/OpenPilot/Modules/System/systemmod.c index d46a958e7..7d2ac699d 100644 --- a/flight/OpenPilot/Modules/System/systemmod.c +++ b/flight/OpenPilot/Modules/System/systemmod.c @@ -24,6 +24,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "systemmod.h" #include "settingspersistence.h" #include "systemstats.h" @@ -36,16 +37,23 @@ #define STACK_SIZE configMINIMAL_STACK_SIZE #define TASK_PRIORITY (tskIDLE_PRIORITY+3) +#define HEAP_LIMIT_WARNING 4000 +#define HEAP_LIMIT_CRITICAL 1000 +#define CPULOAD_LIMIT_WARNING 80 +#define CPULOAD_LIMIT_CRITICAL 95 + // Private types // Private variables static uint32_t idleCounter; static uint32_t idleCounterClear; static xTaskHandle systemTaskHandle; +static int32_t stackOverflow; // Private functions static void objectUpdatedCb(UAVObjEvent* ev); static void updateStats(); +static void updateSystemAlarms(); static void systemTask(void* parameters); /** @@ -54,6 +62,8 @@ static void systemTask(void* parameters); */ int32_t SystemModInitialize(void) { + // Initialize vars + stackOverflow = 0; // Create system task xTaskCreate(systemTask, (signed char*)"System", STACK_SIZE, NULL, TASK_PRIORITY, &systemTaskHandle); return 0; @@ -83,9 +93,22 @@ static void systemTask(void* parameters) // Update the system statistics updateStats(); - // Flash the LED + // Update the system alarms + updateSystemAlarms(); + + // Flash system alive the LED PIOS_LED_Toggle(LED1); + // Flash the error LED if an alarm is set + if ( AlarmsHasWarnings() ) + { + PIOS_LED_Toggle(LED2); + } + else + { + PIOS_LED_Off(LED2); + } + // Wait until next period vTaskDelayUntil(&lastSysTime, SYSTEM_UPDATE_PERIOD_MS / portTICK_RATE_MS); } @@ -132,6 +155,79 @@ static void updateStats() SystemStatsSet(&stats); } +/** + * Update system alarms + */ +static void updateSystemAlarms() +{ + SystemStatsData stats; + UAVObjStats objStats; + EventStats evStats; + SystemStatsGet(&stats); + + // Check heap + if ( stats.HeapRemaining < HEAP_LIMIT_CRITICAL ) + { + AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_CRITICAL); + } + else if ( stats.HeapRemaining < HEAP_LIMIT_WARNING ) + { + AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_WARNING); + } + else + { + AlarmsClear(SYSTEMALARMS_ALARM_OUTOFMEMORY); + } + + // Check CPU load + if ( stats.CPULoad > CPULOAD_LIMIT_CRITICAL ) + { + AlarmsSet(SYSTEMALARMS_ALARM_CPUOVERLOAD, SYSTEMALARMS_ALARM_CRITICAL); + } + else if ( stats.CPULoad > CPULOAD_LIMIT_WARNING ) + { + AlarmsSet(SYSTEMALARMS_ALARM_CPUOVERLOAD, SYSTEMALARMS_ALARM_WARNING); + } + else + { + AlarmsClear(SYSTEMALARMS_ALARM_CPUOVERLOAD); + } + + // Check for stack overflow + if ( stackOverflow == 1 ) + { + AlarmsSet(SYSTEMALARMS_ALARM_STACKOVERFLOW, SYSTEMALARMS_ALARM_CRITICAL); + } + else + { + AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW); + } + + // Check for SD card + if ( POIS_SDCARD_IsMounted() == 0 ) + { + AlarmsSet(SYSTEMALARMS_ALARM_SDCARD, SYSTEMALARMS_ALARM_WARNING); + } + else + { + AlarmsClear(SYSTEMALARMS_ALARM_SDCARD); + } + + // Check for event errors + UAVObjGetStats(&objStats); + EventGetStats(&evStats); + UAVObjClearStats(); + EventClearStats(); + if ( objStats.eventErrors > 0 || evStats.eventErrors > 0 ) + { + AlarmsSet(SYSTEMALARMS_ALARM_EVENTSYSTEM, SYSTEMALARMS_ALARM_WARNING); + } + else + { + AlarmsClear(SYSTEMALARMS_ALARM_EVENTSYSTEM); + } +} + /** * Called by the RTOS when the CPU is idle, used to measure the CPU idle time. */ @@ -154,6 +250,6 @@ void vApplicationIdleHook(void) */ void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName ) { - + stackOverflow = 1; } diff --git a/flight/OpenPilot/Modules/Telemetry/telemetry.c b/flight/OpenPilot/Modules/Telemetry/telemetry.c index b512f0aca..7b048f94a 100644 --- a/flight/OpenPilot/Modules/Telemetry/telemetry.c +++ b/flight/OpenPilot/Modules/Telemetry/telemetry.c @@ -203,6 +203,16 @@ static void processObjEvent(UAVObjEvent* ev) txErrors = 0; txRetries = 0; FlightTelemetryStatsSet(&stats); + + // Update the telemetry alarm + if ( stats.Connected == FLIGHTTELEMETRYSTATS_CONNECTED_TRUE ) + { + AlarmsClear(SYSTEMALARMS_ALARM_TELEMETRY); + } + else + { + AlarmsSet(SYSTEMALARMS_ALARM_TELEMETRY, SYSTEMALARMS_ALARM_ERROR); + } } // This is an object update, handle based on event type else diff --git a/flight/OpenPilot/System/alarms.c b/flight/OpenPilot/System/alarms.c new file mode 100644 index 000000000..116a165e5 --- /dev/null +++ b/flight/OpenPilot/System/alarms.c @@ -0,0 +1,181 @@ +/** + ****************************************************************************** + * + * @file alarms.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Library for setting and clearing system alarms + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "openpilot.h" +#include "alarms.h" + +// Private constants + +// Private types + +// Private variables +static xSemaphoreHandle lock; + +// Private functions +static int32_t hasSeverity(SystemAlarmsAlarmOptions severity); + +/** + * Initialize the alarms library + */ +int32_t AlarmsInitialize(void) +{ + lock = xSemaphoreCreateRecursiveMutex(); + AlarmsClearAll(); + return 0; +} + +/** + * Set an alarm + * @param alarm The system alarm to be modified + * @param severity The alarm severity + * @return 0 if success, -1 if an error + */ +int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity) +{ + SystemAlarmsData alarms; + uint8_t changed; + + // Check that this is a valid alarm + if (alarm >= SYSTEMALARMS_ALARM_NUMELEM) + { + return -1; + } + + // Lock + xSemaphoreTakeRecursive(lock, portMAX_DELAY); + + // Read alarm and update its severity only if it was changed + SystemAlarmsGet(&alarms); + if ( alarms.Alarm[alarm] != severity ) + { + alarms.Alarm[alarm] = severity; + SystemAlarmsSet(&alarms); + SystemAlarmsUpdated(); // force telemetry update since the alarm was changed + } + + // Release lock + xSemaphoreGiveRecursive(lock); + return 0; + +} + +/** + * Get an alarm + * @param alarm The system alarm to be read + * @return Alarm severity + */ +SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm) +{ + SystemAlarmsData alarms; + + // Check that this is a valid alarm + if (alarm >= SYSTEMALARMS_ALARM_NUMELEM) + { + return 0; + } + + // Read alarm + SystemAlarmsGet(&alarms); + return alarms.Alarm[alarm]; +} + +/** + * Clear an alarm + * @param alarm The system alarm to be modified + * @return 0 if success, -1 if an error + */ +int32_t AlarmsClear(SystemAlarmsAlarmElem alarm) +{ + return AlarmsSet(alarm, SYSTEMALARMS_ALARM_OK); +} + +/** + * Clear all alarms + */ +void AlarmsClearAll() +{ + uint32_t n; + for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n) + { + AlarmsClear(n); + } +} + +/** + * Check if there are any alarms with the given or higher severity + * @return 0 if no alarms are found, 1 if at least one alarm is found + */ +int32_t AlarmsHasWarnings() +{ + return hasSeverity(SYSTEMALARMS_ALARM_WARNING); +} + +/** + * Check if there are any alarms with error or higher severity + * @return 0 if no alarms are found, 1 if at least one alarm is found + */ +int32_t AlarmsHasErrors() +{ + return hasSeverity(SYSTEMALARMS_ALARM_ERROR); +}; + +/** + * Check if there are any alarms with critical or higher severity + * @return 0 if no alarms are found, 1 if at least one alarm is found + */ +int32_t AlarmsHasCritical() +{ + return hasSeverity(SYSTEMALARMS_ALARM_CRITICAL); +}; + +/** + * Check if there are any alarms with the given or higher severity + * @return 0 if no alarms are found, 1 if at least one alarm is found + */ +static int32_t hasSeverity(SystemAlarmsAlarmOptions severity) +{ + SystemAlarmsData alarms; + uint32_t n; + + // Lock + xSemaphoreTakeRecursive(lock, portMAX_DELAY); + + // Read alarms + SystemAlarmsGet(&alarms); + + // Go through alarms and check if any are of the given severity or higher + for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n) + { + if ( alarms.Alarm[n] >= severity) + { + xSemaphoreGiveRecursive(lock); + return 1; + } + } + + // If this point is reached then no alarms found + xSemaphoreGiveRecursive(lock); + return 0; +} diff --git a/flight/OpenPilot/System/inc/alarms.h b/flight/OpenPilot/System/inc/alarms.h new file mode 100644 index 000000000..d9b8f6461 --- /dev/null +++ b/flight/OpenPilot/System/inc/alarms.h @@ -0,0 +1,40 @@ +/** + ****************************************************************************** + * + * @file alarms.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Include file of the alarm library + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef ALARMS_H +#define ALARMS_H + +#include "systemalarms.h" + +int32_t AlarmsInitialize(void); +int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity); +SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm); +int32_t AlarmsClear(SystemAlarmsAlarmElem alarm); +void AlarmsClearAll(); +int32_t AlarmsHasWarnings(); +int32_t AlarmsHasErrors(); +int32_t AlarmsHasCritical(); + +#endif // ALARMS_H + diff --git a/flight/OpenPilot/System/inc/openpilot.h b/flight/OpenPilot/System/inc/openpilot.h index 075273690..6893edfb2 100644 --- a/flight/OpenPilot/System/inc/openpilot.h +++ b/flight/OpenPilot/System/inc/openpilot.h @@ -31,16 +31,13 @@ /* PIOS Includes */ #include -/* OpenPilot Includes */ -#include -#include - -/* UAVObjects */ +/* OpenPilot Libraries */ +#include "op_config.h" +#include "op_logging.h" +#include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" -#include "utlist.h" - -/* UAVTalk */ +#include "alarms.h" #include "uavtalk.h" /* Global Functions */ diff --git a/flight/OpenPilot/System/openpilot.c b/flight/OpenPilot/System/openpilot.c index 87b266ff4..7e2134951 100644 --- a/flight/OpenPilot/System/openpilot.c +++ b/flight/OpenPilot/System/openpilot.c @@ -59,8 +59,7 @@ void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value); int main() { /* NOTE: Do NOT modify the following start-up sequence */ - /* Any new initialization functions should be added in */ - /* OpenPilotInit() */ + /* Any new initialization functions should be added in OpenPilotInit() */ /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); @@ -95,64 +94,40 @@ void OpenPilotInit() /* SPI Init */ PIOS_SPI_Init(); - /* Enables the SDCard */ + /* Enable and mount the SDCard */ PIOS_SDCARD_Init(); - - /* Wait for SD card for ever */ - for(;;) - { - /* Check if we have an SD Card with the correct settings files on it */ - if(!PIOS_SDCARD_MountFS(0)) { - /* Found one without errors */ - break; - } - - /* SD Card not found, flash for 1 second */ - PIOS_LED_On(LED1); - PIOS_LED_On(LED2); - for(uint32_t i = 0; i < 10; i++) { - PIOS_LED_Toggle(LED2); - PIOS_DELAY_WaitmS(100); - } - } + PIOS_SDCARD_MountFS(0); /* Initialize UAVObject libraries */ EventDispatcherInitialize(); UAVObjInitialize(); UAVObjectsInitializeAll(); - /* Com ports init */ + /* Initialize the alarms library */ + AlarmsInitialize(); + + /* Initialize the PiOS library */ PIOS_COM_Init(); - - /* Initialise servo outputs */ PIOS_Servo_Init(); - - /* Analog to digital converter initialise */ PIOS_ADC_Init(); - PIOS_GPIO_Init(); - //PIOS_PPM_Init(); - PIOS_PWM_Init(); - PIOS_USB_Init(0); - PIOS_I2C_Init(); - PIOS_Servo_SetHz(50, 450); - /* Create a FreeRTOS task */ - //xTaskCreate(TaskTesting, (signed portCHAR *)"TaskTesting", configMINIMAL_STACK_SIZE , NULL, 4, NULL); - //xTaskCreate(TaskServos, (signed portCHAR *)"Servos", configMINIMAL_STACK_SIZE , NULL, 3, NULL); - //xTaskCreate(TaskSDCard, (signed portCHAR *)"SDCard", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 2), NULL); - /* Initialize modules */ TelemetryInitialize(); ExampleModPeriodicInitialize(); //ExampleModThreadInitialize(); //ExampleModEventInitialize(); GpsInitialize(); + + /* Create test tasks */ + //xTaskCreate(TaskTesting, (signed portCHAR *)"TaskTesting", configMINIMAL_STACK_SIZE , NULL, 4, NULL); + //xTaskCreate(TaskServos, (signed portCHAR *)"Servos", configMINIMAL_STACK_SIZE , NULL, 3, NULL); + //xTaskCreate(TaskSDCard, (signed portCHAR *)"SDCard", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 2), NULL); } static void TaskTesting(void *pvParameters) diff --git a/flight/OpenPilot/UAVObjects/eventdispatcher.c b/flight/OpenPilot/UAVObjects/eventdispatcher.c index 0d30fb5b7..5055134a6 100644 --- a/flight/OpenPilot/UAVObjects/eventdispatcher.c +++ b/flight/OpenPilot/UAVObjects/eventdispatcher.c @@ -60,6 +60,7 @@ static PeriodicObjectList* objList; static xQueueHandle queue; static xTaskHandle eventTaskHandle; static xSemaphoreHandle mutex; +static EventStats stats; // Private functions static int32_t processPeriodicUpdates(); @@ -74,8 +75,9 @@ static int32_t eventPeriodicUpdate(UAVObjEvent* ev, UAVObjEventCallback cb, xQue */ int32_t EventDispatcherInitialize() { - // Initialize list + // Initialize variables objList = NULL; + memset(&stats, 0, sizeof(EventStats)); // Create mutex mutex = xSemaphoreCreateRecursiveMutex(); @@ -92,6 +94,27 @@ int32_t EventDispatcherInitialize() return 0; } +/** + * Get the statistics counters + * @param[out] statsOut The statistics counters will be copied there + */ +void EventGetStats(EventStats* statsOut) +{ + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memcpy(statsOut, &stats, sizeof(EventStats)); + xSemaphoreGiveRecursive(mutex); +} + +/** + * Clear the statistics counters + */ +void EventClearStats() +{ + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memset(&stats, 0, sizeof(EventStats)); + xSemaphoreGiveRecursive(mutex); +} + /** * Dispatch an event by invoking the supplied callback. The function * returns imidiatelly, the callback is invoked from the event task. @@ -312,7 +335,10 @@ static int32_t processPeriodicUpdates() // Push event to queue, if one if ( objEntry->evInfo.queue != 0) { - xQueueSend(objEntry->evInfo.queue, &objEntry->evInfo.ev, 0); // do not block if queue is full + if ( xQueueSend(objEntry->evInfo.queue, &objEntry->evInfo.ev, 0) != pdTRUE ) // do not block if queue is full + { + ++stats.eventErrors; + } } } // Update minimum delay diff --git a/flight/OpenPilot/UAVObjects/exampleobject1.c b/flight/OpenPilot/UAVObjects/exampleobject1.c index ba7f8a283..669e673a2 100644 --- a/flight/OpenPilot/UAVObjects/exampleobject1.c +++ b/flight/OpenPilot/UAVObjects/exampleobject1.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "exampleobject1.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/exampleobject2.c b/flight/OpenPilot/UAVObjects/exampleobject2.c index 42ac90e25..5971febff 100644 --- a/flight/OpenPilot/UAVObjects/exampleobject2.c +++ b/flight/OpenPilot/UAVObjects/exampleobject2.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "exampleobject2.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/examplesettings.c b/flight/OpenPilot/UAVObjects/examplesettings.c index 216a2e073..a6c03370e 100644 --- a/flight/OpenPilot/UAVObjects/examplesettings.c +++ b/flight/OpenPilot/UAVObjects/examplesettings.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "examplesettings.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/flighttelemetrystats.c b/flight/OpenPilot/UAVObjects/flighttelemetrystats.c index 73ec9b2cc..697cd8e82 100644 --- a/flight/OpenPilot/UAVObjects/flighttelemetrystats.c +++ b/flight/OpenPilot/UAVObjects/flighttelemetrystats.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "flighttelemetrystats.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/gcstelemetrystats.c b/flight/OpenPilot/UAVObjects/gcstelemetrystats.c index def6ab824..4f57559fd 100644 --- a/flight/OpenPilot/UAVObjects/gcstelemetrystats.c +++ b/flight/OpenPilot/UAVObjects/gcstelemetrystats.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "gcstelemetrystats.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/gpsobject.c b/flight/OpenPilot/UAVObjects/gpsobject.c index 0e361af42..9cf437218 100644 --- a/flight/OpenPilot/UAVObjects/gpsobject.c +++ b/flight/OpenPilot/UAVObjects/gpsobject.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "gpsobject.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/inc/eventdispatcher.h b/flight/OpenPilot/UAVObjects/inc/eventdispatcher.h index af3f384ed..9e378b65a 100644 --- a/flight/OpenPilot/UAVObjects/inc/eventdispatcher.h +++ b/flight/OpenPilot/UAVObjects/inc/eventdispatcher.h @@ -27,9 +27,17 @@ #define EVENTDISPATCHER_H // Public types +/** + * Event dispatcher statistics + */ +typedef struct { + uint32_t eventErrors; +} EventStats; // Public functions int32_t EventDispatcherInitialize(); +void EventGetStats(EventStats* statsOut); +void EventClearStats(); int32_t EventCallbackDispatch(UAVObjEvent* ev, UAVObjEventCallback cb); int32_t EventPeriodicCallbackCreate(UAVObjEvent* ev, UAVObjEventCallback cb, int32_t periodMs); int32_t EventPeriodicCallbackUpdate(UAVObjEvent* ev, UAVObjEventCallback cb, int32_t periodMs); diff --git a/flight/OpenPilot/UAVObjects/inc/exampleobject1.h b/flight/OpenPilot/UAVObjects/inc/exampleobject1.h index fa7138813..e91b5c045 100644 --- a/flight/OpenPilot/UAVObjects/inc/exampleobject1.h +++ b/flight/OpenPilot/UAVObjects/inc/exampleobject1.h @@ -32,8 +32,6 @@ #ifndef EXAMPLEOBJECT1_H #define EXAMPLEOBJECT1_H -#include "openpilot.h" - // Object constants #define EXAMPLEOBJECT1_OBJID 3852936276U #define EXAMPLEOBJECT1_NAME "ExampleObject1" @@ -69,7 +67,17 @@ typedef struct { } __attribute__((packed)) ExampleObject1Data; -// Enumeration types +// Field information +// Field Field1 information +// Field Field2 information +// Field Field3 information +// Field Field4 information +/* Number of elements for field Field4 */ +#define EXAMPLEOBJECT1_FIELD4_NUMELEM 4 +// Field Field5 information +// Field Field6 information +// Field Field7 information +// Field Field8 information /* Enumeration options for field Field8 */ typedef enum { EXAMPLEOBJECT1_FIELD8_OPTION1=0, EXAMPLEOBJECT1_FIELD8_OPTION2=1, } ExampleObject1Field8Options; diff --git a/flight/OpenPilot/UAVObjects/inc/exampleobject2.h b/flight/OpenPilot/UAVObjects/inc/exampleobject2.h index 902767849..bea64b8f3 100644 --- a/flight/OpenPilot/UAVObjects/inc/exampleobject2.h +++ b/flight/OpenPilot/UAVObjects/inc/exampleobject2.h @@ -32,8 +32,6 @@ #ifndef EXAMPLEOBJECT2_H #define EXAMPLEOBJECT2_H -#include "openpilot.h" - // Object constants #define EXAMPLEOBJECT2_OBJID 2743296914U #define EXAMPLEOBJECT2_NAME "ExampleObject2" @@ -65,7 +63,13 @@ typedef struct { } __attribute__((packed)) ExampleObject2Data; -// Enumeration types +// Field information +// Field Field1 information +// Field Field2 information +// Field Field3 information +// Field Field4 information +/* Number of elements for field Field4 */ +#define EXAMPLEOBJECT2_FIELD4_NUMELEM 4 // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/examplesettings.h b/flight/OpenPilot/UAVObjects/inc/examplesettings.h index 081b7d6ba..466c65948 100644 --- a/flight/OpenPilot/UAVObjects/inc/examplesettings.h +++ b/flight/OpenPilot/UAVObjects/inc/examplesettings.h @@ -32,8 +32,6 @@ #ifndef EXAMPLESETTINGS_H #define EXAMPLESETTINGS_H -#include "openpilot.h" - // Object constants #define EXAMPLESETTINGS_OBJID 1640607828U #define EXAMPLESETTINGS_NAME "ExampleSettings" @@ -64,7 +62,10 @@ typedef struct { } __attribute__((packed)) ExampleSettingsData; -// Enumeration types +// Field information +// Field UpdatePeriod information +// Field StepSize information +// Field StepDirection information /* Enumeration options for field StepDirection */ typedef enum { EXAMPLESETTINGS_STEPDIRECTION_UP=0, EXAMPLESETTINGS_STEPDIRECTION_DOWN=1, } ExampleSettingsStepDirectionOptions; diff --git a/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h b/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h index b82189a5b..66e716db8 100644 --- a/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h +++ b/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h @@ -32,8 +32,6 @@ #ifndef FLIGHTTELEMETRYSTATS_H #define FLIGHTTELEMETRYSTATS_H -#include "openpilot.h" - // Object constants #define FLIGHTTELEMETRYSTATS_OBJID 766280320U #define FLIGHTTELEMETRYSTATS_NAME "FlightTelemetryStats" @@ -67,9 +65,15 @@ typedef struct { } __attribute__((packed)) FlightTelemetryStatsData; -// Enumeration types +// Field information +// Field Connected information /* Enumeration options for field Connected */ typedef enum { FLIGHTTELEMETRYSTATS_CONNECTED_TRUE=0, FLIGHTTELEMETRYSTATS_CONNECTED_FALSE=1, } FlightTelemetryStatsConnectedOptions; +// Field TxDataRate information +// Field RxDataRate information +// Field TxFailures information +// Field RxFailures information +// Field TxRetries information // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h b/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h index fbcf36763..5e3595fb7 100644 --- a/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h +++ b/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h @@ -32,8 +32,6 @@ #ifndef GCSTELEMETRYSTATS_H #define GCSTELEMETRYSTATS_H -#include "openpilot.h" - // Object constants #define GCSTELEMETRYSTATS_OBJID 607270704U #define GCSTELEMETRYSTATS_NAME "GCSTelemetryStats" @@ -67,9 +65,15 @@ typedef struct { } __attribute__((packed)) GCSTelemetryStatsData; -// Enumeration types +// Field information +// Field Connected information /* Enumeration options for field Connected */ typedef enum { GCSTELEMETRYSTATS_CONNECTED_TRUE=0, GCSTELEMETRYSTATS_CONNECTED_FALSE=1, } GCSTelemetryStatsConnectedOptions; +// Field TxDataRate information +// Field RxDataRate information +// Field TxFailures information +// Field RxFailures information +// Field TxRetries information // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/gpsobject.h b/flight/OpenPilot/UAVObjects/inc/gpsobject.h index 328934a8e..4a89436a7 100644 --- a/flight/OpenPilot/UAVObjects/inc/gpsobject.h +++ b/flight/OpenPilot/UAVObjects/inc/gpsobject.h @@ -32,8 +32,6 @@ #ifndef GPSOBJECT_H #define GPSOBJECT_H -#include "openpilot.h" - // Object constants #define GPSOBJECT_OBJID 4217926642U #define GPSOBJECT_NAME "GpsObject" @@ -66,7 +64,12 @@ typedef struct { } __attribute__((packed)) GpsObjectData; -// Enumeration types +// Field information +// Field Latitude information +// Field Longitude information +// Field Altitude information +// Field Satellites information +// Field Updates information // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/settingspersistence.h b/flight/OpenPilot/UAVObjects/inc/settingspersistence.h index 90c79d8fb..bc9da2194 100644 --- a/flight/OpenPilot/UAVObjects/inc/settingspersistence.h +++ b/flight/OpenPilot/UAVObjects/inc/settingspersistence.h @@ -32,8 +32,6 @@ #ifndef SETTINGSPERSISTENCE_H #define SETTINGSPERSISTENCE_H -#include "openpilot.h" - // Object constants #define SETTINGSPERSISTENCE_OBJID 3652432370U #define SETTINGSPERSISTENCE_NAME "SettingsPersistence" @@ -62,7 +60,8 @@ typedef struct { } __attribute__((packed)) SettingsPersistenceData; -// Enumeration types +// Field information +// Field Operation information /* Enumeration options for field Operation */ typedef enum { SETTINGSPERSISTENCE_OPERATION_LOAD=0, SETTINGSPERSISTENCE_OPERATION_SAVE=1, } SettingsPersistenceOperationOptions; diff --git a/flight/OpenPilot/UAVObjects/inc/systemalarms.h b/flight/OpenPilot/UAVObjects/inc/systemalarms.h index b89968a48..286b465ef 100644 --- a/flight/OpenPilot/UAVObjects/inc/systemalarms.h +++ b/flight/OpenPilot/UAVObjects/inc/systemalarms.h @@ -32,10 +32,8 @@ #ifndef SYSTEMALARMS_H #define SYSTEMALARMS_H -#include "openpilot.h" - // Object constants -#define SYSTEMALARMS_OBJID 2311311912U +#define SYSTEMALARMS_OBJID 2311311458U #define SYSTEMALARMS_NAME "SystemAlarms" #define SYSTEMALARMS_ISSINGLEINST 1 #define SYSTEMALARMS_ISSETTINGS 0 @@ -58,15 +56,18 @@ // Object data typedef struct { - uint8_t Alarm[4]; + uint8_t Alarm[6]; } __attribute__((packed)) SystemAlarmsData; -// Enumeration types +// Field information +// Field Alarm information /* Enumeration options for field Alarm */ -typedef enum { SYSTEMALARMS_ALARM_NONE=0, SYSTEMALARMS_ALARM_WARNING=1, SYSTEMALARMS_ALARM_ERROR=2, SYSTEMALARMS_ALARM_CRITICAL=3, } SystemAlarmsAlarmOptions; +typedef enum { SYSTEMALARMS_ALARM_OK=0, SYSTEMALARMS_ALARM_WARNING=1, SYSTEMALARMS_ALARM_ERROR=2, SYSTEMALARMS_ALARM_CRITICAL=3, } SystemAlarmsAlarmOptions; /* Array element names for field Alarm */ -typedef enum { SYSTEMALARMS_ALARM_OUTOFMEMORY=0, SYSTEMALARMS_ALARM_STACKOVERFLOW=1, SYSTEMALARMS_ALARM_CPUOVERLOAD=2, SYSTEMALARMS_ALARM_EVENTSYSTEM=3, } SystemAlarmsAlarmElem; +typedef enum { SYSTEMALARMS_ALARM_OUTOFMEMORY=0, SYSTEMALARMS_ALARM_STACKOVERFLOW=1, SYSTEMALARMS_ALARM_CPUOVERLOAD=2, SYSTEMALARMS_ALARM_EVENTSYSTEM=3, SYSTEMALARMS_ALARM_SDCARD=4, SYSTEMALARMS_ALARM_TELEMETRY=5, } SystemAlarmsAlarmElem; +/* Number of elements for field Alarm */ +#define SYSTEMALARMS_ALARM_NUMELEM 6 // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/systemstats.h b/flight/OpenPilot/UAVObjects/inc/systemstats.h index 2edc0d894..59bed9c2f 100644 --- a/flight/OpenPilot/UAVObjects/inc/systemstats.h +++ b/flight/OpenPilot/UAVObjects/inc/systemstats.h @@ -32,8 +32,6 @@ #ifndef SYSTEMSTATS_H #define SYSTEMSTATS_H -#include "openpilot.h" - // Object constants #define SYSTEMSTATS_OBJID 680908530U #define SYSTEMSTATS_NAME "SystemStats" @@ -64,7 +62,10 @@ typedef struct { } __attribute__((packed)) SystemStatsData; -// Enumeration types +// Field information +// Field FlightTime information +// Field HeapRemaining information +// Field CPULoad information // Generic interface functions diff --git a/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h b/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h index b05be0987..afc0d7832 100644 --- a/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h +++ b/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h @@ -88,7 +88,16 @@ typedef struct { */ typedef void (*UAVObjEventCallback)(UAVObjEvent* ev); +/** + * Event manager statistics + */ +typedef struct { + uint32_t eventErrors; +} UAVObjStats; + int32_t UAVObjInitialize(); +void UAVObjGetStats(UAVObjStats* statsOut); +void UAVObjClearStats(); UAVObjHandle UAVObjRegister(uint32_t id, const char* name, int32_t isMetaobject, int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes); UAVObjHandle UAVObjGetByID(uint32_t id); diff --git a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h index 703ac6aee..ca62faf99 100644 --- a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h +++ b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h @@ -32,8 +32,6 @@ #ifndef $(NAMEUC)_H #define $(NAMEUC)_H -#include "openpilot.h" - // Object constants #define $(NAMEUC)_OBJID $(OBJID)U #define $(NAMEUC)_NAME "$(NAME)" @@ -61,8 +59,8 @@ typedef struct { $(DATAFIELDS) } __attribute__((packed)) $(NAME)Data; -// Enumeration types -$(DATAENUM) +// Field information +$(DATAFIELDINFO) // Generic interface functions int32_t $(NAME)Initialize(); diff --git a/flight/OpenPilot/UAVObjects/settingspersistence.c b/flight/OpenPilot/UAVObjects/settingspersistence.c index 11ac1fc22..3ae140721 100644 --- a/flight/OpenPilot/UAVObjects/settingspersistence.c +++ b/flight/OpenPilot/UAVObjects/settingspersistence.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "settingspersistence.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/systemalarms.c b/flight/OpenPilot/UAVObjects/systemalarms.c index c6294bf76..8cd09b3a4 100644 --- a/flight/OpenPilot/UAVObjects/systemalarms.c +++ b/flight/OpenPilot/UAVObjects/systemalarms.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "systemalarms.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/systemstats.c b/flight/OpenPilot/UAVObjects/systemstats.c index d854946ad..66b33e89c 100644 --- a/flight/OpenPilot/UAVObjects/systemstats.c +++ b/flight/OpenPilot/UAVObjects/systemstats.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "systemstats.h" // Private variables diff --git a/flight/OpenPilot/UAVObjects/uavobjectmanager.c b/flight/OpenPilot/UAVObjects/uavobjectmanager.c index 64cbcd44e..856cb9a1a 100644 --- a/flight/OpenPilot/UAVObjects/uavobjectmanager.c +++ b/flight/OpenPilot/UAVObjects/uavobjectmanager.c @@ -80,6 +80,7 @@ static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCa static ObjectList* objList; static xSemaphoreHandle mutex; static UAVObjMetadata defMetadata; +static UAVObjStats stats; /** * Initialize the object manager @@ -88,8 +89,9 @@ static UAVObjMetadata defMetadata; */ int32_t UAVObjInitialize() { - // Initialize object list + // Initialize variables objList = NULL; + memset(&stats, 0, sizeof(UAVObjStats)); // Create mutex mutex = xSemaphoreCreateRecursiveMutex(); @@ -110,6 +112,27 @@ int32_t UAVObjInitialize() return 0; } +/** + * Get the statistics counters + * @param[out] statsOut The statistics counters will be copied there + */ +void UAVObjGetStats(UAVObjStats* statsOut) +{ + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memcpy(statsOut, &stats, sizeof(UAVObjStats)); + xSemaphoreGiveRecursive(mutex); +} + +/** + * Clear the statistics counters + */ +void UAVObjClearStats() +{ + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memset(&stats, 0, sizeof(UAVObjStats)); + xSemaphoreGiveRecursive(mutex); +} + /** * Register and new object in the object manager. * \param[in] id Unique object ID @@ -459,6 +482,12 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file) ObjectList* objEntry; ObjectInstList* instEntry; + // Check for file system availability + if ( POIS_SDCARD_IsMounted() == 0 ) + { + return -1; + } + // Lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); @@ -510,6 +539,12 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId) FILEINFO file; ObjectList* objEntry; + // Check for file system availability + if ( POIS_SDCARD_IsMounted() == 0 ) + { + return -1; + } + // Lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); @@ -551,6 +586,12 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO* file) uint16_t instId; UAVObjHandle obj; + // Check for file system availability + if ( POIS_SDCARD_IsMounted() == 0 ) + { + return -1; + } + // Lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); @@ -626,6 +667,12 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId) UAVObjHandle loadedObj; ObjectList* loadedObjEntry; + // Check for file system availability + if ( POIS_SDCARD_IsMounted() == 0 ) + { + return -1; + } + // Lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); @@ -983,7 +1030,7 @@ void UAVObjUpdated(UAVObjHandle obj) void UAVObjInstanceUpdated(UAVObjHandle obj, uint16_t instId) { xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - sendEvent((ObjectList*)obj, instId, EV_UPDATED); + sendEvent((ObjectList*)obj, instId, EV_UPDATED_MANUAL); xSemaphoreGiveRecursive(mutex); } @@ -1030,12 +1077,18 @@ static int32_t sendEvent(ObjectList* obj, uint16_t instId, UAVObjEventType event // Send to queue if a valid queue is registered if (eventEntry->queue != 0) { - xQueueSend(eventEntry->queue, &msg, 0); // do not wait if queue is full + if ( xQueueSend(eventEntry->queue, &msg, 0) != pdTRUE ) // will not block + { + ++stats.eventErrors; + } } // Invoke callback (from event task) if a valid one is registered if (eventEntry->cb != 0) { - EventCallbackDispatch(&msg, eventEntry->cb); // invoke callback from the event task + if ( EventCallbackDispatch(&msg, eventEntry->cb) != pdTRUE ) // invoke callback from the event task, will not block + { + ++stats.eventErrors; + } } } } diff --git a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c index 62d6c8082..620e63113 100644 --- a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c +++ b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c @@ -29,6 +29,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "openpilot.h" #include "$(NAMELC).h" // Private variables diff --git a/flight/PiOS/Common/pios_sdcard.c b/flight/PiOS/Common/pios_sdcard.c index 4f0d1b562..b865893d5 100644 --- a/flight/PiOS/Common/pios_sdcard.c +++ b/flight/PiOS/Common/pios_sdcard.c @@ -87,6 +87,7 @@ uint8_t PIOS_SDCARD_Sector[SECTOR_SIZE]; #define CT_SDC (CT_SD1|CT_SD2) #define CT_BLOCK 0x08 static uint8_t CardType; +static int32_t sdcard_mounted; /** * Initialises SPI pins and peripheral to access MMC/SD Card @@ -96,6 +97,9 @@ static uint8_t CardType; int32_t PIOS_SDCARD_Init(void) { SDCARD_MUTEX_TAKE; + + sdcard_mounted = 0; + /* Ensure that fast pin drivers are activated */ PIOS_SPI_IO_Init(PIOS_SDCARD_SPI, PIOS_SPI_PIN_DRIVER_STRONG); @@ -804,6 +808,16 @@ int32_t PIOS_SDCARD_StartupLog(void) return 0; } +/** + * Check if the SD card has been mounted + * @return 0 if no + * @return 1 if yes + */ +int32_t POIS_SDCARD_IsMounted() +{ + return sdcard_mounted; +} + /** * Mounts the file system * param[in] CreateStartupLog 1 = True, 0 = False @@ -845,6 +859,7 @@ int32_t PIOS_SDCARD_MountFS(uint32_t CreateStartupLog) } /* No errors */ + sdcard_mounted = 1; return 0; } diff --git a/flight/PiOS/inc/FreeRTOSConfig.h b/flight/PiOS/inc/FreeRTOSConfig.h index 4f6fe703f..78045f8c4 100644 --- a/flight/PiOS/inc/FreeRTOSConfig.h +++ b/flight/PiOS/inc/FreeRTOSConfig.h @@ -32,7 +32,7 @@ #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_COUNTING_SEMAPHORES 0 #define configUSE_ALTERNATIVE_API 0 -#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 #define configQUEUE_REGISTRY_SIZE 10 diff --git a/flight/PiOS/inc/pios_sdcard.h b/flight/PiOS/inc/pios_sdcard.h index 286a4e2d4..3ef78dd7e 100644 --- a/flight/PiOS/inc/pios_sdcard.h +++ b/flight/PiOS/inc/pios_sdcard.h @@ -99,6 +99,7 @@ extern int32_t PIOS_SDCARD_CIDRead(SDCARDCidTypeDef *cid); extern int32_t PIOS_SDCARD_CSDRead(SDCARDCsdTypeDef *csd); extern int32_t PIOS_SDCARD_StartupLog(void); +extern int32_t POIS_SDCARD_IsMounted(); extern int32_t PIOS_SDCARD_MountFS(uint32_t StartupLog); extern int32_t PIOS_SDCARD_GetFree(void);