diff --git a/flight/AHRS/ahrs.c b/flight/AHRS/ahrs.c index 316a0a74a..cc6e349e3 100644 --- a/flight/AHRS/ahrs.c +++ b/flight/AHRS/ahrs.c @@ -782,6 +782,8 @@ void process_spi_request(void) // compute the idle fraction user_tx_v1.payload.user.v.rsp.update.load = ((float) running_counts / (float) (idle_counts+running_counts)) * 100; + user_tx_v1.payload.user.v.rsp.update.idle_time = idle_counts / (TIMER_RATE / 10000); + user_tx_v1.payload.user.v.rsp.update.run_time = running_counts / (TIMER_RATE / 10000); lfsm_user_set_tx_v1 (&user_tx_v1); break; diff --git a/flight/AHRS/ahrs_timer.c b/flight/AHRS/ahrs_timer.c index 76e18bc10..9fd25dfb8 100644 --- a/flight/AHRS/ahrs_timer.c +++ b/flight/AHRS/ahrs_timer.c @@ -33,7 +33,6 @@ #include "ahrs_timer.h" -#define TIMER_RATE (8e6 / 128) void timer_start() { RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE); diff --git a/flight/AHRS/inc/ahrs_timer.h b/flight/AHRS/inc/ahrs_timer.h index 991fa4c61..dbfa694ee 100644 --- a/flight/AHRS/inc/ahrs_timer.h +++ b/flight/AHRS/inc/ahrs_timer.h @@ -36,6 +36,8 @@ #include +#define TIMER_RATE (8e6 / 128) + void timer_start(); uint32_t timer_count(); uint32_t timer_rate(); diff --git a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c index 2927d6a21..4c961d3c9 100644 --- a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c +++ b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c @@ -480,6 +480,8 @@ static void process_update(struct opahrs_msg_v1_rsp_update * update) AhrsStatusData status; AhrsStatusGet(&status); status.CPULoad = update->load; + status.IdleTimePerCyle = update->idle_time; + status.RunningTimePerCyle = update->run_time; AhrsStatusSet(&status); } diff --git a/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h b/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h index e225c1de8..1f3dbbbbc 100644 --- a/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h +++ b/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h @@ -41,7 +41,7 @@ #define AHRSSTATUS_H // Object constants -#define AHRSSTATUS_OBJID 3393301276U +#define AHRSSTATUS_OBJID 1854089084U #define AHRSSTATUS_NAME "AhrsStatus" #define AHRSSTATUS_METANAME "AhrsStatusMeta" #define AHRSSTATUS_ISSINGLEINST 1 @@ -73,6 +73,8 @@ typedef struct { uint8_t SerialNumber[25]; uint8_t CPULoad; + uint8_t IdleTimePerCyle; + uint8_t RunningTimePerCyle; uint8_t CommErrors[5]; uint8_t AlgorithmSet; uint8_t CalibrationSet; @@ -85,6 +87,8 @@ typedef struct { /* Number of elements for field SerialNumber */ #define AHRSSTATUS_SERIALNUMBER_NUMELEM 25 // Field CPULoad information +// Field IdleTimePerCyle information +// Field RunningTimePerCyle information // Field CommErrors information /* Array element names for field CommErrors */ typedef enum { AHRSSTATUS_COMMERRORS_ALGORITHM=0, AHRSSTATUS_COMMERRORS_UPDATE=1, AHRSSTATUS_COMMERRORS_ATTITUDERAW=2, AHRSSTATUS_COMMERRORS_HOMELOCATION=3, AHRSSTATUS_COMMERRORS_CALIBRATION=4 } AhrsStatusCommErrorsElem; diff --git a/flight/PiOS/inc/pios_opahrs_proto.h b/flight/PiOS/inc/pios_opahrs_proto.h index 494a27b9c..67fd6b1d6 100644 --- a/flight/PiOS/inc/pios_opahrs_proto.h +++ b/flight/PiOS/inc/pios_opahrs_proto.h @@ -304,6 +304,8 @@ struct opahrs_msg_v1_rsp_update { float NED[3]; float Vel[3]; uint8_t load; + uint8_t idle_time; + uint8_t run_time; } __attribute__((__packed__)); struct opahrs_msg_v1_rsp_calibration { diff --git a/ground/src/plugins/uavobjects/ahrsstatus.cpp b/ground/src/plugins/uavobjects/ahrsstatus.cpp index bdc08b3e2..bfb05bbb2 100644 --- a/ground/src/plugins/uavobjects/ahrsstatus.cpp +++ b/ground/src/plugins/uavobjects/ahrsstatus.cpp @@ -72,6 +72,12 @@ AhrsStatus::AhrsStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) QStringList CPULoadElemNames; CPULoadElemNames.append("0"); fields.append( new UAVObjectField(QString("CPULoad"), QString("count"), UAVObjectField::UINT8, CPULoadElemNames, QStringList()) ); + QStringList IdleTimePerCyleElemNames; + IdleTimePerCyleElemNames.append("0"); + fields.append( new UAVObjectField(QString("IdleTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, IdleTimePerCyleElemNames, QStringList()) ); + QStringList RunningTimePerCyleElemNames; + RunningTimePerCyleElemNames.append("0"); + fields.append( new UAVObjectField(QString("RunningTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, RunningTimePerCyleElemNames, QStringList()) ); QStringList CommErrorsElemNames; CommErrorsElemNames.append("Algorithm"); CommErrorsElemNames.append("Update"); diff --git a/ground/src/plugins/uavobjects/ahrsstatus.h b/ground/src/plugins/uavobjects/ahrsstatus.h index 14eb6b13d..554c993d9 100644 --- a/ground/src/plugins/uavobjects/ahrsstatus.h +++ b/ground/src/plugins/uavobjects/ahrsstatus.h @@ -45,6 +45,8 @@ public: typedef struct { quint8 SerialNumber[25]; quint8 CPULoad; + quint8 IdleTimePerCyle; + quint8 RunningTimePerCyle; quint8 CommErrors[5]; quint8 AlgorithmSet; quint8 CalibrationSet; @@ -57,6 +59,8 @@ public: /* Number of elements for field SerialNumber */ static const quint32 SERIALNUMBER_NUMELEM = 25; // Field CPULoad information + // Field IdleTimePerCyle information + // Field RunningTimePerCyle information // Field CommErrors information /* Array element names for field CommErrors */ typedef enum { COMMERRORS_ALGORITHM=0, COMMERRORS_UPDATE=1, COMMERRORS_ATTITUDERAW=2, COMMERRORS_HOMELOCATION=3, COMMERRORS_CALIBRATION=4 } CommErrorsElem; @@ -74,7 +78,7 @@ public: // Constants - static const quint32 OBJID = 3393301276U; + static const quint32 OBJID = 1854089084U; static const QString NAME; static const bool ISSINGLEINST = 1; static const bool ISSETTINGS = 0; diff --git a/ground/src/plugins/uavobjects/ahrsstatus.py b/ground/src/plugins/uavobjects/ahrsstatus.py index dd4fc4f78..0d90eb89b 100644 --- a/ground/src/plugins/uavobjects/ahrsstatus.py +++ b/ground/src/plugins/uavobjects/ahrsstatus.py @@ -81,6 +81,26 @@ _fields = [ \ { } ), + uavobject.UAVObjectField( + 'IdleTimePerCyle', + 'B', + 1, + [ + '0', + ], + { + } + ), + uavobject.UAVObjectField( + 'RunningTimePerCyle', + 'B', + 1, + [ + '0', + ], + { + } + ), uavobject.UAVObjectField( 'CommErrors', 'B', @@ -136,7 +156,7 @@ _fields = [ \ class AhrsStatus(uavobject.UAVObject): ## Object constants - OBJID = 3393301276 + OBJID = 1854089084 NAME = "AhrsStatus" METANAME = "AhrsStatusMeta" ISSINGLEINST = 1 diff --git a/ground/src/shared/uavobjectdefinition/ahrsstatus.xml b/ground/src/shared/uavobjectdefinition/ahrsstatus.xml index 11568d370..9616241c5 100644 --- a/ground/src/shared/uavobjectdefinition/ahrsstatus.xml +++ b/ground/src/shared/uavobjectdefinition/ahrsstatus.xml @@ -3,6 +3,8 @@ Status for the @ref AHRSCommsModule, including communication errors + +