From dfb21482f467f426d46d5b719f8ae89d24579548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=A9=20Olivier?= Date: Fri, 8 Aug 2014 13:14:39 +0200 Subject: [PATCH] DSM protocol improvement added item in DSM protocol in GCS --- flight/pios/inc/pios_dsm_priv.h | 3 +- flight/pios/stm32f4xx/pios_dsm.c | 41 +++++-------------- .../coptercontrol/firmware/pios_board.c | 10 +++-- .../boards/revolution/firmware/pios_board.c | 20 ++++++--- .../plugins/setupwizard/connectiondiagram.cpp | 3 +- .../plugins/setupwizard/pages/inputpage.cpp | 18 +++++--- .../src/plugins/setupwizard/setupwizard.cpp | 11 +++-- .../vehicleconfigurationhelper.cpp | 17 +++++--- .../setupwizard/vehicleconfigurationsource.h | 2 +- shared/uavobjectdefinition/hwsettings.xml | 14 +++---- 10 files changed, 76 insertions(+), 63 deletions(-) diff --git a/flight/pios/inc/pios_dsm_priv.h b/flight/pios/inc/pios_dsm_priv.h index 1cdf88f75..d823b4f3d 100644 --- a/flight/pios/inc/pios_dsm_priv.h +++ b/flight/pios/inc/pios_dsm_priv.h @@ -111,7 +111,8 @@ /* DSM protocol variations */ enum pios_dsm_proto { - PIOS_DSM_PROTO_DSM2, + PIOS_DSM_PROTO_DSM210BIT, + PIOS_DSM_PROTO_DSM211BIT, PIOS_DSM_PROTO_DSMX10BIT, PIOS_DSM_PROTO_DSMX11BIT, }; diff --git a/flight/pios/stm32f4xx/pios_dsm.c b/flight/pios/stm32f4xx/pios_dsm.c index b6d8f0d85..70b32483d 100644 --- a/flight/pios/stm32f4xx/pios_dsm.c +++ b/flight/pios/stm32f4xx/pios_dsm.c @@ -181,7 +181,7 @@ static void PIOS_DSM_ResetState(struct pios_dsm_dev *dsm_dev) static int PIOS_DSM_UnrollChannels(struct pios_dsm_dev *dsm_dev) { struct pios_dsm_state *state = &(dsm_dev->state); - uint8_t resolution; + uint8_t resolution=10; #ifdef DSM_LOST_FRAME_COUNTER /* increment the lost frame counter */ @@ -191,35 +191,16 @@ static int PIOS_DSM_UnrollChannels(struct pios_dsm_dev *dsm_dev) #endif /* check the frame type assuming master satellite stream */ - uint8_t type = state->received_data[1]; - switch (type) { - case 0x01: - case 0x02: - case 0x12: - /* DSM2, DSMJ stream */ - if (dsm_dev->proto == PIOS_DSM_PROTO_DSM2) { - /* DSM2/DSMJ resolution is known from the header */ - resolution = (type & DSM_DSM2_RES_MASK) ? 11 : 10; - } else { - /* DSMX resolution should explicitly be selected */ - goto stream_error; - } - break; - case 0xA2: - case 0xB2: - /* DSMX stream */ - if (dsm_dev->proto == PIOS_DSM_PROTO_DSMX10BIT) { - resolution = 10; - } else if (dsm_dev->proto == PIOS_DSM_PROTO_DSMX11BIT) { - resolution = 11; - } else { - /* DSMX resolution should explicitly be selected */ - goto stream_error; - } - break; - default: - /* unknown yet data stream */ - goto stream_error; + + switch(dsm_dev->proto) { + case PIOS_DSM_PROTO_DSM210BIT: + case PIOS_DSM_PROTO_DSMX10BIT: + resolution = 10; + break; + case PIOS_DSM_PROTO_DSM211BIT: + case PIOS_DSM_PROTO_DSMX11BIT: + resolution = 11; + break; } /* unroll channels */ diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 2cb1734ff..35029acd6 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -477,15 +477,19 @@ void PIOS_Board_Init(void) } #endif /* PIOS_INCLUDE_GPS */ break; - case HWSETTINGS_CC_MAINPORT_DSM2: + case HWSETTINGS_CC_MAINPORT_DSM210BIT: + case HWSETTINGS_CC_MAINPORT_DSM211BIT: case HWSETTINGS_CC_MAINPORT_DSMX10BIT: case HWSETTINGS_CC_MAINPORT_DSMX11BIT: #if defined(PIOS_INCLUDE_DSM) { enum pios_dsm_proto proto; switch (hwsettings_cc_mainport) { - case HWSETTINGS_CC_MAINPORT_DSM2: - proto = PIOS_DSM_PROTO_DSM2; + case HWSETTINGS_CC_MAINPORT_DSM210BIT: + proto = PIOS_DSM_PROTO_DSM210BIT; + break; + case HWSETTINGS_CC_MAINPORT_DSM211BIT: + proto = PIOS_DSM_PROTO_DSM211BIT; break; case HWSETTINGS_CC_MAINPORT_DSMX10BIT: proto = PIOS_DSM_PROTO_DSMX10BIT; diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 4901cc432..ebbedfb19 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -624,14 +624,18 @@ void PIOS_Board_Init(void) } #endif break; - case HWSETTINGS_RM_MAINPORT_DSM2: + case HWSETTINGS_RM_MAINPORT_DSM210BIT: + case HWSETTINGS_RM_MAINPORT_DSM211BIT: case HWSETTINGS_RM_MAINPORT_DSMX10BIT: case HWSETTINGS_RM_MAINPORT_DSMX11BIT: { enum pios_dsm_proto proto; switch (hwsettings_mainport) { - case HWSETTINGS_RM_MAINPORT_DSM2: - proto = PIOS_DSM_PROTO_DSM2; + case HWSETTINGS_RM_MAINPORT_DSM210BIT: + proto = PIOS_DSM_PROTO_DSM210BIT; + break; + case HWSETTINGS_RM_MAINPORT_DSM211BIT: + proto = PIOS_DSM_PROTO_DSM211BIT; break; case HWSETTINGS_RM_MAINPORT_DSMX10BIT: proto = PIOS_DSM_PROTO_DSMX10BIT; @@ -693,14 +697,18 @@ void PIOS_Board_Init(void) case HWSETTINGS_RM_FLEXIPORT_GPS: PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id); break; - case HWSETTINGS_RM_FLEXIPORT_DSM2: + case HWSETTINGS_RM_FLEXIPORT_DSM210BIT: + case HWSETTINGS_RM_FLEXIPORT_DSM211BIT: case HWSETTINGS_RM_FLEXIPORT_DSMX10BIT: case HWSETTINGS_RM_FLEXIPORT_DSMX11BIT: { enum pios_dsm_proto proto; switch (hwsettings_flexiport) { - case HWSETTINGS_RM_FLEXIPORT_DSM2: - proto = PIOS_DSM_PROTO_DSM2; + case HWSETTINGS_RM_FLEXIPORT_DSM210BIT: + proto = PIOS_DSM_PROTO_DSM210BIT; + break; + case HWSETTINGS_RM_FLEXIPORT_DSM211BIT: + proto = PIOS_DSM_PROTO_DSM211BIT; break; case HWSETTINGS_RM_FLEXIPORT_DSMX10BIT: proto = PIOS_DSM_PROTO_DSMX10BIT; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp index 22b85bdd3..8b1f56d92 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp @@ -139,7 +139,8 @@ void ConnectionDiagram::setupGraphicsScene() break; case VehicleConfigurationSource::INPUT_DSMX10: case VehicleConfigurationSource::INPUT_DSMX11: - case VehicleConfigurationSource::INPUT_DSM2: + case VehicleConfigurationSource::INPUT_DSM2_10: + case VehicleConfigurationSource::INPUT_DSM2_11: elementsToShow << "satellite"; break; default: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/inputpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/inputpage.cpp index 5515a31dd..5c9ec16b7 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/inputpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/inputpage.cpp @@ -54,7 +54,7 @@ bool InputPage::validatePage() } else if (ui->sbusButton->isChecked()) { getWizard()->setInputType(SetupWizard::INPUT_SBUS); } else if (ui->spectrumButton->isChecked()) { - getWizard()->setInputType(SetupWizard::INPUT_DSM2); + getWizard()->setInputType(SetupWizard::INPUT_DSM2_11); } else { getWizard()->setInputType(SetupWizard::INPUT_PWM); } @@ -85,9 +85,13 @@ bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedTyp case VehicleConfigurationSource::INPUT_SBUS: return data.CC_MainPort != HwSettings::CC_MAINPORT_SBUS; - case VehicleConfigurationSource::INPUT_DSM2: + case VehicleConfigurationSource::INPUT_DSM2_10: // TODO: Handle all of the DSM types ?? Which is most common? - return data.CC_MainPort != HwSettings::CC_MAINPORT_DSM2; + return data.CC_MainPort != HwSettings::CC_MAINPORT_DSM210BIT; + + case VehicleConfigurationSource::INPUT_DSM2_11: + // TODO: Handle all of the DSM types ?? Which is most common? + return data.CC_MainPort != HwSettings::CC_MAINPORT_DSM211BIT; default: return true; } @@ -105,9 +109,13 @@ bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedTyp case VehicleConfigurationSource::INPUT_SBUS: return data.RM_MainPort != HwSettings::CC_MAINPORT_SBUS; - case VehicleConfigurationSource::INPUT_DSM2: + case VehicleConfigurationSource::INPUT_DSM2_10: // TODO: Handle all of the DSM types ?? Which is most common? - return data.RM_MainPort != HwSettings::CC_MAINPORT_DSM2; + return data.RM_MainPort != HwSettings::CC_MAINPORT_DSM210BIT; + + case VehicleConfigurationSource::INPUT_DSM2_11: + // TODO: Handle all of the DSM types ?? Which is most common? + return data.RM_MainPort != HwSettings::CC_MAINPORT_DSM211BIT; default: return true; } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 1657ca526..cc2cfd253 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -252,14 +252,17 @@ QString SetupWizard::getSummaryText() case INPUT_SBUS: summary.append(tr("Futaba S.Bus")); break; - case INPUT_DSM2: - summary.append(tr("Spektrum satellite (DSM2)")); + case INPUT_DSM2_10: + summary.append(tr("Spektrum satellite (DSM2 10bits)")); + break; + case INPUT_DSM2_11: + summary.append(tr("Spektrum satellite (DSM2 11bits)")); break; case INPUT_DSMX10: - summary.append(tr("Spektrum satellite (DSMX10BIT)")); + summary.append(tr("Spektrum satellite (DSMX 10bits)")); break; case INPUT_DSMX11: - summary.append(tr("Spektrum satellite (DSMX11BIT)")); + summary.append(tr("Spektrum satellite (DSMX 11bits)")); break; default: summary.append(tr("Unknown")); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 119d58120..a318d2fd4 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -139,8 +139,11 @@ void VehicleConfigurationHelper::applyHardwareConfiguration() case VehicleConfigurationSource::INPUT_DSMX11: data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSMX11BIT; break; - case VehicleConfigurationSource::INPUT_DSM2: - data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSM2; + case VehicleConfigurationSource::INPUT_DSM2_10: + data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSM210BIT; + break; + case VehicleConfigurationSource::INPUT_DSM2_11: + data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSM211BIT; break; default: break; @@ -172,8 +175,11 @@ void VehicleConfigurationHelper::applyHardwareConfiguration() case VehicleConfigurationSource::INPUT_DSMX11: data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSMX11BIT; break; - case VehicleConfigurationSource::INPUT_DSM2: - data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSM2; + case VehicleConfigurationSource::INPUT_DSM2_10: + data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSM210BIT; + break; + case VehicleConfigurationSource::INPUT_DSM2_11: + data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSM211BIT; break; default: break; @@ -486,7 +492,8 @@ void VehicleConfigurationHelper::applyManualControlDefaults() break; case VehicleConfigurationSource::INPUT_DSMX10: case VehicleConfigurationSource::INPUT_DSMX11: - case VehicleConfigurationSource::INPUT_DSM2: + case VehicleConfigurationSource::INPUT_DSM2_10: + case VehicleConfigurationSource::INPUT_DSM2_11: channelType = ManualControlSettings::CHANNELGROUPS_DSMMAINPORT; break; default: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h index 797283656..3c0399421 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -62,7 +62,7 @@ public: MULTI_ROTOR_OCTO_X, MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS, FIXED_WING_AILERON, FIXED_WING_VTAIL, HELI_CCPM }; enum ESC_TYPE { ESC_RAPID, ESC_LEGACY, ESC_UNKNOWN }; - enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSMX10, INPUT_DSMX11, INPUT_DSM2, INPUT_UNKNOWN }; + enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSMX10, INPUT_DSMX11, INPUT_DSM2_10, INPUT_DSM2_11, INPUT_UNKNOWN }; enum GPS_SETTING { GPS_UBX, GPS_NMEA, GPS_DISABLED }; enum RADIO_SETTING { RADIO_TELEMETRY, RADIO_DISABLED }; diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index f005a31ab..556397340 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -2,19 +2,19 @@ Selection of optional hardware configurations. - - + + - - - + + + - - + +