1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-936: Moves the task monitor code out of the flight library and into PiOS.

This move and rework also breaks the dependency of the task monitor on the UAVO subsystem,
and pushes the responsibility for updating the TaskInfo UAVO into the System module.

+review OPReview
This commit is contained in:
Richard Flay (Hyper) 2013-05-03 07:01:14 +09:30
parent 742058da8c
commit 84e1a81f8b
68 changed files with 493 additions and 325 deletions

View File

@ -1,44 +0,0 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @{
* @file taskmonitor.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Include file of the task monitoring 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 TASKMONITOR_H
#define TASKMONITOR_H
#include "taskinfo.h"
int32_t TaskMonitorInitialize(void);
int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle);
int32_t TaskMonitorRemove(TaskInfoRunningElem task);
bool TaskMonitorQueryRunning(TaskInfoRunningElem task);
void TaskMonitorUpdateAll(void);
#endif // TASKMONITOR_H
/**
* @}
* @}
*/

View File

@ -30,12 +30,12 @@
#include <pios_board_info.h>
// Private includes
#include "inc/taskmonitor.h"
#include "inc/sanitycheck.h"
// UAVOs
#include <manualcontrolsettings.h>
#include <systemsettings.h>
#include <taskinfo.h>
/****************************
* Current checks:
@ -103,28 +103,28 @@ int32_t configuration_check()
severity = (severity == SYSTEMALARMS_ALARM_OK) ? check_stabilization_settings(3, multirotor) : severity;
break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AUTOTUNE:
if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_AUTOTUNE)) {
if (!PIOS_TASK_MONITOR_IsRunning(TASKINFO_RUNNING_AUTOTUNE)) {
severity = SYSTEMALARMS_ALARM_ERROR;
}
break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ALTITUDEHOLD:
if (coptercontrol) {
severity = SYSTEMALARMS_ALARM_ERROR;
} else if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_ALTITUDEHOLD)) { // Revo supports altitude hold
} else if (!PIOS_TASK_MONITOR_IsRunning(TASKINFO_RUNNING_ALTITUDEHOLD)) { // Revo supports altitude hold
severity = SYSTEMALARMS_ALARM_ERROR;
}
break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_VELOCITYCONTROL:
if (coptercontrol) {
severity = SYSTEMALARMS_ALARM_ERROR;
} else if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_PATHFOLLOWER)) { // Revo supports altitude hold
} else if (!PIOS_TASK_MONITOR_IsRunning(TASKINFO_RUNNING_PATHFOLLOWER)) { // Revo supports altitude hold
severity = SYSTEMALARMS_ALARM_ERROR;
}
break;
case MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_POSITIONHOLD:
if (coptercontrol){
severity = SYSTEMALARMS_ALARM_ERROR;
} else if (!TaskMonitorQueryRunning(TASKINFO_RUNNING_PATHFOLLOWER)) { // Revo supports altitude hold
} else if (!PIOS_TASK_MONITOR_IsRunning(TASKINFO_RUNNING_PATHFOLLOWER)) { // Revo supports altitude hold
severity = SYSTEMALARMS_ALARM_ERROR;
}
break;

View File

@ -1,159 +0,0 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @{
* @file taskmonitor.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Task monitoring 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
*/
#include "openpilot.h"
//#include "taskmonitor.h"
// Private constants
// Private types
// Private variables
static xSemaphoreHandle lock;
static xTaskHandle handles[TASKINFO_RUNNING_NUMELEM];
static uint32_t lastMonitorTime;
// Private functions
/**
* Initialize library
*/
int32_t TaskMonitorInitialize(void)
{
lock = xSemaphoreCreateRecursiveMutex();
memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM);
lastMonitorTime = 0;
#ifdef DIAG_TASKS
lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
return 0;
}
/**
* Register a task handle with the library
*/
int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle)
{
if (task < TASKINFO_RUNNING_NUMELEM)
{
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
handles[task] = handle;
xSemaphoreGiveRecursive(lock);
return 0;
}
else
{
return -1;
}
}
/**
* Remove a task handle from the library
*/
int32_t TaskMonitorRemove(TaskInfoRunningElem task)
{
if (task < TASKINFO_RUNNING_NUMELEM)
{
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
handles[task] = 0;
xSemaphoreGiveRecursive(lock);
return 0;
}
else
{
return -1;
}
}
/**
* Query if a task is running
*/
bool TaskMonitorQueryRunning(TaskInfoRunningElem task)
{
if (task < TASKINFO_RUNNING_NUMELEM && handles[task] != 0)
return true;
return false;
}
/**
* Update the status of all tasks
*/
void TaskMonitorUpdateAll(void)
{
#ifdef DIAG_TASKS
TaskInfoData data;
int n;
// Lock
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
#if ( configGENERATE_RUN_TIME_STATS == 1 )
uint32_t currentTime;
uint32_t deltaTime;
/*
* Calculate the amount of elapsed run time between the last time we
* measured and now. Scale so that we can convert task run times
* directly to percentages.
*/
currentTime = portGET_RUN_TIME_COUNTER_VALUE();
deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */
lastMonitorTime = currentTime;
#endif
// Update all task information
for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n)
{
if (handles[n] != 0)
{
data.Running[n] = TASKINFO_RUNNING_TRUE;
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
data.StackRemaining[n] = 10000;
#else
data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4;
#endif
#if ( configGENERATE_RUN_TIME_STATS == 1 )
/* Generate run time stats */
data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;
#endif
}
else
{
data.Running[n] = TASKINFO_RUNNING_FALSE;
data.StackRemaining[n] = 0;
data.RunningTime[n] = 0;
}
}
// Update object
TaskInfoSet(&data);
// Done
xSemaphoreGiveRecursive(lock);
#endif
}

View File

@ -31,7 +31,8 @@
*/
#include "openpilot.h"
#include <openpilot.h>
#include "accessorydesired.h"
#include "actuator.h"
#include "actuatorsettings.h"
@ -43,6 +44,7 @@
#include "mixerstatus.h"
#include "cameradesired.h"
#include "manualcontrolcommand.h"
#include "taskinfo.h"
// Private constants
#define MAX_QUEUE_SIZE 2
@ -100,7 +102,7 @@ int32_t ActuatorStart()
{
// Start main task
xTaskCreate(actuatorTask, (signed char*)"Actuator", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ACTUATOR, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ACTUATOR, taskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_ACTUATOR);
return 0;

View File

@ -36,12 +36,14 @@
*
*/
#include "openpilot.h"
#include <openpilot.h>
#include "hwsettings.h"
#include "airspeedsettings.h"
#include "airspeedsensor.h" // object that will be updated by the module
#include "baro_airspeed_etasv3.h"
#include "baro_airspeed_mpxv.h"
#include "taskinfo.h"
// Private constants
@ -79,7 +81,7 @@ int32_t AirspeedStart()
// Start main task
xTaskCreate(airspeedTask, (signed char *)"Airspeed", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_AIRSPEED, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_AIRSPEED, taskHandle);
return 0;
}

View File

@ -36,13 +36,15 @@
*
*/
#include "openpilot.h"
#include <openpilot.h>
#include "hwsettings.h"
#include "altitude.h"
#include "baroaltitude.h" // object that will be updated by the module
#if defined(PIOS_INCLUDE_HCSR04)
#include "sonaraltitude.h" // object that will be updated by the module
#endif
#include "taskinfo.h"
// Private constants
#define STACK_SIZE_BYTES 500
@ -80,7 +82,7 @@ int32_t AltitudeStart()
// Start main task
xTaskCreate(altitudeTask, (signed char *)"Altitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ALTITUDE, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ALTITUDE, taskHandle);
return 0;
}
return -1;

View File

@ -36,12 +36,14 @@
*
*/
#include "openpilot.h"
#include <openpilot.h>
#include "altitude.h"
#include "baroaltitude.h" // object that will be updated by the module
#if defined(PIOS_INCLUDE_HCSR04)
#include "sonaraltitude.h" // object that will be updated by the module
#endif
#include "taskinfo.h"
// Private constants
#define STACK_SIZE_BYTES 500
@ -67,7 +69,7 @@ int32_t AltitudeStart()
// Start main task
xTaskCreate(altitudeTask, (signed char *)"Altitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ALTITUDE, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ALTITUDE, taskHandle);
return 0;
}

View File

@ -43,8 +43,8 @@
*
*/
#include "openpilot.h"
#include <math.h>
#include <openpilot.h>
#include "CoordinateConversions.h"
#include "altholdsmoothed.h"
#include "attitudeactual.h"
@ -55,6 +55,7 @@
#include "flightstatus.h"
#include "stabilizationdesired.h"
#include "accels.h"
#include "taskinfo.h"
// Private constants
#define MAX_QUEUE_SIZE 2
@ -80,7 +81,7 @@ int32_t AltitudeHoldStart()
{
// Start main task
xTaskCreate(altitudeHoldTask, (signed char *)"AltitudeHold", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &altitudeHoldTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ALTITUDEHOLD, altitudeHoldTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ALTITUDEHOLD, altitudeHoldTaskHandle);
return 0;
}

View File

@ -48,7 +48,10 @@
*
*/
#include "pios.h"
#include <openpilot.h>
#include <pios_board_info.h>
#include "attitude.h"
#include "gyros.h"
#include "accels.h"
@ -56,11 +59,11 @@
#include "attitudesettings.h"
#include "flightstatus.h"
#include "manualcontrolcommand.h"
#include "CoordinateConversions.h"
#include <pios_board_info.h>
#include <pios_math.h>
#include "taskinfo.h"
#include "CoordinateConversions.h"
// Private constants
#define STACK_SIZE_BYTES 540
#define TASK_PRIORITY (tskIDLE_PRIORITY+3)
@ -119,7 +122,7 @@ int32_t AttitudeStart(void)
// Start main task
xTaskCreate(AttitudeTask, (signed char *)"Attitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ATTITUDE, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ATTITUDE, taskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_ATTITUDE);
return 0;

View File

@ -48,10 +48,9 @@
*
*/
#include "pios.h"
#include <openpilot.h>
#include "attitude.h"
#include "accels.h"
#include "airspeedsensor.h"
#include "airspeedactual.h"
@ -69,8 +68,10 @@
#include "revocalibration.h"
#include "revosettings.h"
#include "velocityactual.h"
#include "taskinfo.h"
#include "CoordinateConversions.h"
#include <pios_math.h>
// Private constants
#define STACK_SIZE_BYTES 2048
#define TASK_PRIORITY (tskIDLE_PRIORITY+3)
@ -184,7 +185,7 @@ int32_t AttitudeStart(void)
// Start main task
xTaskCreate(AttitudeTask, (signed char *)"Attitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &attitudeTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_ATTITUDE, attitudeTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ATTITUDE, attitudeTaskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_ATTITUDE);
GyrosConnectQueue(gyroQueue);

View File

@ -48,7 +48,7 @@
*
*/
#include "openpilot.h"
#include <openpilot.h>
#include "flightstatus.h"
#include "hwsettings.h"
@ -58,7 +58,7 @@
#include "relaytuningsettings.h"
#include "stabilizationdesired.h"
#include "stabilizationsettings.h"
#include <pios_board_info.h>
#include "taskinfo.h"
// Private constants
#define STACK_SIZE_BYTES 1024
@ -109,7 +109,7 @@ int32_t AutotuneStart(void)
if(autotuneEnabled) {
xTaskCreate(AutotuneTask, (signed char *)"Autotune", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_AUTOTUNE, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_AUTOTUNE, taskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_AUTOTUNE);
}
return 0;

View File

@ -30,8 +30,10 @@
// ****************
#include "openpilot.h"
#include <openpilot.h>
#include "hwsettings.h"
#include "taskinfo.h"
#include <stdbool.h>
@ -75,9 +77,9 @@ static int32_t comUsbBridgeStart(void)
if (bridge_enabled) {
// Start tasks
xTaskCreate(com2UsbBridgeTask, (signed char *)"Com2UsbBridge", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &com2UsbBridgeTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_COM2USBBRIDGE, com2UsbBridgeTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_COM2USBBRIDGE, com2UsbBridgeTaskHandle);
xTaskCreate(usb2ComBridgeTask, (signed char *)"Usb2ComBridge", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &usb2ComBridgeTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_USB2COMBRIDGE, usb2ComBridgeTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_USB2COMBRIDGE, usb2ComBridgeTaskHandle);
return 0;
}

View File

@ -36,11 +36,13 @@
*
*/
#include "openpilot.h"
#include <openpilot.h>
#include "hwsettings.h"
#include "magbaro.h"
#include "baroaltitude.h" // object that will be updated by the module
#include "magnetometer.h"
#include "taskinfo.h"
// Private constants
#define STACK_SIZE_BYTES 620
@ -75,7 +77,7 @@ int32_t MagBaroStart()
if (magbaroEnabled) {
// Start main task
xTaskCreate(magbaroTask, (signed char *)"MagBaro", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
//TaskMonitorAdd(TASKINFO_RUNNING_MAGBARO, taskHandle);
//PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_MAGBARO, taskHandle);
return 0;
}
return -1;

View File

@ -24,11 +24,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdint.h>
#include "pios.h"
#include <openpilot.h>
#include <pios_board_info.h>
#include "openpilot.h"
#include "firmwareiap.h"
#include "firmwareiapobj.h"
#include "flightstatus.h"

View File

@ -43,8 +43,7 @@
*
*/
#include "openpilot.h"
#include "paths.h"
#include <openpilot.h>
#include "accels.h"
#include "hwsettings.h"
@ -65,9 +64,11 @@
#include "systemsettings.h"
#include "velocitydesired.h"
#include "velocityactual.h"
#include "taskinfo.h"
#include "paths.h"
#include "CoordinateConversions.h"
#include <pios_math.h>
#include <pios_constants.h>
// Private constants
#define MAX_QUEUE_SIZE 4
#define STACK_SIZE_BYTES 1548
@ -98,7 +99,7 @@ int32_t FixedWingPathFollowerStart()
if (followerEnabled) {
// Start main task
xTaskCreate(pathfollowerTask, (signed char *)"PathFollower", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &pathfollowerTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_PATHFOLLOWER, pathfollowerTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_PATHFOLLOWER, pathfollowerTaskHandle);
}
return 0;

View File

@ -29,12 +29,15 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include "pm.h"
#include <openpilot.h>
#include "flightplan.h"
#include "flightplanstatus.h"
#include "flightplancontrol.h"
#include "flightplansettings.h"
#include "taskinfo.h"
#include "pm.h"
// Private constants
#define STACK_SIZE_BYTES 1500
@ -63,7 +66,7 @@ int32_t FlightPlanStart()
// Start VM thread
xTaskCreate(flightPlanTask, (signed char *)"FlightPlan", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_FLIGHTPLAN, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_FLIGHTPLAN, taskHandle);
return 0;
}
@ -258,7 +261,7 @@ static void objectUpdatedCb(UAVObjEvent * ev)
if ( taskHandle == NULL )
{
xTaskCreate(flightPlanTask, (signed char *)"FlightPlan", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_FLIGHTPLAN, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_FLIGHTPLAN, taskHandle);
}
}
else if ( controlData.Command == FLIGHTPLANCONTROL_COMMAND_KILL )
@ -268,7 +271,7 @@ static void objectUpdatedCb(UAVObjEvent * ev)
if ( taskHandle != NULL )
{
// Kill VM
TaskMonitorRemove(TASKINFO_RUNNING_FLIGHTPLAN);
PIOS_TASK_MONITOR_UnregisterTask(TASKINFO_RUNNING_FLIGHTPLAN);
vTaskDelete(taskHandle);
taskHandle = NULL;
// Update status object

View File

@ -30,8 +30,7 @@
// ****************
#include "openpilot.h"
#include "GPS.h"
#include <openpilot.h>
#include "gpsposition.h"
#include "homelocation.h"
@ -39,10 +38,13 @@
#include "gpssatellites.h"
#include "gpsvelocity.h"
#include "systemsettings.h"
#include "WorldMagModel.h"
#include "CoordinateConversions.h"
#include "taskinfo.h"
#include "hwsettings.h"
#include "WorldMagModel.h"
#include "CoordinateConversions.h"
#include "GPS.h"
#include "NMEA.h"
#include "UBX.h"
@ -107,7 +109,7 @@ int32_t GPSStart(void)
if (gpsPort) {
// Start gps task
xTaskCreate(gpsTask, (signed char *)"GPS", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &gpsTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_GPS, gpsTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_GPS, gpsTaskHandle);
return 0;
}

View File

@ -33,7 +33,8 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include <openpilot.h>
#include "accessorydesired.h"
#include "actuatordesired.h"
#include "altitudeholddesired.h"
@ -50,6 +51,7 @@
#include "stabilizationdesired.h"
#include "receiveractivity.h"
#include "systemsettings.h"
#include "taskinfo.h"
#if defined(PIOS_INCLUDE_USB_RCTX)
#include "pios_usb_rctx.h"
@ -132,7 +134,7 @@ int32_t ManualControlStart()
{
// Start main task
xTaskCreate(manualControlTask, (signed char *)"ManualControl", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_MANUALCONTROL, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_MANUALCONTROL, taskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_MANUAL);
return 0;

View File

@ -39,10 +39,13 @@
*/
#include <openpilot.h>
#include <oplinkstatus.h>
#include <oplinksettings.h>
#include <taskinfo.h>
#include <pios_rfm22b.h>
#include <pios_board_info.h>
#include <oplinksettings.h>
// Private constants
#define SYSTEM_UPDATE_PERIOD_MS 1000
@ -79,7 +82,7 @@ int32_t OPLinkModStart(void)
// Create oplink system task
xTaskCreate(systemTask, (signed char *)"OPLink", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &systemTaskHandle);
// Register task
TaskMonitorAdd(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
return 0;
}

View File

@ -30,8 +30,10 @@
// ****************
#include "openpilot.h"
#include <openpilot.h>
#include "osdgen.h"
#include "attitudeactual.h"
#include "gpsposition.h"
#include "homelocation.h"
@ -39,6 +41,7 @@
#include "gpssatellites.h"
#include "osdsettings.h"
#include "baroaltitude.h"
#include "taskinfo.h"
#include "fonts.h"
#include "font12x18.h"
@ -2420,7 +2423,7 @@ int32_t osdgenStart(void)
// Start gps task
vSemaphoreCreateBinary( osdSemaphore);
xTaskCreate(osdgenTask, (signed char *)"OSDGEN", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &osdgenTaskHandle);
//TaskMonitorAdd(TASKINFO_RUNNING_GPS, osdgenTaskHandle);
//PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_GPS, osdgenTaskHandle);
return 0;
}

View File

@ -30,9 +30,13 @@
// ****************
#include "openpilot.h"
#include <openpilot.h>
#include "osdinput.h"
#include "attitudeactual.h"
#include "taskinfo.h"
#include "fifo_buffer.h"
@ -85,7 +89,7 @@ int32_t OpOsdStart(void)
{
// Start gps task
xTaskCreate(OpOsdTask, (signed char *)"OSD", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &OpOsdTaskHandle);
//TaskMonitorAdd(TASKINFO_RUNNING_GPS, OpOsdTaskHandle);
//PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_GPS, OpOsdTaskHandle);
return 0;
}

View File

@ -30,11 +30,14 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include "hwsettings.h"
#include <openpilot.h>
#include "overosync.h"
#include "hwsettings.h"
#include "overosyncstats.h"
#include "systemstats.h"
#include "taskinfo.h"
// Private constants
#define MAX_QUEUE_SIZE 200
@ -128,7 +131,7 @@ int32_t OveroSyncStart(void)
// Start overosync tasks
xTaskCreate(overoSyncTask, (signed char *)"OveroSync", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &overoSyncTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
return 0;
}

View File

@ -30,10 +30,13 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include <openpilot.h>
#include "overosync.h"
#include "overosyncstats.h"
#include "systemstats.h"
#include "taskinfo.h"
// Private constants
#define OVEROSYNC_PACKET_SIZE 1024
@ -127,7 +130,7 @@ int32_t OveroSyncStart(void)
// Start telemetry tasks
xTaskCreate(overoSyncTask, (signed char *)"OveroSync", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &overoSyncTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
return 0;
}

View File

@ -30,8 +30,6 @@
*/
#include "openpilot.h"
#include <pios_math.h>
#include "paths.h"
#include "flightstatus.h"
#include "airspeedactual.h"
@ -42,6 +40,9 @@
#include "velocityactual.h"
#include "waypoint.h"
#include "waypointactive.h"
#include "taskinfo.h"
#include "paths.h"
// Private constants
#define STACK_SIZE_BYTES 1024
@ -86,7 +87,7 @@ int32_t PathPlannerStart()
// Start VM thread
xTaskCreate(pathPlannerTask, (signed char *)"PathPlanner", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_PATHPLANNER, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_PATHPLANNER, taskHandle);
return 0;
}

View File

@ -58,9 +58,10 @@
#include <attitudesettings.h>
#include <revocalibration.h>
#include <flightstatus.h>
#include <taskinfo.h>
#include <CoordinateConversions.h>
#include <pios_math.h>
#include <pios_board_info.h>
// Private constants
@ -130,7 +131,7 @@ int32_t SensorsStart(void)
{
// Start main task
xTaskCreate(SensorsTask, (signed char *)"Sensors", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &sensorsTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_SENSORS, sensorsTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SENSORS, sensorsTaskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_SENSORS);
return 0;

View File

@ -46,9 +46,9 @@
*
*/
#include "pios.h"
#include "attitude.h"
#include <openpilot.h>
#include "attitude.h"
#include "accels.h"
#include "actuatordesired.h"
#include "attitudeactual.h"
@ -67,6 +67,7 @@
#include "ratedesired.h"
#include "revocalibration.h"
#include "systemsettings.h"
#include "taskinfo.h"
#include "CoordinateConversions.h"
@ -132,7 +133,7 @@ int32_t SensorsStart(void)
{
// Start main task
xTaskCreate(SensorsTask, (signed char *)"Sensors", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &sensorsTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_SENSORS, sensorsTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SENSORS, sensorsTaskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_SENSORS);
return 0;

View File

@ -31,7 +31,8 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include <openpilot.h>
#include "stabilization.h"
#include "stabilizationsettings.h"
#include "actuatordesired.h"
@ -43,6 +44,7 @@
#include "gyros.h"
#include "flightstatus.h"
#include "manualcontrol.h" // Just to get a macro
#include "taskinfo.h"
// Math libraries
#include "CoordinateConversions.h"
@ -107,7 +109,7 @@ int32_t StabilizationStart()
// Start main task
xTaskCreate(stabilizationTask, (signed char*)"Stabilization", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_STABILIZATION, taskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_STABILIZATION, taskHandle);
PIOS_WDG_RegisterFlag(PIOS_WDG_STABILIZATION);
return 0;
}

View File

@ -51,7 +51,7 @@
#include <i2cstats.h>
#include <taskinfo.h>
#include <watchdogstatus.h>
#include <taskmonitor.h>
#include <taskinfo.h>
#include <hwsettings.h>
// Flight Libraries
@ -98,6 +98,9 @@ static HwSettingsData bootHwSettings;
// Private functions
static void objectUpdatedCb(UAVObjEvent * ev);
static void hwSettingsUpdatedCb(UAVObjEvent * ev);
#ifdef DIAG_TASKS
static void taskMonitorForEachCallback(uint16_t task_id, const struct pios_task_info *task_info, void *context);
#endif
static void updateStats();
static void updateSystemAlarms();
static void systemTask(void *parameters);
@ -117,7 +120,7 @@ int32_t SystemModStart(void)
// Create system task
xTaskCreate(systemTask, (signed char *)"System", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &systemTaskHandle);
// Register task
TaskMonitorAdd(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
return 0;
}
@ -185,6 +188,10 @@ static void systemTask(void *parameters)
// Whenever the configuration changes, make sure it is safe to fly
HwSettingsConnectCallback(hwSettingsUpdatedCb);
#ifdef DIAG_TASKS
TaskInfoData taskInfoData;
#endif
// Main system loop
while (1) {
// Update the system statistics
@ -199,7 +206,8 @@ static void systemTask(void *parameters)
#ifdef DIAG_TASKS
// Update the task status object
TaskMonitorUpdateAll();
PIOS_TASK_MONITOR_ForEachTask(taskMonitorForEachCallback, &taskInfoData);
TaskInfoSet(&taskInfoData);
#endif
// Flash the heartbeat LED
@ -348,6 +356,19 @@ static void hwSettingsUpdatedCb(UAVObjEvent * ev)
}
}
#ifdef DIAG_TASKS
static void taskMonitorForEachCallback(uint16_t task_id, const struct pios_task_info *task_info, void *context)
{
TaskInfoData *taskData = (TaskInfoData *)context;
// By convention, there is a direct mapping between task monitor task_id's and members
// of the TaskInfoXXXXElem enums
PIOS_DEBUG_Assert(task_id < TASKINFO_RUNNING_NUMELEM);
taskData->Running[task_id] = task_info->is_running? TASKINFO_RUNNING_TRUE: TASKINFO_RUNNING_FALSE;
taskData->StackRemaining[task_id] = task_info->stack_remaining;
taskData->RunningTime[task_id] = task_info->running_time_percentage;
}
#endif
/**
* Called periodically to update the I2C statistics
*/

View File

@ -30,11 +30,14 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include <openpilot.h>
#include "telemetry.h"
#include "flighttelemetrystats.h"
#include "gcstelemetrystats.h"
#include "hwsettings.h"
#include "taskinfo.h"
// Private constants
#define MAX_QUEUE_SIZE TELEM_QUEUE_SIZE
@ -96,13 +99,13 @@ int32_t TelemetryStart(void)
// Start telemetry tasks
xTaskCreate(telemetryTxTask, (signed char *)"TelTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
xTaskCreate(telemetryRxTask, (signed char *)"TelRx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
xTaskCreate(telemetryTxPriTask, (signed char *)"TelPriTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TXPRI, &telemetryTxPriTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif
return 0;

View File

@ -46,11 +46,10 @@
*
*/
#include "openpilot.h"
#include <pios_math.h>
#include "paths.h"
#include <openpilot.h>
#include "vtolpathfollower.h"
#include "accels.h"
#include "attitudeactual.h"
#include "hwsettings.h"
@ -69,6 +68,9 @@
#include "systemsettings.h"
#include "velocitydesired.h"
#include "velocityactual.h"
#include "taskinfo.h"
#include "paths.h"
#include "CoordinateConversions.h"
// Private constants
@ -103,7 +105,7 @@ int32_t VtolPathFollowerStart()
if (vtolpathfollower_enabled) {
// Start main task
xTaskCreate(vtolPathFollowerTask, (signed char *)"VtolPathFollower", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &pathfollowerTaskHandle);
TaskMonitorAdd(TASKINFO_RUNNING_PATHFOLLOWER, pathfollowerTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_PATHFOLLOWER, pathfollowerTaskHandle);
}
return 0;

View File

@ -35,7 +35,6 @@
#include <stdbool.h>
#define MIN(x,y) ((x) < (y) ? (x) : (y))
/*
* Filesystem state data tracked in RAM

View File

@ -0,0 +1,144 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @{
* @file pios_task_monitor.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Task monitoring functions
* @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 <pios.h>
#ifdef PIOS_INCLUDE_TASK_MONITOR
// Private variables
static xSemaphoreHandle mLock;
static xTaskHandle *mTaskHandles;
static uint32_t mLastMonitorTime;
static uint16_t mMaxTasks;
/**
* Initialize the Task Monitor
*/
int32_t PIOS_TASK_MONITOR_Initialize(uint16_t max_tasks)
{
mLock = xSemaphoreCreateRecursiveMutex();
if (!mLock) { return -1; }
mTaskHandles = (xTaskHandle*)pvPortMalloc(max_tasks * sizeof(xTaskHandle));
if (!mTaskHandles) { return -1; }
memset(mTaskHandles, 0, max_tasks * sizeof(xTaskHandle));
mMaxTasks = max_tasks;
#if (configGENERATE_RUN_TIME_STATS == 1)
mLastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
#else
mLastMonitorTime = 0;
#endif
return 0;
}
/**
* Register a task handle
*/
int32_t PIOS_TASK_MONITOR_RegisterTask(uint16_t task_id, xTaskHandle handle)
{
if (mTaskHandles && task_id < mMaxTasks) {
xSemaphoreTakeRecursive(mLock, portMAX_DELAY);
mTaskHandles[task_id] = handle;
xSemaphoreGiveRecursive(mLock);
return 0;
} else {
return -1;
}
}
/**
* Unregister a task handle
*/
int32_t PIOS_TASK_MONITOR_UnregisterTask(uint16_t task_id)
{
if (mTaskHandles && task_id < mMaxTasks) {
xSemaphoreTakeRecursive(mLock, portMAX_DELAY);
mTaskHandles[task_id] = 0;
xSemaphoreGiveRecursive(mLock);
return 0;
} else {
return -1;
}
}
/**
* Query if a task is running
*/
bool PIOS_TASK_MONITOR_IsRunning(uint16_t task_id)
{
return (mTaskHandles && task_id <= mMaxTasks && mTaskHandles[task_id]);
}
/**
* Tell the caller the status of all tasks via a task-by-task callback
*/
void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *context)
{
if (!mTaskHandles) { return; }
xSemaphoreTakeRecursive(mLock, portMAX_DELAY);
#if (configGENERATE_RUN_TIME_STATS == 1)
/* Calculate the amount of elapsed run time between the last time we
* measured and now. Scale so that we can convert task run times
* directly to percentages. */
uint32_t currentTime = portGET_RUN_TIME_COUNTER_VALUE();
/* avoid divide-by-zero if the interval is too small */
uint32_t deltaTime = ((currentTime - mLastMonitorTime)/100) ? : 1;
mLastMonitorTime = currentTime;
#endif
/* Update all task information */
for (uint16_t n = 0; n < mMaxTasks; ++n) {
struct pios_task_info info;
if (mTaskHandles[n]) {
info.is_running = true;
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
info.stack_remaining = 10000;
#else
info.stack_remaining = uxTaskGetStackHighWaterMark(mTaskHandles[n]) * 4;
#endif
#if (configGENERATE_RUN_TIME_STATS == 1)
/* Generate run time percentage stats */
info.running_time_percentage = uxTaskGetRunTime(mTaskHandles[n])/deltaTime;
#else
info.running_time_percentage = 0;
#endif
} else {
info.is_running = false;
info.stack_remaining = 0;
info.running_time_percentage = 0;
}
/* Pass the information for this task back to the caller */
callback(n, &info, context);
}
xSemaphoreGiveRecursive(mLock);
}
#endif // PIOS_INCLUDE_TASK_MONITOR

View File

@ -0,0 +1,107 @@
/**
******************************************************************************
* @addtogroup OpenPilotSystem OpenPilot System
* @{
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
* @{
* @file task_monitor.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
* @brief Task monitoring functions
* @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 PIOS_TASK_MONITOR_H
#define PIOS_TASK_MONITOR_H
#include <stdbool.h>
/**
* Initializes the Task Monitor.
*
* For correct results, this must be called prior to any calls to other
* task monitoring functions. The task_ids of the monitored tasks must
* be in the range [0, max_tasks-1].
* Initially, all tasks are marked as not running.
*
* @param max_tasks The maximum number of tasks that will be monitored.
* @return 0 on success, -1 on failure.
*/
extern int32_t PIOS_TASK_MONITOR_Initialize(uint16_t max_tasks);
/**
* Registers a task with the task monitor.
* A task that has been registered will be marked as running.
*
* @param task_id The id of the task to register. Must be in the range [0, max_tasks-1].
* @param handle The FreeRTOS xTaskHandle of the running task.
* @return 0 on success, -1 on failure.
*/
extern int32_t PIOS_TASK_MONITOR_RegisterTask(uint16_t task_id, xTaskHandle handle);
/**
* Unregisters a task with the task monitor.
* A task that has been unregistered will be marked as not running.
*
* @param task_id The id of the task to unregister. Must be in the range [0, max_tasks-1].
* @return 0 on success, -1 on failure.
*/
extern int32_t PIOS_TASK_MONITOR_UnregisterTask(uint16_t task_id);
/**
* Checks if a given task is running.
* A task that has not been registered will be marked as not running.
*
* @param task_id The id of the task to check. Must be in the range [0, max_tasks-1].
* @return true if the task is running.
*/
extern bool PIOS_TASK_MONITOR_IsRunning(uint16_t task_id);
/**
* Information about a running task that has been registered
* via a call to PIOS_TASK_MONITOR_Add().
*/
struct pios_task_info {
/** Remaining task stack in bytes. */
uint32_t stack_remaining;
/** Flag indicating whether or not the task is running. */
bool is_running;
/** Percentage of cpu time used by the task since the last call
* to PIOS_TASK_MONITOR_ForEachTask(). Low-load tasks may
* report 0% load even though they have run during the interval. */
uint8_t running_time_percentage;
};
/**
* Iterator callback, called for each monitored task by PIOS_TASK_MONITOR_TasksIterate().
*
* @param task_id The id of the task the task_info refers to.
* @param task_info Information about the task identified by task_id.
* @param context Context information optionally provided by the caller to PIOS_TASK_MONITOR_TasksIterate()
*/
typedef void (*TaskMonitorTaskInfoCallback)(uint16_t task_id, const struct pios_task_info *task_info, void *context);
/**
* Iterator callback, called for each monitored task by PIOS_TASK_MONITOR_TasksIterate().
*
* @param task_id The id of the task the task_info refers to.
* @param task_info Information about the task identified by task_id.
* @param context Context information optionally provided by the caller to PIOS_TASK_MONITOR_TasksIterate()
*/
extern void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *context);
#endif // PIOS_TASK_MONITOR_H

View File

@ -35,6 +35,8 @@
#define PIOS_H
#include <pios_helpers.h>
#include <pios_math.h>
#include <pios_constants.h>
#ifdef USE_SIM_POSIX
/* SimPosix version of this file. This will probably be removed later */
@ -78,6 +80,13 @@
#include "semphr.h"
#endif
#ifdef PIOS_INCLUDE_TASK_MONITOR
#ifndef PIOS_INCLUDE_FREERTOS
#error PiOS Task Monitor requires PIOS_INCLUDE_FREERTOS to be defined
#endif
#include <pios_task_monitor.h>
#endif
/* PIOS bootloader helper */
#ifdef PIOS_INCLUDE_BL_HELPER
/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */

View File

@ -40,6 +40,13 @@
#include "semphr.h"
#endif
#ifdef PIOS_INCLUDE_TASK_MONITOR
#ifndef PIOS_INCLUDE_FREERTOS
#error PiOS Task Monitor requires PIOS_INCLUDE_FREERTOS to be defined
#endif
#include <pios_task_monitor.h>
#endif
/* C Lib Includes */
#include <stdio.h>
#include <stdlib.h>

View File

@ -169,7 +169,9 @@
#define HCCHAR_BULK 2
#define HCCHAR_INTR 3
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
/**
* @}

View File

@ -37,9 +37,6 @@
#include "pios_usb_board_data.h" /* PIOS_BOARD_*_DATA_LENGTH */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
static void PIOS_USB_HID_RegisterTxCallback(uint32_t usbhid_id, pios_com_callback tx_out_cb, uint32_t context);
static void PIOS_USB_HID_RegisterRxCallback(uint32_t usbhid_id, pios_com_callback rx_in_cb, uint32_t context);
static void PIOS_USB_HID_TxStart(uint32_t usbhid_id, uint16_t tx_bytes_avail);

View File

@ -36,7 +36,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_INITCALL
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
/* PIOS hardware peripherals */
#define PIOS_INCLUDE_IRQ

View File

@ -34,6 +34,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_TASK_MONITOR
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_UDP
#define PIOS_INCLUDE_SERVO

View File

@ -31,6 +31,7 @@
#include <hwsettings.h>
#include <manualcontrolsettings.h>
#include <gcsreceiver.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -228,8 +229,10 @@ void PIOS_Board_Init(void) {
AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
}
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Set up pulse timers */
PIOS_TIM_InitClock(&tim_1_cfg);

View File

@ -45,8 +45,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Initialize the PiOS library */
PIOS_COM_Init();

View File

@ -37,7 +37,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_INITCALL
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
/* PIOS hardware peripherals */
#define PIOS_INCLUDE_IRQ

View File

@ -34,6 +34,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_TASK_MONITOR
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_UDP
#define PIOS_INCLUDE_SERVO

View File

@ -30,6 +30,7 @@
#include "inc/openpilot.h"
#include <pios_board_info.h>
#include <oplinksettings.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -138,8 +139,10 @@ void PIOS_Board_Init(void) {
OPLinkSettingsGet(&oplinkSettings);
#endif /* PIOS_INCLUDE_FLASH_EEPROM */
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_TIM)
/* Set up pulse timers */

View File

@ -45,8 +45,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Initialize the PiOS library */
PIOS_COM_Init();

View File

@ -36,7 +36,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_INITCALL
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
/* PIOS hardware peripherals */
#define PIOS_INCLUDE_IRQ

View File

@ -29,6 +29,7 @@
#include <hwsettings.h>
#include <manualcontrolsettings.h>
#include <gcsreceiver.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -133,8 +134,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* IAP System Setup */
PIOS_IAP_Init();

View File

@ -186,7 +186,6 @@ SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/paths.c
SRC += $(FLIGHTLIB)/insgps13state.c
SRC += $(FLIGHTLIB)/taskmonitor.c
## RTOS and RTOS Portable
SRC += $(RTOSSRCDIR)/list.c

View File

@ -37,7 +37,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_INITCALL
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
/* PIOS hardware peripherals */
#define PIOS_INCLUDE_IRQ

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_SDCARD
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_TASK_MONITOR
#define PIOS_INCLUDE_COM
//#define PIOS_INCLUDE_GPS
#define PIOS_INCLUDE_IRQ

View File

@ -30,6 +30,7 @@
#include <uavobjectsinit.h>
#include <hwsettings.h>
#include <manualcontrolsettings.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -379,8 +380,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Set up pulse timers */
PIOS_TIM_InitClock(&tim_1_cfg);

View File

@ -149,8 +149,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 1

View File

@ -184,7 +184,6 @@ SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/paths.c
SRC += $(FLIGHTLIB)/insgps13state.c
SRC += $(FLIGHTLIB)/taskmonitor.c
SRC += $(MATHLIB)/pid.c
SRC += $(MATHLIB)/sin_lookup.c

View File

@ -37,7 +37,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_INITCALL
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
/* PIOS hardware peripherals */
#define PIOS_INCLUDE_IRQ

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_SDCARD
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_TASK_MONITOR
#define PIOS_INCLUDE_COM
//#define PIOS_INCLUDE_GPS
#define PIOS_INCLUDE_IRQ

View File

@ -30,6 +30,7 @@
#include <uavobjectsinit.h>
#include <hwsettings.h>
#include <manualcontrolsettings.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -428,8 +429,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Set up pulse timers */
PIOS_TIM_InitClock(&tim_1_cfg);

View File

@ -149,8 +149,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 1

View File

@ -56,6 +56,7 @@ MATHLIB = $(FLIGHTLIB)/math
MATHLIBINC = $(FLIGHTLIB)/math
PIOSPOSIX = $(PIOS)/posix
PIOSCOMMON = $(PIOS)/posix
PIOSCORECOMMON = $(PIOS)/common
PIOSCOMMONLIB = $(PIOS)/common/libraries
BOOT =
BOOTINC =
@ -85,13 +86,14 @@ SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/insgps13state.c
SRC += $(FLIGHTLIB)/taskmonitor.c
SRC += $(FLIGHTLIB)/paths.c
SRC += $(FLIGHTLIB)/sanitycheck.c
SRC += $(MATHLIB)/sin_lookup.c
SRC += $(MATHLIB)/pid.c
SRC += $(PIOSCORECOMMON)/pios_task_monitor.c
## PIOS Hardware
include $(PIOS)/posix/library.mk

View File

@ -37,7 +37,6 @@
#include <utlist.h>
#include <uavobjectmanager.h>
#include <eventdispatcher.h>
#include <taskmonitor.h>
#include <uavtalk.h>
#include "alarms.h"

View File

@ -49,6 +49,7 @@
#define PIOS_INCLUDE_SERVO
#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_TASK_MONITOR
#define PIOS_INCLUDE_USART
//#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID

View File

@ -32,6 +32,7 @@
#include <uavobjectsinit.h>
#include <hwsettings.h>
#include <manualcontrolsettings.h>
#include <taskinfo.h>
/*
* Pull in the board-specific static HW definitions.
@ -126,8 +127,10 @@ void PIOS_Board_Init(void) {
/* Initialize the alarms library */
AlarmsInitialize();
/* Initialize the task monitor library */
TaskMonitorInitialize();
/* Initialize the task monitor */
if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) {
PIOS_Assert(0);
}
/* Configure IO ports */

View File

@ -24,7 +24,9 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "openpilot.h"
#include <openpilot.h>
#include <taskinfo.h>
// Private constants
#if defined(PIOS_EVENTDISAPTCHER_QUEUE)
@ -281,7 +283,7 @@ static void eventTask()
EventCallbackInfo evInfo;
/* Must do this in task context to ensure that TaskMonitor has already finished its init */
TaskMonitorAdd(TASKINFO_RUNNING_EVENTDISPATCHER, eventTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_EVENTDISPATCHER, eventTaskHandle);
// Initialize time
timeToNextUpdateMs = xTaskGetTickCount()*portTICK_RATE_MS;

View File

@ -92,9 +92,11 @@ SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
SRC += $(PIOSCOMMON)/pios_usb_util.c
## PIOS system code
SRC += $(PIOSCOMMON)/pios_task_monitor.c
## Misc library functions
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/taskmonitor.c
SRC += $(FLIGHTLIB)/sanitycheck.c
SRC += $(FLIGHTLIB)/CoordinateConversions.c
SRC += $(MATHLIB)/sin_lookup.c