mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Merge branch 'next' into thread/OP-1245_FlightLog_Configuration_And_Control_GUI
This commit is contained in:
commit
7affc034c4
1
Makefile
1
Makefile
@ -450,6 +450,7 @@ else
|
|||||||
GCS_SILENT := silent
|
GCS_SILENT := silent
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
.NOTPARALLEL:
|
||||||
.PHONY: openpilotgcs
|
.PHONY: openpilotgcs
|
||||||
openpilotgcs: uavobjects_gcs openpilotgcs_qmake openpilotgcs_make
|
openpilotgcs: uavobjects_gcs openpilotgcs_qmake openpilotgcs_make
|
||||||
|
|
||||||
|
@ -63,8 +63,6 @@
|
|||||||
// Private types
|
// Private types
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
static uint32_t idleCounter;
|
|
||||||
static uint32_t idleCounterClear;
|
|
||||||
static xTaskHandle systemTaskHandle;
|
static xTaskHandle systemTaskHandle;
|
||||||
static bool stackOverflow;
|
static bool stackOverflow;
|
||||||
static bool mallocFailed;
|
static bool mallocFailed;
|
||||||
@ -130,8 +128,6 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize vars
|
// Initialize vars
|
||||||
idleCounter = 0;
|
|
||||||
idleCounterClear = 0;
|
|
||||||
lastSysTime = xTaskGetTickCount();
|
lastSysTime = xTaskGetTickCount();
|
||||||
|
|
||||||
// Main system loop
|
// Main system loop
|
||||||
@ -205,15 +201,7 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
* Called by the RTOS when the CPU is idle, used to measure the CPU idle time.
|
* Called by the RTOS when the CPU is idle, used to measure the CPU idle time.
|
||||||
*/
|
*/
|
||||||
void vApplicationIdleHook(void)
|
void vApplicationIdleHook(void)
|
||||||
{
|
{}
|
||||||
// Called when the scheduler has no tasks to run
|
|
||||||
if (idleCounterClear == 0) {
|
|
||||||
++idleCounter;
|
|
||||||
} else {
|
|
||||||
idleCounter = 0;
|
|
||||||
idleCounterClear = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the RTOS when a stack overflow is detected.
|
* Called by the RTOS when a stack overflow is detected.
|
||||||
|
@ -92,8 +92,6 @@
|
|||||||
// Private types
|
// Private types
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
static uint32_t idleCounter;
|
|
||||||
static uint32_t idleCounterClear;
|
|
||||||
static xTaskHandle systemTaskHandle;
|
static xTaskHandle systemTaskHandle;
|
||||||
static xQueueHandle objectPersistenceQueue;
|
static xQueueHandle objectPersistenceQueue;
|
||||||
static enum { STACKOVERFLOW_NONE = 0, STACKOVERFLOW_WARNING = 1, STACKOVERFLOW_CRITICAL = 3 } stackOverflow;
|
static enum { STACKOVERFLOW_NONE = 0, STACKOVERFLOW_WARNING = 1, STACKOVERFLOW_CRITICAL = 3 } stackOverflow;
|
||||||
@ -132,6 +130,7 @@ int32_t SystemModStart(void)
|
|||||||
// Register task
|
// Register task
|
||||||
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
|
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,15 +185,12 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
*/
|
*/
|
||||||
PIOS_SYS_Reset();
|
PIOS_SYS_Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_IAP)
|
#if defined(PIOS_INCLUDE_IAP)
|
||||||
/* Record a successful boot */
|
/* Record a successful boot */
|
||||||
PIOS_IAP_WriteBootCount(0);
|
PIOS_IAP_WriteBootCount(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize vars
|
// Initialize vars
|
||||||
idleCounter = 0;
|
|
||||||
idleCounterClear = 0;
|
|
||||||
|
|
||||||
// Listen for SettingPersistance object updates, connect a callback function
|
// Listen for SettingPersistance object updates, connect a callback function
|
||||||
ObjectPersistenceConnectQueue(objectPersistenceQueue);
|
ObjectPersistenceConnectQueue(objectPersistenceQueue);
|
||||||
@ -212,9 +208,10 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
// Main system loop
|
// Main system loop
|
||||||
while (1) {
|
while (1) {
|
||||||
// Update the system statistics
|
// Update the system statistics
|
||||||
updateStats();
|
|
||||||
cycleCount = cycleCount > 0 ? cycleCount - 1 : 7;
|
|
||||||
|
|
||||||
|
cycleCount = cycleCount > 0 ? cycleCount - 1 : 7;
|
||||||
|
// if(cycleCount == 1){
|
||||||
|
updateStats();
|
||||||
// Update the system alarms
|
// Update the system alarms
|
||||||
updateSystemAlarms();
|
updateSystemAlarms();
|
||||||
#ifdef DIAG_I2C_WDG_STATS
|
#ifdef DIAG_I2C_WDG_STATS
|
||||||
@ -227,10 +224,12 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
PIOS_TASK_MONITOR_ForEachTask(taskMonitorForEachCallback, &taskInfoData);
|
PIOS_TASK_MONITOR_ForEachTask(taskMonitorForEachCallback, &taskInfoData);
|
||||||
TaskInfoSet(&taskInfoData);
|
TaskInfoSet(&taskInfoData);
|
||||||
// Update the callback status object
|
// Update the callback status object
|
||||||
|
// if(FALSE){
|
||||||
PIOS_CALLBACKSCHEDULER_ForEachCallback(callbackSchedulerForEachCallback, &callbackInfoData);
|
PIOS_CALLBACKSCHEDULER_ForEachCallback(callbackSchedulerForEachCallback, &callbackInfoData);
|
||||||
CallbackInfoSet(&callbackInfoData);
|
CallbackInfoSet(&callbackInfoData);
|
||||||
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
// }
|
||||||
// Flash the heartbeat LED
|
// Flash the heartbeat LED
|
||||||
#if defined(PIOS_LED_HEARTBEAT)
|
#if defined(PIOS_LED_HEARTBEAT)
|
||||||
uint8_t armingStatus;
|
uint8_t armingStatus;
|
||||||
@ -541,7 +540,6 @@ static uint16_t GetFreeIrqStackSize(void)
|
|||||||
*/
|
*/
|
||||||
static void updateStats()
|
static void updateStats()
|
||||||
{
|
{
|
||||||
static portTickType lastTickCount = 0;
|
|
||||||
SystemStatsData stats;
|
SystemStatsData stats;
|
||||||
|
|
||||||
// Get stats and update
|
// Get stats and update
|
||||||
@ -559,10 +557,6 @@ static void updateStats()
|
|||||||
// Get Irq stack status
|
// Get Irq stack status
|
||||||
stats.IRQStackRemaining = GetFreeIrqStackSize();
|
stats.IRQStackRemaining = GetFreeIrqStackSize();
|
||||||
|
|
||||||
// When idleCounterClear was not reset by the idle-task, it means the idle-task did not run
|
|
||||||
if (idleCounterClear) {
|
|
||||||
idleCounter = 0;
|
|
||||||
}
|
|
||||||
#if !defined(ARCH_POSIX) && !defined(ARCH_WIN32)
|
#if !defined(ARCH_POSIX) && !defined(ARCH_WIN32)
|
||||||
if (pios_uavo_settings_fs_id) {
|
if (pios_uavo_settings_fs_id) {
|
||||||
PIOS_FLASHFS_GetStats(pios_uavo_settings_fs_id, &fsStats);
|
PIOS_FLASHFS_GetStats(pios_uavo_settings_fs_id, &fsStats);
|
||||||
@ -575,16 +569,11 @@ static void updateStats()
|
|||||||
stats.UsrSlotsActive = fsStats.num_active_slots;
|
stats.UsrSlotsActive = fsStats.num_active_slots;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
portTickType now = xTaskGetTickCount();
|
stats.CPULoad = 100 - PIOS_TASK_MONITOR_GetIdlePercentage();
|
||||||
if (now > lastTickCount) {
|
|
||||||
uint32_t dT = (xTaskGetTickCount() - lastTickCount) * portTICK_RATE_MS; // in ms
|
|
||||||
stats.CPULoad = 100 - (uint8_t)roundf(100.0f * ((float)idleCounter / ((float)dT / 1000.0f)) / (float)IDLE_COUNTS_PER_SEC_AT_NO_LOAD);
|
|
||||||
} // else: TickCount has wrapped, do not calc now
|
|
||||||
lastTickCount = now;
|
|
||||||
idleCounterClear = 1;
|
|
||||||
#if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR)
|
#if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR)
|
||||||
float temp_voltage = PIOS_ADC_PinGetVolt(PIOS_ADC_TEMPERATURE_PIN);
|
float temp_voltage = PIOS_ADC_PinGetVolt(PIOS_ADC_TEMPERATURE_PIN);
|
||||||
stats.CPUTemp = PIOS_CONVERT_VOLT_TO_CPU_TEMP(temp_voltage);;
|
stats.CPUTemp = PIOS_CONVERT_VOLT_TO_CPU_TEMP(temp_voltage);;
|
||||||
#endif
|
#endif
|
||||||
SystemStatsSet(&stats);
|
SystemStatsSet(&stats);
|
||||||
}
|
}
|
||||||
@ -663,15 +652,7 @@ static void updateSystemAlarms()
|
|||||||
* Called by the RTOS when the CPU is idle, used to measure the CPU idle time.
|
* Called by the RTOS when the CPU is idle, used to measure the CPU idle time.
|
||||||
*/
|
*/
|
||||||
void vApplicationIdleHook(void)
|
void vApplicationIdleHook(void)
|
||||||
{
|
{}
|
||||||
// Called when the scheduler has no tasks to run
|
|
||||||
if (idleCounterClear == 0) {
|
|
||||||
++idleCounter;
|
|
||||||
} else {
|
|
||||||
idleCounter = 0;
|
|
||||||
idleCounterClear = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the RTOS when a stack overflow is detected.
|
* Called by the RTOS when a stack overflow is detected.
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
static xSemaphoreHandle mLock;
|
static xSemaphoreHandle mLock;
|
||||||
static xTaskHandle *mTaskHandles;
|
static xTaskHandle *mTaskHandles;
|
||||||
static uint32_t mLastMonitorTime;
|
static uint32_t mLastMonitorTime;
|
||||||
|
static uint32_t mLastIdleMonitorTime;
|
||||||
static uint16_t mMaxTasks;
|
static uint16_t mMaxTasks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,9 +54,11 @@ int32_t PIOS_TASK_MONITOR_Initialize(uint16_t max_tasks)
|
|||||||
|
|
||||||
mMaxTasks = max_tasks;
|
mMaxTasks = max_tasks;
|
||||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||||
mLastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
|
mLastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||||
|
mLastIdleMonitorTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||||
#else
|
#else
|
||||||
mLastMonitorTime = 0;
|
mLastMonitorTime = 0;
|
||||||
|
mLastIdleMonitorTime = 0;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -146,4 +149,31 @@ void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *c
|
|||||||
xSemaphoreGiveRecursive(mLock);
|
xSemaphoreGiveRecursive(mLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t PIOS_TASK_MONITOR_GetIdlePercentage()
|
||||||
|
{
|
||||||
|
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
|
||||||
|
return 50;
|
||||||
|
|
||||||
|
#elif (configGENERATE_RUN_TIME_STATS == 1)
|
||||||
|
xSemaphoreTakeRecursive(mLock, portMAX_DELAY);
|
||||||
|
|
||||||
|
uint32_t currentTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||||
|
|
||||||
|
/* avoid divide-by-zero if the interval is too small */
|
||||||
|
uint32_t deltaTime = ((currentTime - mLastIdleMonitorTime) / 100) ? : 1;
|
||||||
|
mLastIdleMonitorTime = currentTime;
|
||||||
|
uint8_t running_time_percentage = 0;
|
||||||
|
|
||||||
|
/* Generate idle time percentage stats */
|
||||||
|
running_time_percentage = uxTaskGetRunTime(xTaskGetIdleTaskHandle()) / deltaTime;
|
||||||
|
xSemaphoreGiveRecursive(mLock);
|
||||||
|
return running_time_percentage;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // PIOS_INCLUDE_TASK_MONITOR
|
#endif // PIOS_INCLUDE_TASK_MONITOR
|
||||||
|
@ -104,4 +104,9 @@ typedef void (*TaskMonitorTaskInfoCallback)(uint16_t task_id, const struct pios_
|
|||||||
*/
|
*/
|
||||||
extern void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *context);
|
extern void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the idle task running time percentage.
|
||||||
|
*/
|
||||||
|
extern uint8_t PIOS_TASK_MONITOR_GetIdlePercentage();
|
||||||
|
|
||||||
#endif // PIOS_TASK_MONITOR_H
|
#endif // PIOS_TASK_MONITOR_H
|
||||||
|
@ -75,11 +75,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable run time stats collection */
|
/* Enable run time stats collection */
|
||||||
#ifdef DIAG_TASKS
|
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
|
||||||
|
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define INCLUDE_uxTaskGetRunTime 1
|
#define INCLUDE_uxTaskGetRunTime 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
|
||||||
do { \
|
do { \
|
||||||
(*(unsigned long *)0xe000edfc) |= (1 << 24); /* DEMCR |= DEMCR_TRCENA */ \
|
(*(unsigned long *)0xe000edfc) |= (1 << 24); /* DEMCR |= DEMCR_TRCENA */ \
|
||||||
@ -87,6 +85,9 @@
|
|||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004) /* DWT_CYCCNT */
|
#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004) /* DWT_CYCCNT */
|
||||||
|
|
||||||
|
#ifdef DIAG_TASKS
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
#else
|
#else
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
#define configCHECK_FOR_STACK_OVERFLOW 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,11 +75,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable run time stats collection */
|
/* Enable run time stats collection */
|
||||||
#ifdef DIAG_TASKS
|
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
|
||||||
|
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define INCLUDE_uxTaskGetRunTime 1
|
#define INCLUDE_uxTaskGetRunTime 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
|
||||||
do { \
|
do { \
|
||||||
(*(unsigned long *)0xe000edfc) |= (1 << 24); /* DEMCR |= DEMCR_TRCENA */ \
|
(*(unsigned long *)0xe000edfc) |= (1 << 24); /* DEMCR |= DEMCR_TRCENA */ \
|
||||||
@ -87,6 +85,9 @@
|
|||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004) /* DWT_CYCCNT */
|
#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004) /* DWT_CYCCNT */
|
||||||
|
|
||||||
|
#ifdef DIAG_TASKS
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
#else
|
#else
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
#define configCHECK_FOR_STACK_OVERFLOW 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
/* Enable run time stats collection */
|
/* Enable run time stats collection */
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define INCLUDE_uxTaskGetRunTime 1
|
#define INCLUDE_uxTaskGetRunTime 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once we move to CMSIS2 we can at least use:
|
* Once we move to CMSIS2 we can at least use:
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
#define INCLUDE_xTaskGetSchedulerState 1
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
|
|
||||||
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
|
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
|
||||||
(lowest) to 1 (highest maskable) to 0 (highest non-maskable). */
|
(lowest) to 1 (highest maskable) to 0 (highest non-maskable). */
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
/* Enable run time stats collection */
|
/* Enable run time stats collection */
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define INCLUDE_uxTaskGetRunTime 1
|
#define INCLUDE_uxTaskGetRunTime 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once we move to CMSIS2 we can at least use:
|
* Once we move to CMSIS2 we can at least use:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user