From 764520980981f49b9988138b1c82fa20db0cf362 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 7 May 2014 20:11:24 +0200 Subject: [PATCH 1/6] OP-1329 Various fixes to airspeed: - Prevent Airspeed module with Sensor=none from constantly running and updating AirspeedSensor - Do not call gps_airspeedInitialize if not needed --- flight/modules/Airspeed/airspeed.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index 8f368bef7..92fe7bcf7 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -137,17 +137,14 @@ MODULE_INITCALL(AirspeedInitialize, AirspeedStart); static void airspeedTask(__attribute__((unused)) void *parameters) { AirspeedSettingsUpdatedCb(AirspeedSettingsHandle()); - + bool gpsAirspeedInitialized = false; AirspeedSensorData airspeedData; AirspeedSensorGet(&airspeedData); AirspeedSettingsUpdatedCb(NULL); - gps_airspeedInitialize(); - airspeedData.SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_FALSE; - // Main task loop portTickType lastSysTime = xTaskGetTickCount(); while (1) { @@ -161,7 +158,12 @@ static void airspeedTask(__attribute__((unused)) void *parameters) AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); lastAirspeedSensorType = airspeedSettings.AirspeedSensorType; } - + if(airspeedSettings.AirspeedSensorType == AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE){ + // no need to check so often until a sensor is enabled + AirspeedAlarm(SYSTEMALARMS_ALARM_DEFAULT); + vTaskDelay(5000/ portTICK_RATE_MS); + continue; + } switch (airspeedSettings.AirspeedSensorType) { #if defined(PIOS_INCLUDE_MPXV) case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_DIYDRONESMPXV7002: @@ -183,6 +185,10 @@ static void airspeedTask(__attribute__((unused)) void *parameters) break; #endif case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_GROUNDSPEEDBASEDWINDESTIMATION: + if(!gpsAirspeedInitialized){ + gpsAirspeedInitialized = true; + gps_airspeedInitialize(); + } gps_airspeedGet(&airspeedData, &airspeedSettings); break; case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE: From 2ceef9ce864087306a3bd360543093ddbba168c1 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 7 May 2014 22:47:50 +0200 Subject: [PATCH 2/6] OP-1326 Change default airspeed sensor to "None" --- shared/uavobjectdefinition/airspeedsettings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/uavobjectdefinition/airspeedsettings.xml b/shared/uavobjectdefinition/airspeedsettings.xml index fbfce3e91..0c438afa5 100644 --- a/shared/uavobjectdefinition/airspeedsettings.xml +++ b/shared/uavobjectdefinition/airspeedsettings.xml @@ -4,7 +4,7 @@ - + From 516f359645f4bebf19143977c7762ed11636a940 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 7 May 2014 23:23:51 +0200 Subject: [PATCH 3/6] OP-1329 fix a cherry-pick issue --- flight/modules/Airspeed/airspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index 92fe7bcf7..9aba9fb72 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -160,7 +160,7 @@ static void airspeedTask(__attribute__((unused)) void *parameters) } if(airspeedSettings.AirspeedSensorType == AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE){ // no need to check so often until a sensor is enabled - AirspeedAlarm(SYSTEMALARMS_ALARM_DEFAULT); + AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); vTaskDelay(5000/ portTICK_RATE_MS); continue; } From 08dcdefc1f69be7197901d61b458fccad6c292e4 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 8 May 2014 19:48:30 +0200 Subject: [PATCH 4/6] OP-1329 set SensorConnected to false when sensorType is changed to none. --- flight/modules/Airspeed/airspeed.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index 9aba9fb72..25e6821a5 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -157,13 +157,11 @@ static void airspeedTask(__attribute__((unused)) void *parameters) if (airspeedSettings.AirspeedSensorType != lastAirspeedSensorType) { AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); lastAirspeedSensorType = airspeedSettings.AirspeedSensorType; + if (airspeedSettings.AirspeedSensorType == AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE) { + airspeedData.SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_FALSE; + AirspeedSensorSet(&airspeedData); + } } - if(airspeedSettings.AirspeedSensorType == AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE){ - // no need to check so often until a sensor is enabled - AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); - vTaskDelay(5000/ portTICK_RATE_MS); - continue; - } switch (airspeedSettings.AirspeedSensorType) { #if defined(PIOS_INCLUDE_MPXV) case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_DIYDRONESMPXV7002: @@ -185,13 +183,17 @@ static void airspeedTask(__attribute__((unused)) void *parameters) break; #endif case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_GROUNDSPEEDBASEDWINDESTIMATION: - if(!gpsAirspeedInitialized){ - gpsAirspeedInitialized = true; - gps_airspeedInitialize(); - } + if (!gpsAirspeedInitialized) { + gpsAirspeedInitialized = true; + gps_airspeedInitialize(); + } gps_airspeedGet(&airspeedData, &airspeedSettings); break; case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE: + // no need to check so often until a sensor is enabled + AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); + vTaskDelay(2000 / portTICK_RATE_MS); + continue; default: airspeedData.SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_FALSE; break; From 3a451c97373012ee92e15b791fd4bcc2dcdcf88b Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 8 May 2014 19:58:42 +0200 Subject: [PATCH 5/6] OP-1329 Trigger a SensorType change the first time Task runs to set AirspeedSensor UAVO when sensor is None --- flight/modules/Airspeed/airspeed.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index 25e6821a5..5b449f69c 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -60,7 +60,7 @@ static xTaskHandle taskHandle; static bool airspeedEnabled = false; static AirspeedSettingsData airspeedSettings; -static AirspeedSettingsAirspeedSensorTypeOptions lastAirspeedSensorType = 0; +static AirspeedSettingsAirspeedSensorTypeOptions lastAirspeedSensorType = -1; static int8_t airspeedADCPin = -1; @@ -119,8 +119,6 @@ int32_t AirspeedInitialize() } } - lastAirspeedSensorType = airspeedSettings.AirspeedSensorType; - AirspeedSensorInitialize(); AirspeedSettingsInitialize(); From 7155805b79d2b27ae528fee5700f2c1d6d0eb012 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 11 May 2014 11:33:11 +0200 Subject: [PATCH 6/6] OP-1329 Move gps airspeed initialization checks under "sensor changed" test --- flight/modules/Airspeed/airspeed.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index 5b449f69c..5cbe8e162 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -155,9 +155,19 @@ static void airspeedTask(__attribute__((unused)) void *parameters) if (airspeedSettings.AirspeedSensorType != lastAirspeedSensorType) { AlarmsSet(SYSTEMALARMS_ALARM_AIRSPEED, SYSTEMALARMS_ALARM_DEFAULT); lastAirspeedSensorType = airspeedSettings.AirspeedSensorType; - if (airspeedSettings.AirspeedSensorType == AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE) { + switch (airspeedSettings.AirspeedSensorType) { + case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE: + // AirspeedSensor will not be updated until a different sensor is selected + // set the disconencted satus now airspeedData.SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_FALSE; AirspeedSensorSet(&airspeedData); + break; + case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_GROUNDSPEEDBASEDWINDESTIMATION: + if (!gpsAirspeedInitialized) { + gpsAirspeedInitialized = true; + gps_airspeedInitialize(); + } + break; } } switch (airspeedSettings.AirspeedSensorType) { @@ -181,10 +191,6 @@ static void airspeedTask(__attribute__((unused)) void *parameters) break; #endif case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_GROUNDSPEEDBASEDWINDESTIMATION: - if (!gpsAirspeedInitialized) { - gpsAirspeedInitialized = true; - gps_airspeedInitialize(); - } gps_airspeedGet(&airspeedData, &airspeedSettings); break; case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_NONE: