From ed11e64bb2f9a64ac0191d04785939ee125c72f6 Mon Sep 17 00:00:00 2001 From: peabody124 Date: Mon, 10 Jan 2011 00:16:30 +0000 Subject: [PATCH] OP-251 Watchdog: Get rid of the old extra watchdog module and instead have tasks directly update a flag for each module (which they register) and when all flags set clear the watchdog then. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2365 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Makefile | 3 +- .../OpenPilot/Modules/AHRSComms/ahrs_comms.c | 6 +- flight/OpenPilot/Modules/Actuator/actuator.c | 8 +- .../Modules/ManualControl/manualcontrol.c | 8 +- .../Modules/Stabilization/stabilization.c | 9 +- flight/OpenPilot/Modules/System/systemmod.c | 11 +++ .../OpenPilot/Modules/Watchdog/inc/watchdog.h | 33 ------- flight/OpenPilot/Modules/Watchdog/watchdog.c | 99 ------------------- flight/OpenPilot/System/inc/pios_config.h | 3 +- flight/OpenPilot/System/pios_board.c | 1 + flight/OpenPilot/UAVObjects/uavobjectsinit.c | 2 + flight/PiOS/Boards/STM3210E_OP.h | 10 ++ flight/PiOS/STM32F10x/pios_wdg.c | 98 +++++++++++++++++- flight/PiOS/inc/pios_wdg.h | 6 +- .../OpenPilotOSX.xcodeproj/project.pbxproj | 26 ++--- ground/src/plugins/uavobjects/OPLogConvert.m | 25 ++++- ground/src/plugins/uavobjects/uavobjects.pro | 7 +- .../src/plugins/uavobjects/uavobjectsinit.cpp | 2 + 18 files changed, 175 insertions(+), 182 deletions(-) delete mode 100644 flight/OpenPilot/Modules/Watchdog/inc/watchdog.h delete mode 100644 flight/OpenPilot/Modules/Watchdog/watchdog.c diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 308a64680..d90010a51 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -57,7 +57,7 @@ FLASH_TOOL = OPENOCD USE_THUMB_MODE = YES # List of modules to include -MODULES = Actuator Telemetry GPS ManualControl Altitude AHRSComms Stabilization Guidance Watchdog FirmwareIAP +MODULES = Actuator Telemetry GPS ManualControl Altitude AHRSComms Stabilization Guidance FirmwareIAP #MODULES = Telemetry Example #MODULES = Telemetry MK/MKSerial @@ -201,6 +201,7 @@ SRC += $(OPUAVOBJ)/flightplancontrol.c SRC += $(OPUAVOBJ)/flightplanstatus.c SRC += $(OPUAVOBJ)/flightplansettings.c SRC += $(OPUAVOBJ)/taskinfo.c +SRC += $(OPUAVOBJ)/watchdogstatus.c endif ## PIOS Hardware (STM32F10x) diff --git a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c index 0546b8d23..b9784b7c7 100644 --- a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c +++ b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c @@ -65,9 +65,6 @@ static xTaskHandle taskHandle; // Private functions static void ahrscommsTask(void *parameters); -// Global update flag -volatile uint8_t ahrs_updated; - /** * Initialise the module, called on startup * \returns 0 on success or -1 if initialisation failed @@ -79,6 +76,7 @@ int32_t AHRSCommsInitialize(void) // Start main task xTaskCreate(ahrscommsTask, (signed char *)"AHRSComms", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle); TaskMonitorAdd(TASKINFO_RUNNING_AHRSCOMMS, taskHandle); + PIOS_WDG_RegisterFlag(PIOS_WDG_AHRS); return 0; } @@ -94,7 +92,7 @@ static void ahrscommsTask(void *parameters) // Main task loop while (1) { - ahrs_updated = 1; + PIOS_WDG_UpdateFlag(PIOS_WDG_AHRS); AHRSSettingsData settings; AHRSSettingsGet(&settings); diff --git a/flight/OpenPilot/Modules/Actuator/actuator.c b/flight/OpenPilot/Modules/Actuator/actuator.c index 0ea6d1835..841d670fe 100644 --- a/flight/OpenPilot/Modules/Actuator/actuator.c +++ b/flight/OpenPilot/Modules/Actuator/actuator.c @@ -71,9 +71,6 @@ float ProcessMixer(const int index, const float curve1, const float curve2, MixerSettingsData* mixerSettings, ActuatorDesiredData* desired, const float period); -// External watchdog update flag -volatile uint8_t actuator_updated; - //this structure is equivalent to the UAVObjects for one mixer. typedef struct { uint8_t type; @@ -96,7 +93,8 @@ int32_t ActuatorInitialize() // Start main task xTaskCreate(actuatorTask, (signed char*)"Actuator", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle); TaskMonitorAdd(TASKINFO_RUNNING_ACTUATOR, taskHandle); - + PIOS_WDG_RegisterFlag(PIOS_WDG_ACTUATOR); + return 0; } @@ -143,7 +141,7 @@ static void actuatorTask(void* parameters) lastSysTime = xTaskGetTickCount(); while (1) { - actuator_updated = 1; + PIOS_WDG_UpdateFlag(PIOS_WDG_ACTUATOR); // Wait until the ActuatorDesired object is updated, if a timeout then go to failsafe if ( xQueueReceive(queue, &ev, FAILSAFE_TIMEOUT_MS / portTICK_RATE_MS) != pdTRUE ) diff --git a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c index 28604172a..7bc1d583a 100644 --- a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c +++ b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c @@ -63,9 +63,6 @@ static void manualControlTask(void *parameters); static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutral); static uint32_t timeDifferenceMs(portTickType start_time, portTickType end_time); -// Global updated variable -volatile uint8_t manual_updated; - /** * Module initialization */ @@ -74,7 +71,7 @@ int32_t ManualControlInitialize() // Start main task xTaskCreate(manualControlTask, (signed char *)"ManualControl", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle); TaskMonitorAdd(TASKINFO_RUNNING_MANUALCONTROL, taskHandle); - + PIOS_WDG_RegisterFlag(PIOS_WDG_MANUAL); return 0; } @@ -109,8 +106,7 @@ static void manualControlTask(void *parameters) while (1) { // Wait until next update vTaskDelayUntil(&lastSysTime, UPDATE_PERIOD_MS / portTICK_RATE_MS); - - manual_updated = 1; + PIOS_WDG_UpdateFlag(PIOS_WDG_MANUAL); // Read settings ManualControlSettingsGet(&settings); diff --git a/flight/OpenPilot/Modules/Stabilization/stabilization.c b/flight/OpenPilot/Modules/Stabilization/stabilization.c index 528a1c244..868aaf235 100644 --- a/flight/OpenPilot/Modules/Stabilization/stabilization.c +++ b/flight/OpenPilot/Modules/Stabilization/stabilization.c @@ -78,9 +78,6 @@ static float bound(float val); static void ZeroPids(void); static void SettingsUpdatedCb(UAVObjEvent * ev); -// Global updated variable -volatile uint8_t stabilization_updated; - /** * Module initialization */ @@ -100,7 +97,8 @@ int32_t StabilizationInitialize() // Start main task xTaskCreate(stabilizationTask, (signed char*)"Stabilization", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle); TaskMonitorAdd(TASKINFO_RUNNING_STABILIZATION, taskHandle); - + PIOS_WDG_RegisterFlag(PIOS_WDG_STABILIZATION); + return 0; } @@ -128,9 +126,8 @@ static void stabilizationTask(void* parameters) lastSysTime = xTaskGetTickCount(); ZeroPids(); while(1) { + PIOS_WDG_UpdateFlag(PIOS_WDG_STABILIZATION); - stabilization_updated = 1; - // Wait until the AttitudeRaw object is updated, if a timeout then go to failsafe if ( xQueueReceive(queue, &ev, FAILSAFE_TIMEOUT_MS / portTICK_RATE_MS) != pdTRUE ) { diff --git a/flight/OpenPilot/Modules/System/systemmod.c b/flight/OpenPilot/Modules/System/systemmod.c index 0249b4503..a381756dd 100644 --- a/flight/OpenPilot/Modules/System/systemmod.c +++ b/flight/OpenPilot/Modules/System/systemmod.c @@ -44,6 +44,7 @@ #include "manualcontrolcommand.h" #include "systemstats.h" #include "i2cstats.h" +#include "watchdogstatus.h" #include "taskmonitor.h" @@ -72,6 +73,7 @@ static int32_t stackOverflow; static void objectUpdatedCb(UAVObjEvent * ev); static void updateStats(); static void updateI2Cstats(); +static void updateWDGstats(); static void updateSystemAlarms(); static void systemTask(void *parameters); @@ -117,6 +119,7 @@ static void systemTask(void *parameters) // Update the system alarms updateSystemAlarms(); updateI2Cstats(); + updateWDGstats(); // Update the task status object TaskMonitorUpdateAll(); @@ -232,6 +235,14 @@ static void updateI2Cstats() } #endif +static void updateWDGstats() +{ + WatchdogStatusData watchdogStatus; + watchdogStatus.BootupFlags = PIOS_WDG_GetBootupFlags(); + watchdogStatus.ActiveFlags = PIOS_WDG_GetActiveFlags(); + WatchdogStatusSet(&watchdogStatus); +} + /** * Called periodically to update the system stats */ diff --git a/flight/OpenPilot/Modules/Watchdog/inc/watchdog.h b/flight/OpenPilot/Modules/Watchdog/inc/watchdog.h deleted file mode 100644 index 3f9c6b527..000000000 --- a/flight/OpenPilot/Modules/Watchdog/inc/watchdog.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - ****************************************************************************** - * - * @file watchdog.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Watchdog module which must run every 250 ms - * - * @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 WATCHDOG_H -#define WATCHDOG_H -extern volatile uint8_t actuator_updated; -extern volatile uint8_t stabilization_updated; -extern volatile uint8_t ahrs_updated; -extern volatile uint8_t manual_updated; -#endif /* WATCHDOG_H */ \ No newline at end of file diff --git a/flight/OpenPilot/Modules/Watchdog/watchdog.c b/flight/OpenPilot/Modules/Watchdog/watchdog.c deleted file mode 100644 index 52652db50..000000000 --- a/flight/OpenPilot/Modules/Watchdog/watchdog.c +++ /dev/null @@ -1,99 +0,0 @@ -/** - ****************************************************************************** - * - * @file watchdog.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Watchdog module which must run every 250 ms - * - * @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 - */ - -/** - * Input object: none - * Output object: none - * - * This module initializes the PIOS Watchdog and then periodically resets the timeout - * - * The module executes in its own thread in this example. - */ - -#include "openpilot.h" -#include "pios_wdg.h" -#include "watchdog.h" - -// Private constants -// TODO: Look up maximum task priority and set this to it. Not trying to replicate CPU load. -#define TASK_PRIORITY (tskIDLE_PRIORITY+5) -#define STACK_SIZE_BYTES 324 -#define WATCHDOG_TIMEOUT 250 - -// Private types - -// Private variables -static xTaskHandle taskHandle; - -// Private functions -static void watchdogTask(void *parameters); - - -/** - * Initialise the module, called on startup - * \returns 0 on success or -1 if initialisation failed - */ -int32_t WatchdogInitialize() -{ - actuator_updated = 0; - stabilization_updated = 0; - ahrs_updated = 0; - manual_updated = 0; - - // Start main task - xTaskCreate(watchdogTask, (signed char *)"Watchdog", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle); - TaskMonitorAdd(TASKINFO_RUNNING_WATCHDOG, taskHandle); - - return 0; -} - -/** - * @brief Module thread, should not return. - * - * Initializes the PIOS watchdog and periodically resets it - */ -static void watchdogTask(void *parameters) -{ - uint32_t delay; - portTickType lastSysTime; - - delay = PIOS_WDG_Init(WATCHDOG_TIMEOUT) / portTICK_RATE_MS; - - // Main task loop - lastSysTime = xTaskGetTickCount(); - while (1) { - if(actuator_updated && stabilization_updated && - ahrs_updated && manual_updated) { - PIOS_WDG_Clear(); - actuator_updated = 0; - stabilization_updated = 0; - ahrs_updated = 0; - manual_updated = 0; - } - - vTaskDelayUntil(&lastSysTime, delay); - } -} diff --git a/flight/OpenPilot/System/inc/pios_config.h b/flight/OpenPilot/System/inc/pios_config.h index b2d95d3f7..482895145 100644 --- a/flight/OpenPilot/System/inc/pios_config.h +++ b/flight/OpenPilot/System/inc/pios_config.h @@ -57,6 +57,7 @@ #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG /* Defaults for Logging */ @@ -78,4 +79,4 @@ /** * @} * @} - */ + */ diff --git a/flight/OpenPilot/System/pios_board.c b/flight/OpenPilot/System/pios_board.c index dfa1ffa46..dd8f11682 100644 --- a/flight/OpenPilot/System/pios_board.c +++ b/flight/OpenPilot/System/pios_board.c @@ -83,6 +83,7 @@ void PIOS_Board_Init(void) { #endif PIOS_I2C_Init(); PIOS_IAP_Init(); + PIOS_WDG_Init(); } /* MicroSD Interface diff --git a/flight/OpenPilot/UAVObjects/uavobjectsinit.c b/flight/OpenPilot/UAVObjects/uavobjectsinit.c index e12e2294d..de16429e3 100644 --- a/flight/OpenPilot/UAVObjects/uavobjectsinit.c +++ b/flight/OpenPilot/UAVObjects/uavobjectsinit.c @@ -70,6 +70,7 @@ #include "telemetrysettings.h" #include "velocityactual.h" #include "velocitydesired.h" +#include "watchdogstatus.h" /** @@ -120,5 +121,6 @@ void UAVObjectsInitializeAll() TelemetrySettingsInitialize(); VelocityActualInitialize(); VelocityDesiredInitialize(); + WatchdogStatusInitialize(); } diff --git a/flight/PiOS/Boards/STM3210E_OP.h b/flight/PiOS/Boards/STM3210E_OP.h index be6727f5b..74fdd7eec 100644 --- a/flight/PiOS/Boards/STM3210E_OP.h +++ b/flight/PiOS/Boards/STM3210E_OP.h @@ -86,6 +86,16 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8 #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 +//------------------------ +// WATCHDOG_SETTINGS +//------------------------ +#define PIOS_WATCHDOG_TIMEOUT 250 +#define PIOS_WDG_REGISTER BKP_DR4 +#define PIOS_WDG_ACTUATOR 0x0001 +#define PIOS_WDG_STABILIZATION 0x0002 +#define PIOS_WDG_AHRS 0x0004 +#define PIOS_WDG_MANUAL 0x0008 + //------------------------ // PIOS_LED //------------------------ diff --git a/flight/PiOS/STM32F10x/pios_wdg.c b/flight/PiOS/STM32F10x/pios_wdg.c index 6af39e5e9..28cb3753c 100644 --- a/flight/PiOS/STM32F10x/pios_wdg.c +++ b/flight/PiOS/STM32F10x/pios_wdg.c @@ -36,6 +36,11 @@ #include "stm32f10x_iwdg.h" #include "stm32f10x_dbgmcu.h" +static struct wdg_configuration { + uint16_t used_flags; + uint16_t bootup_flags; +} wdg_configuration; + /** * @brief Initialize the watchdog timer for a specified timeout * @@ -53,9 +58,10 @@ * @param[in] delayMs The delay period in ms * @returns Maximum recommended delay between updates */ -uint16_t PIOS_WDG_Init(uint16_t delayMs) +void PIOS_WDG_Init() { - uint16_t delay = ((uint32_t) delayMs * 60) / 16; +#if defined(PIOS_INCLUDE_WDG) + uint16_t delay = ((uint32_t) PIOS_WATCHDOG_TIMEOUT * 60) / 16; if (delay > 0x0fff) delay = 0x0fff; @@ -66,7 +72,91 @@ uint16_t PIOS_WDG_Init(uint16_t delayMs) IWDG_ReloadCounter(); IWDG_Enable(); - return ((((uint32_t) delay * 16) / 60) * .75f); + // watchdog flags now stored in backup registers + PWR_BackupAccessCmd(ENABLE); + + wdg_configuration.bootup_flags = BKP_ReadBackupRegister(PIOS_WDG_REGISTER); +#endif +} + +/** + * @brief Register a module against the watchdog + * + * There are two ways to use PIOS WDG: this is for when + * multiple modules must be monitored. In this case they + * must first register against the watchdog system and + * only when all of the modules have been updated with the + * watchdog be cleared. Each module must have its own + * bit in the 16 bit + * + * @param[in] flag the bit this module wants to use + * @returns True if that bit is unregistered + */ +bool PIOS_WDG_RegisterFlag(uint16_t flag_requested) +{ + + /* Fail if flag already registered */ + if(wdg_configuration.used_flags & flag_requested) + return false; + + // FIXME: Protect with semaphore + wdg_configuration.used_flags |= flag_requested; + + return true; +} + +/** + * @brief Function called by modules to indicate they are still running + * + * This function will set this flag in the active flags register (which is + * a backup regsiter) and if all the registered flags are set will clear + * the watchdog and set only this flag in the backup register + * + * @param[in] flag the flag to set + * @return true if the watchdog cleared, false if flags are pending + */ +bool PIOS_WDG_UpdateFlag(uint16_t flag) +{ + // we can probably avoid using a semaphore here which will be good for + // efficiency and not blocking critical tasks. race condition could + // overwrite their flag update, but unlikely to block _all_ of them + // for the timeout window + uint16_t cur_flags = BKP_ReadBackupRegister(PIOS_WDG_REGISTER); + + if((cur_flags | flag) == wdg_configuration.used_flags) { + PIOS_WDG_Clear(); + BKP_WriteBackupRegister(PIOS_WDG_REGISTER, flag); + return true; + } else { + BKP_WriteBackupRegister(PIOS_WDG_REGISTER, cur_flags | flag); + return false; + } + +} + +/** + * @brief Returns the flags that were set at bootup + * + * This is used for diagnostics, if only one flag not set this + * was likely the module that wasn't running before reset + * + * @return The active flags register from bootup + */ +uint16_t PIOS_WDG_GetBootupFlags() +{ + return wdg_configuration.bootup_flags; +} + +/** + * @brief Returns the currently active flags + * + * For external monitoring + * + * @return The active flags register + */ +uint16_t PIOS_WDG_GetActiveFlags() +{ + return BKP_ReadBackupRegister(PIOS_WDG_REGISTER); } /** @@ -76,5 +166,7 @@ uint16_t PIOS_WDG_Init(uint16_t delayMs) */ void PIOS_WDG_Clear(void) { +#if defined(PIOS_INCLUDE_WDG) IWDG_ReloadCounter(); +#endif } diff --git a/flight/PiOS/inc/pios_wdg.h b/flight/PiOS/inc/pios_wdg.h index 03f35d08a..47662624f 100644 --- a/flight/PiOS/inc/pios_wdg.h +++ b/flight/PiOS/inc/pios_wdg.h @@ -31,7 +31,11 @@ #ifndef PIOS_WDG #define PIOS_WDG -uint16_t PIOS_WDG_Init(uint16_t delayMs); +void PIOS_WDG_Init(); +bool PIOS_WDG_RegisterFlag(uint16_t flag_requested); +bool PIOS_WDG_UpdateFlag(uint16_t flag); +uint16_t PIOS_WDG_GetBootupFlags(); +uint16_t PIOS_WDG_GetActiveFlags(); void PIOS_WDG_Clear(void); #endif diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index 57b4b01df..e72a3a245 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -7,8 +7,6 @@ objects = { /* Begin PBXFileReference section */ - 65003B2D1212499100C183DD /* watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = watchdog.h; sourceTree = ""; }; - 65003B2E1212499100C183DD /* watchdog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = watchdog.c; sourceTree = ""; }; 65003B31121249CA00C183DD /* pios_wdg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_wdg.c; sourceTree = ""; }; 6502584212CA4D2600583CDF /* insgps13state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps13state.c; path = ../../AHRS/insgps13state.c; sourceTree = SOURCE_ROOT; }; 6509C7E912CA57DC002E5DC2 /* insgps16state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps16state.c; path = ../../AHRS/insgps16state.c; sourceTree = SOURCE_ROOT; }; @@ -43,6 +41,9 @@ 6549E0D21279B3C800C5476F /* fifo_buffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fifo_buffer.c; sourceTree = ""; }; 6549E0D31279B3CF00C5476F /* fifo_buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fifo_buffer.h; sourceTree = ""; }; 655268BC121FBD2900410C6E /* ahrscalibration.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ahrscalibration.xml; sourceTree = ""; }; + 655DBA5212DA5B6A00341B9A /* pios_iap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_iap.h; sourceTree = ""; }; + 655DBA5312DA5E9900341B9A /* watchdogstatus.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = watchdogstatus.xml; sourceTree = ""; }; + 655DBA8A12DA644300341B9A /* taskmonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = taskmonitor.c; sourceTree = ""; }; 65632CBF124E09D900469B77 /* guidance.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = guidance.c; sourceTree = ""; }; 65632CC1124E09D900469B77 /* guidance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = guidance.h; sourceTree = ""; }; 65632DF51251650300469B77 /* pios_board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_board.h; sourceTree = ""; }; @@ -2903,23 +2904,6 @@ name = Products; sourceTree = ""; }; - 65003B2B1212499100C183DD /* Watchdog */ = { - isa = PBXGroup; - children = ( - 65003B2C1212499100C183DD /* inc */, - 65003B2E1212499100C183DD /* watchdog.c */, - ); - path = Watchdog; - sourceTree = ""; - }; - 65003B2C1212499100C183DD /* inc */ = { - isa = PBXGroup; - children = ( - 65003B2D1212499100C183DD /* watchdog.h */, - ); - path = inc; - sourceTree = ""; - }; 651F32EC1281DE7E00D065F8 /* FirmwareIAP */ = { isa = PBXGroup; children = ( @@ -6802,6 +6786,7 @@ 65B367FD121C2620003EAD18 /* systemstats.xml */, 65B367FE121C2620003EAD18 /* telemetrysettings.xml */, 65408AA812BB1648004DACC5 /* i2cstats.xml */, + 655DBA5312DA5E9900341B9A /* watchdogstatus.xml */, ); path = uavobjectdefinition; sourceTree = ""; @@ -6869,7 +6854,6 @@ 65E8EF4F11EEA61E00BBF654 /* Stabilization */, 65E8EF5311EEA61E00BBF654 /* System */, 65E8EF5711EEA61E00BBF654 /* Telemetry */, - 65003B2B1212499100C183DD /* Watchdog */, ); name = Modules; path = ../../OpenPilot/Modules; @@ -7129,6 +7113,7 @@ 65E8EF5B11EEA61E00BBF654 /* System */ = { isa = PBXGroup; children = ( + 655DBA8A12DA644300341B9A /* taskmonitor.c */, 65E8EF5C11EEA61E00BBF654 /* alarms.c */, 65E8EF5D11EEA61E00BBF654 /* inc */, 65E8EF6511EEA61E00BBF654 /* openpilot.c */, @@ -7313,6 +7298,7 @@ 65E8F03811EFF25C00BBF654 /* inc */ = { isa = PBXGroup; children = ( + 655DBA5212DA5B6A00341B9A /* pios_iap.h */, 6526645A122DF972006F9A3C /* pios_i2c_priv.h */, 6526645B122DF972006F9A3C /* pios_wdg.h */, 651CF9EF120B700D00EEFD70 /* pios_usb_hid_desc.h */, diff --git a/ground/src/plugins/uavobjects/OPLogConvert.m b/ground/src/plugins/uavobjects/OPLogConvert.m index 0ff341ca2..da4eaf53f 100644 --- a/ground/src/plugins/uavobjects/OPLogConvert.m +++ b/ground/src/plugins/uavobjects/OPLogConvert.m @@ -413,6 +413,11 @@ function [] = OPLogConvert() VelocityDesired(1).East = 0; VelocityDesired(1).Down = 0; + watchdogstatusIdx = 1; + WatchdogStatus.timestamp = 0; + WatchdogStatus(1).BootupFlags = 0; + WatchdogStatus(1).ActiveFlags = 0; + %% Open file %fid = fopen('log.opl'); @@ -574,6 +579,9 @@ function [] = OPLogConvert() case 305094202 VelocityDesired(velocitydesiredIdx) = ReadVelocityDesiredObject(fid, timestamp); velocitydesiredIdx = velocitydesiredIdx + 1; + case 3594971408 + WatchdogStatus(watchdogstatusIdx) = ReadWatchdogStatusObject(fid, timestamp); + watchdogstatusIdx = watchdogstatusIdx + 1; otherwise disp('Unknown object ID'); @@ -587,7 +595,7 @@ function [] = OPLogConvert() fclose(fid); matfile = strrep(logfile,'opl','mat'); - save(matfile ,'ActuatorCommand','ActuatorDesired','ActuatorSettings','AHRSCalibration','AHRSSettings','AhrsStatus','AttitudeActual','AttitudeDesired','AttitudeRaw','BaroAltitude','BatterySettings','FirmwareIAPObj','FlightBatteryState','FlightPlanControl','FlightPlanSettings','FlightPlanStatus','FlightTelemetryStats','GCSTelemetryStats','GPSPosition','GPSSatellites','GPSTime','GuidanceSettings','HomeLocation','I2CStats','ManualControlCommand','ManualControlSettings','MixerSettings','MixerStatus','ObjectPersistence','PipXtremeModemSettings','PipXtremeModemStatus','PositionActual','PositionDesired','RateDesired','StabilizationSettings','SystemAlarms','SystemSettings','SystemStats','TaskInfo','TelemetrySettings','VelocityActual','VelocityDesired'); + save(matfile ,'ActuatorCommand','ActuatorDesired','ActuatorSettings','AHRSCalibration','AHRSSettings','AhrsStatus','AttitudeActual','AttitudeDesired','AttitudeRaw','BaroAltitude','BatterySettings','FirmwareIAPObj','FlightBatteryState','FlightPlanControl','FlightPlanSettings','FlightPlanStatus','FlightTelemetryStats','GCSTelemetryStats','GPSPosition','GPSSatellites','GPSTime','GuidanceSettings','HomeLocation','I2CStats','ManualControlCommand','ManualControlSettings','MixerSettings','MixerStatus','ObjectPersistence','PipXtremeModemSettings','PipXtremeModemStatus','PositionActual','PositionDesired','RateDesired','StabilizationSettings','SystemAlarms','SystemSettings','SystemStats','TaskInfo','TelemetrySettings','VelocityActual','VelocityDesired','WatchdogStatus'); end @@ -1425,6 +1433,21 @@ function [VelocityDesired] = ReadVelocityDesiredObject(fid, timestamp) fread(fid, 1, 'uint8'); end +function [WatchdogStatus] = ReadWatchdogStatusObject(fid, timestamp) + if 1 + headerSize = 8; + else + WatchdogStatus.instanceID = fread(fid, 1, 'uint16'); + headerSize = 10; + end + + WatchdogStatus.timestamp = timestamp; + WatchdogStatus.BootupFlags = double(fread(fid, 1, 'uint16')); + WatchdogStatus.ActiveFlags = double(fread(fid, 1, 'uint16')); + % read CRC + fread(fid, 1, 'uint8'); +end + diff --git a/ground/src/plugins/uavobjects/uavobjects.pro b/ground/src/plugins/uavobjects/uavobjects.pro index c62828c70..b19e12313 100644 --- a/ground/src/plugins/uavobjects/uavobjects.pro +++ b/ground/src/plugins/uavobjects/uavobjects.pro @@ -52,7 +52,8 @@ HEADERS += uavobjects_global.h \ taskinfo.h \ flightplanstatus.h \ flightplansettings.h \ - flightplancontrol.h + flightplancontrol.h \ + watchdogstatus.h SOURCES += uavobject.cpp \ uavmetaobject.cpp \ @@ -102,5 +103,7 @@ SOURCES += uavobject.cpp \ taskinfo.cpp \ flightplanstatus.cpp \ flightplansettings.cpp \ - flightplancontrol.cpp + flightplancontrol.cpp \ + watchdogstatus.cpp + OTHER_FILES += UAVObjects.pluginspec diff --git a/ground/src/plugins/uavobjects/uavobjectsinit.cpp b/ground/src/plugins/uavobjects/uavobjectsinit.cpp index 872934093..c914177fd 100644 --- a/ground/src/plugins/uavobjects/uavobjectsinit.cpp +++ b/ground/src/plugins/uavobjects/uavobjectsinit.cpp @@ -72,6 +72,7 @@ #include "telemetrysettings.h" #include "velocityactual.h" #include "velocitydesired.h" +#include "watchdogstatus.h" /** @@ -122,5 +123,6 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr) objMngr->registerObject( new TelemetrySettings() ); objMngr->registerObject( new VelocityActual() ); objMngr->registerObject( new VelocityDesired() ); + objMngr->registerObject( new WatchdogStatus() ); }