From a454cf844bfb8f39f9ad65e105b9ac42ff29da96 Mon Sep 17 00:00:00 2001 From: sambas Date: Thu, 4 Aug 2011 19:20:05 +0300 Subject: [PATCH 01/18] DX8 support, BIND3 only --- flight/PiOS/STM32F10x/pios_spektrum.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flight/PiOS/STM32F10x/pios_spektrum.c b/flight/PiOS/STM32F10x/pios_spektrum.c index 8b0f38c6b..4206d80d7 100644 --- a/flight/PiOS/STM32F10x/pios_spektrum.c +++ b/flight/PiOS/STM32F10x/pios_spektrum.c @@ -8,7 +8,6 @@ * * @file pios_spektrum.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org) * @brief USART commands. Inits USARTs, controls USARTs & Interrupt handlers. (STM32 dependent) * @see The GNU Public License (GPL) Version 3 * @@ -172,9 +171,10 @@ static int32_t PIOS_SPEKTRUM_Decode(uint8_t b) CaptureValue[7]=b; } #endif - /* Known sync bytes, 0x01, 0x02, 0x12 */ + /* Known sync bytes, 0x01, 0x02, 0x12, 0xb2 */ + /* 0xb2 DX8 3bind pulses only */ if (bytecount == 2) { - if (b == 0x01) { + if ((b == 0x01) || (b == 0xb2)) { datalength=0; // 10bit //frames=1; sync = 1; @@ -234,17 +234,17 @@ static int32_t PIOS_SPEKTRUM_Decode(uint8_t b) *@brief clears the channel values */ static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id) { - /* 125hz */ + /* 625hz */ supv_timer++; - if(supv_timer > 5) { + if(supv_timer > 4) { /* sync between frames */ sync = 0; bytecount = 0; prev_byte = 0xFF; frame_error = 0; sync_of++; - /* watchdog activated after 100ms silence */ - if (sync_of > 12) { + /* watchdog activated after 200ms silence */ + if (sync_of > 30) { /* signal lost */ sync_of = 0; for (int i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS; i++) { From 1e67b5e3b5c2d7b07f40a8f74aceb3f8ea16477c Mon Sep 17 00:00:00 2001 From: sambas Date: Sat, 6 Aug 2011 22:16:47 +0300 Subject: [PATCH 02/18] DSMx_binder, hw setting 0 disabled, 1-10 bind pulses. Manual disable after successful bind. Only for flexiport. --- flight/CopterControl/System/pios_board.c | 6 ++++-- flight/PiOS/STM32F10x/pios_spektrum.c | 13 +++++++------ flight/PiOS/inc/pios_spektrum_priv.h | 2 +- shared/uavobjectdefinition/hwsettings.xml | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/flight/CopterControl/System/pios_board.c b/flight/CopterControl/System/pios_board.c index ee3deaf5c..d125e1cf6 100644 --- a/flight/CopterControl/System/pios_board.c +++ b/flight/CopterControl/System/pios_board.c @@ -921,6 +921,8 @@ void PIOS_Board_Init(void) { TaskMonitorInitialize(); /* Configure the main IO port */ + uint8_t hwsettings_DSMxBind; + HwSettingsDSMxBindGet(&hwsettings_DSMxBind); uint8_t hwsettings_cc_mainport; HwSettingsCC_MainPortGet(&hwsettings_cc_mainport); @@ -989,7 +991,7 @@ void PIOS_Board_Init(void) { } uint32_t pios_spektrum_id; - if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, false)) { + if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, 0)) { PIOS_Assert(0); } } @@ -1051,7 +1053,7 @@ void PIOS_Board_Init(void) { } uint32_t pios_spektrum_id; - if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_flexi_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, false)) { + if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_flexi_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, hwsettings_DSMxBind)) { PIOS_Assert(0); } } diff --git a/flight/PiOS/STM32F10x/pios_spektrum.c b/flight/PiOS/STM32F10x/pios_spektrum.c index 4206d80d7..9c81b6131 100644 --- a/flight/PiOS/STM32F10x/pios_spektrum.c +++ b/flight/PiOS/STM32F10x/pios_spektrum.c @@ -58,7 +58,7 @@ uint8_t sync_of = 0; uint16_t supv_timer=0; static void PIOS_SPEKTRUM_Supervisor(uint32_t spektrum_id); -static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg); +static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bind); static int32_t PIOS_SPEKTRUM_Decode(uint8_t b); static uint16_t PIOS_SPEKTRUM_RxInCallback(uint32_t context, uint8_t * buf, uint16_t buf_len, uint16_t * headroom, bool * need_yield) @@ -84,11 +84,11 @@ static uint16_t PIOS_SPEKTRUM_RxInCallback(uint32_t context, uint8_t * buf, uint /** * Bind and Initialise Spektrum satellite receiver */ -int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, bool bind) +int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t bind) { // TODO: need setting flag for bind on next powerup if (bind) { - PIOS_SPEKTRUM_Bind(cfg); + PIOS_SPEKTRUM_Bind(cfg,bind); } (driver->bind_rx_cb)(lower_id, PIOS_SPEKTRUM_RxInCallback, 0); @@ -120,9 +120,10 @@ static int32_t PIOS_SPEKTRUM_Get(uint32_t rcvr_id, uint8_t channel) * \output true Successful bind * \output false Bind failed */ -static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg) +static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bind) { -#define BIND_PULSES 5 + /* just to limit bind pulses */ + bind=(bind<=10)?bind:10; GPIO_Init(cfg->bind.gpio, &cfg->bind.init); /* RX line, set high */ @@ -131,7 +132,7 @@ static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg) /* on CC works upto 140ms, I guess bind window is around 20-140ms after powerup */ PIOS_DELAY_WaitmS(60); - for (int i = 0; i < BIND_PULSES ; i++) { + for (int i = 0; i < bind ; i++) { /* RX line, drive low for 120us */ GPIO_ResetBits(cfg->bind.gpio, cfg->bind.init.GPIO_Pin); PIOS_DELAY_WaituS(120); diff --git a/flight/PiOS/inc/pios_spektrum_priv.h b/flight/PiOS/inc/pios_spektrum_priv.h index 2d31a8027..ffd224e40 100644 --- a/flight/PiOS/inc/pios_spektrum_priv.h +++ b/flight/PiOS/inc/pios_spektrum_priv.h @@ -42,7 +42,7 @@ struct pios_spektrum_cfg { extern const struct pios_rcvr_driver pios_spektrum_rcvr_driver; -extern int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, bool bind); +extern int32_t PIOS_SPEKTRUM_Init(uint32_t * spektrum_id, const struct pios_spektrum_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id, uint8_t bind); #endif /* PIOS_PWM_PRIV_H */ diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index a3494f820..d8facecd9 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -1,8 +1,9 @@ Selection of optional hardware configurations. - - + + + From 9f35b6939c86a7df2906afe70ba6d0429180cec7 Mon Sep 17 00:00:00 2001 From: sambas Date: Sun, 7 Aug 2011 10:10:52 +0300 Subject: [PATCH 03/18] Bind IO fix --- flight/PiOS/STM32F10x/pios_spektrum.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flight/PiOS/STM32F10x/pios_spektrum.c b/flight/PiOS/STM32F10x/pios_spektrum.c index 9c81b6131..2d57d9900 100644 --- a/flight/PiOS/STM32F10x/pios_spektrum.c +++ b/flight/PiOS/STM32F10x/pios_spektrum.c @@ -122,6 +122,11 @@ static int32_t PIOS_SPEKTRUM_Get(uint32_t rcvr_id, uint8_t channel) */ static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bind) { + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.GPIO_Pin = cfg->bind.init.GPIO_Pin; + GPIO_InitStructure.GPIO_Speed = cfg->bind.init.GPIO_Speed; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + /* just to limit bind pulses */ bind=(bind<=10)?bind:10; @@ -141,6 +146,7 @@ static bool PIOS_SPEKTRUM_Bind(const struct pios_spektrum_cfg * cfg, uint8_t bin PIOS_DELAY_WaituS(120); } /* RX line, set input and wait for data, PIOS_SPEKTRUM_Init */ + GPIO_Init(cfg->bind.gpio, &GPIO_InitStructure); return true; } From 35eef66bfeb686a463abf40688c5c46889b0ba09 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 15 Aug 2011 10:24:37 -0500 Subject: [PATCH 04/18] OP-557: Add a UAVO access method to erase the entire flash chip. Normally not needed by users because if too much changes I change the FS magic and trigger a wipe. Possibly the erase should require a particular "magic" object id value to execute? This would make it harder to do manually through UAVOs though. --- flight/Modules/System/systemmod.c | 5 +++++ flight/PiOS/Common/pios_flashfs_objlist.c | 13 +++++++++++++ flight/PiOS/inc/pios_flashfs_objlist.h | 3 ++- shared/uavobjectdefinition/objectpersistence.xml | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/flight/Modules/System/systemmod.c b/flight/Modules/System/systemmod.c index f555d227f..e985da78d 100644 --- a/flight/Modules/System/systemmod.c +++ b/flight/Modules/System/systemmod.c @@ -230,6 +230,11 @@ static void objectUpdatedCb(UAVObjEvent * ev) || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS) { retval = UAVObjDeleteMetaobjects(); } + } else if (objper.Operation == OBJECTPERSISTENCE_OPERATION_FULLERASE) { + retval = -1; +#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS) + retval = PIOS_FLASHFS_Format(); +#endif } if(retval == 0) { objper.Operation = OBJECTPERSISTENCE_OPERATION_COMPLETED; diff --git a/flight/PiOS/Common/pios_flashfs_objlist.c b/flight/PiOS/Common/pios_flashfs_objlist.c index 08fe640c9..2b2fe06fa 100644 --- a/flight/PiOS/Common/pios_flashfs_objlist.c +++ b/flight/PiOS/Common/pios_flashfs_objlist.c @@ -116,6 +116,19 @@ int32_t PIOS_FLASHFS_Init() return 0; } +/** + * @brief Erase the whole flash chip and create the file system + * @return 0 if successful, -1 if not + */ +int32_t PIOS_FLASHFS_Format() +{ + if(PIOS_Flash_W25X_EraseChip() != 0) + return -1; + if(PIOS_FLASHFS_ClearObjectTableHeader() != 0) + return -1; + return 0; +} + /** * @brief Erase the headers for all objects in the flash chip * @return 0 if successful, -1 if not diff --git a/flight/PiOS/inc/pios_flashfs_objlist.h b/flight/PiOS/inc/pios_flashfs_objlist.h index 945df4068..f5c22d973 100644 --- a/flight/PiOS/inc/pios_flashfs_objlist.h +++ b/flight/PiOS/inc/pios_flashfs_objlist.h @@ -32,6 +32,7 @@ #include "uavobjectmanager.h" int32_t PIOS_FLASHFS_Init(); +int32_t PIOS_FLASHFS_Format(); int32_t PIOS_FLASHFS_ObjSave(UAVObjHandle obj, uint16_t instId, uint8_t * data); int32_t PIOS_FLASHFS_ObjLoad(UAVObjHandle obj, uint16_t instId, uint8_t * data); -int32_t PIOS_FLASHFS_ObjDelete(UAVObjHandle obj, uint16_t instId); \ No newline at end of file +int32_t PIOS_FLASHFS_ObjDelete(UAVObjHandle obj, uint16_t instId); diff --git a/shared/uavobjectdefinition/objectpersistence.xml b/shared/uavobjectdefinition/objectpersistence.xml index 94076de9a..aa7a58e8c 100644 --- a/shared/uavobjectdefinition/objectpersistence.xml +++ b/shared/uavobjectdefinition/objectpersistence.xml @@ -1,7 +1,7 @@ Someone who knows please enter this - + From 33e61b4405b7f05fd00119fd16d0608bcc1689f1 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 15 Aug 2011 10:55:36 -0500 Subject: [PATCH 05/18] OP-557: Make the tools erase menu item attempt to perform a full format on the flash chip first, then fall back to erasing settings via the EraseSettings object persistence. The later only removes UAVO instances that the firmware is current aware of, so can create issues when jumping between versions. --- .../src/plugins/config/configplugin.cpp | 76 ++++++++++++------- .../src/plugins/config/configplugin.h | 1 + 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configplugin.cpp b/ground/openpilotgcs/src/plugins/config/configplugin.cpp index dced1c231..622b3db9b 100644 --- a/ground/openpilotgcs/src/plugins/config/configplugin.cpp +++ b/ground/openpilotgcs/src/plugins/config/configplugin.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include "objectpersistence.h" ConfigPlugin::ConfigPlugin() { @@ -58,7 +58,7 @@ bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg) "ConfigPlugin.EraseAll", QList() << Core::Constants::C_GLOBAL_ID); - cmd->action()->setText("Erase all settings from board..."); + cmd->action()->setText(tr("Erase all settings from board...")); ac->menu()->addSeparator(); ac->appendGroup("Utilities"); @@ -80,6 +80,17 @@ bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg) return true; } +/** + * @brief Return handle to object manager + */ +UAVObjectManager * ConfigPlugin::getObjectManager() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager * objMngr = pm->getObject(); + Q_ASSERT(objMngr); + return objMngr; +} + void ConfigPlugin::extensionsInitialized() { cmd->action()->setEnabled(false); @@ -122,18 +133,19 @@ void ConfigPlugin::eraseAllSettings() return; settingsErased = false; - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager * objMngr = pm->getObject(); - Q_ASSERT(objMngr); - ObjectPersistence* objper = dynamic_cast( objMngr->getObject(ObjectPersistence::NAME) ); + ObjectPersistence* objper = ObjectPersistence::GetInstance(getObjectManager()); Q_ASSERT(objper); + connect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *))); - ObjectPersistence::DataFields data; - data.Operation = ObjectPersistence::OPERATION_DELETE; - data.Selection = ObjectPersistence::SELECTION_ALLSETTINGS; + + ObjectPersistence::DataFields data = objper->getData(); + data.Operation = ObjectPersistence::OPERATION_FULLERASE; + + // No need for manual updated event, this is triggered by setData + // based on UAVO meta data objper->setData(data); objper->updated(); - QTimer::singleShot(1500,this,SLOT(eraseFailed())); + QTimer::singleShot(6000,this,SLOT(eraseFailed())); } @@ -141,37 +153,47 @@ void ConfigPlugin::eraseFailed() { if (settingsErased) return; - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager * objMngr = pm->getObject(); - Q_ASSERT(objMngr); - ObjectPersistence* objper = dynamic_cast( objMngr->getObject(ObjectPersistence::NAME)); - disconnect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *))); - QMessageBox msgBox; - msgBox.setText(tr("Error trying to erase settings.")); - msgBox.setInformativeText(tr("Power-cycle your board. Settings might be inconsistent.")); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.exec(); + + ObjectPersistence* objper = ObjectPersistence::GetInstance(getObjectManager()); + + ObjectPersistence::DataFields data = objper->getData(); + if(data.Operation == ObjectPersistence::OPERATION_FULLERASE) { + // First attempt via flash erase failed. Fall back on erase all settings + data.Operation = ObjectPersistence::OPERATION_DELETE; + data.Selection = ObjectPersistence::SELECTION_ALLSETTINGS; + objper->setData(data); + objper->updated(); + QTimer::singleShot(1500,this,SLOT(eraseFailed())); + } else { + disconnect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *))); + QMessageBox msgBox; + msgBox.setText(tr("Error trying to erase settings.")); + msgBox.setInformativeText(tr("Power-cycle your board after removing all blades. Settings might be inconsistent.")); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); + } } void ConfigPlugin::eraseDone(UAVObject * obj) { QMessageBox msgBox; - ObjectPersistence* objper = dynamic_cast(sender()); - Q_ASSERT(obj->getName().compare("ObjectPersistence") == 0); - QString tmp = obj->getField("Operation")->getValue().toString(); - if (obj->getField("Operation")->getValue().toString().compare(QString("Delete")) == 0 ) { + ObjectPersistence* objper = ObjectPersistence::GetInstance(getObjectManager()); + ObjectPersistence::DataFields data = objper->getData(); + Q_ASSERT(obj->getInstID() == objper->getInstID()); + + if(data.Operation != ObjectPersistence::OPERATION_COMPLETED) { return; } disconnect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *))); - if (obj->getField("Operation")->getValue().toString().compare(QString("Completed")) == 0) { + if (data.Operation == ObjectPersistence::OPERATION_COMPLETED) { settingsErased = true; msgBox.setText(tr("Settings are now erased.")); msgBox.setInformativeText(tr("Please now power-cycle your board to complete reset.")); } else { msgBox.setText(tr("Error trying to erase settings.")); - msgBox.setInformativeText(tr("Power-cycle your board. Settings might be inconsistent.")); + msgBox.setInformativeText(tr("Power-cycle your board after removing all blades. Settings might be inconsistent.")); } msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); diff --git a/ground/openpilotgcs/src/plugins/config/configplugin.h b/ground/openpilotgcs/src/plugins/config/configplugin.h index f4fa677de..7091ad460 100644 --- a/ground/openpilotgcs/src/plugins/config/configplugin.h +++ b/ground/openpilotgcs/src/plugins/config/configplugin.h @@ -48,6 +48,7 @@ public: ConfigPlugin(); ~ConfigPlugin(); + UAVObjectManager * getObjectManager(); void extensionsInitialized(); bool initialize(const QStringList & arguments, QString * errorString); void shutdown(); From e4e952f27004d2a393b61b32959cd44d93037e17 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 21 Aug 2011 02:20:10 -0500 Subject: [PATCH 06/18] Manual control settings needs to be initialized in OpenPilot board file for spektrum to work --- flight/OpenPilot/System/pios_board.c | 1 + 1 file changed, 1 insertion(+) diff --git a/flight/OpenPilot/System/pios_board.c b/flight/OpenPilot/System/pios_board.c index f4ac5c367..12d365b67 100644 --- a/flight/OpenPilot/System/pios_board.c +++ b/flight/OpenPilot/System/pios_board.c @@ -1093,6 +1093,7 @@ void PIOS_Board_Init(void) { /* Configure the selected receiver */ uint8_t manualcontrolsettings_inputmode; + ManualControlSettingsInitialize(); ManualControlSettingsInputModeGet(&manualcontrolsettings_inputmode); switch (manualcontrolsettings_inputmode) { From b6b0703c284caebf6b86953391eb806aea178028 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sat, 20 Aug 2011 12:28:53 +1000 Subject: [PATCH 07/18] GCS: Fixed stabilization settings layout on a small screen. Put most of widgets into QScrollArea. It looks the same on large enough screen but scrollbars are added on netbook size screen. --- .../src/plugins/config/stabilization.ui | 1264 +++++++++-------- 1 file changed, 652 insertions(+), 612 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 96c414055..799c50880 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -6,649 +6,689 @@ 0 0 - 639 - 611 + 683 + 685 Form - + - + - + 0 - 0 + 1 - - - 0 - 150 - + + QFrame::NoFrame - - Rate Stabilization Coefficients (Inner Loop) + + true - - - - - Kp - - - Qt::AlignCenter - - - - - - - Ki - - - Qt::AlignCenter - - - - - - - ILimit - - - Qt::AlignCenter - - - - - - - Roll - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. + + + + 0 + 0 + 665 + 627 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 150 + + + + Rate Stabilization Coefficients (Inner Loop) + + + + + + Kp + + + Qt::AlignCenter + + + + + + + Ki + + + Qt::AlignCenter + + + + + + + ILimit + + + Qt::AlignCenter + + + + + + + Roll + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. Then lower the value by 20% or so. - - - 6 - - - 0.000100000000000 - - - - - - - I factor for rate stabilization is usually very low or even zero. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - If checked, the Roll and Pitch factors will be identical. + + + 6 + + + 0.000100000000000 + + + + + + + I factor for rate stabilization is usually very low or even zero. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + If checked, the Roll and Pitch factors will be identical. When you change one, the other is updated. - - - Link - - - - - - - Pitch - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. + + + Link + + + + + + + Pitch + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. Then lower the value by 20% or so. - - - 6 - - - 0.000100000000000 - - - - - - - I factor for rate stabilization is usually very low or even zero. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - Yaw - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. + + + 6 + + + 0.000100000000000 + + + + + + + I factor for rate stabilization is usually very low or even zero. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + Yaw + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. Then lower the value by 20% or so. You can usually go for higher values for Yaw factors. - - - 6 - - - 0.000100000000000 - - - - - - - As a rule of thumb, you can set YawRate Ki at roughly the same + + + 6 + + + 0.000100000000000 + + + + + + + As a rule of thumb, you can set YawRate Ki at roughly the same value as YawRate Kp. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 5 - - - - - - - - - 0 - 0 - - - - - 0 - 150 - - - - Attitude Stabization Coefficients (Outer Loop) - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 150 + + + + Attitude Stabization Coefficients (Outer Loop) + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - 6 - - - 0.100000000000000 - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust + + + 6 + + + 0.100000000000000 + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust depending on whether your airframe is well balanced, and your flying style. - - - 6 - - - 0.100000000000000 - - - - - - - Kp - - - Qt::AlignCenter - - - - - - - Ki - - - Qt::AlignCenter - - - - - - - ILimit - - - Qt::AlignCenter - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust + + + 6 + + + 0.100000000000000 + + + + + + + Kp + + + Qt::AlignCenter + + + + + + + Ki + + + Qt::AlignCenter + + + + + + + ILimit + + + Qt::AlignCenter + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust depending on whether your airframe is well balanced, and your flying style. - - - 6 - - - 0.100000000000000 - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + 6 + + + 0.100000000000000 + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - 6 - - - 0.100000000000000 - - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + 6 + + + 0.100000000000000 + + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - 6 - - - 0.100000000000000 - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Roll - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust + + + 6 + + + 0.100000000000000 + + + + + + + Yaw + + + + + + + Pitch + + + + + + + Roll + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust depending on whether your airframe is well balanced, and your flying style. - - - 6 - - - 0.100000000000000 - - - - - - - If checked, the Roll and Pitch factors will be identical. + + + 6 + + + 0.100000000000000 + + + + + + + If checked, the Roll and Pitch factors will be identical. When you change one, the other is updated. - - - Link - - - - + + + Link + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Stick range and limits + + + + QLayout::SetMinAndMaxSize + + + + + Roll + + + Qt::AlignCenter + + + + + + + Pitch + + + Qt::AlignCenter + + + + + + + Yaw + + + Qt::AlignCenter + + + + + + + 180 + + + + + + + 180 + + + + + + + 180 + + + + + + + + 150 + 0 + + + + + 50 + false + + + + Full stick angle (deg) + + + + + + + + 150 + 0 + + + + + 50 + false + + + + Full stick rate (deg/s) + + + + + + + 300 + + + + + + + 300 + + + + + + + 300 + + + + + + + + 150 + 0 + + + + + 50 + false + + + + + + + Maximum rate in attitude mode (deg/s) + + + + + + + 300 + + + + + + + 300 + + + + + + + 300 + + + + + + + + + + Zero the integral when throttle is low + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 5 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Stick range and limits - - - - QLayout::SetMinAndMaxSize - - - - - Roll - - - Qt::AlignCenter - - - - - - - Pitch - - - Qt::AlignCenter - - - - - - - Yaw - - - Qt::AlignCenter - - - - - - - 180 - - - - - - - 180 - - - - - - - 180 - - - - - - - - 150 - 0 - - - - - 50 - false - - - - Full stick angle (deg) - - - - - - - - 150 - 0 - - - - - 50 - false - - - - Full stick rate (deg/s) - - - - - - - 300 - - - - - - - 300 - - - - - - - 300 - - - - - - - - 150 - 0 - - - - - 50 - false - - - - - - - Maximum rate in attitude mode (deg/s) - - - - - - - 300 - - - - - - - 300 - - - - - - - 300 - - - - - - - - - - Zero the integral when throttle is low - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - From bbc137eabe0dc5ac62afa682710e4b8535dd415d Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 21 Aug 2011 21:36:41 +1000 Subject: [PATCH 08/18] Added initial CachedSvgItem implementation Texture is regenerated each time item is scaled but it's reused during rotation, unlike the default DeviceCoordinateCache mode. --- .../src/libs/utils/cachedsvgitem.cpp | 155 ++++++++++++++++++ .../src/libs/utils/cachedsvgitem.h | 52 ++++++ ground/openpilotgcs/src/libs/utils/utils.pro | 10 +- 3 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp create mode 100644 ground/openpilotgcs/src/libs/utils/cachedsvgitem.h diff --git a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp new file mode 100644 index 000000000..4fc80e6d2 --- /dev/null +++ b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp @@ -0,0 +1,155 @@ +/** + ****************************************************************************** + * + * @file cachedsvgitem.h + * @author Dmytro Poplavskiy Copyright (C) 2011. + * @{ + * @brief OpenGL texture cached SVG item + *****************************************************************************/ +/* + * 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 "cachedsvgitem.h" +#include +#include + +CachedSvgItem::CachedSvgItem(QGraphicsItem * parent) : + QGraphicsSvgItem(parent), + m_context(0), + m_texture(0), + m_scale(1.0) +{ + setCacheMode(NoCache); +} + +CachedSvgItem::CachedSvgItem(const QString & fileName, QGraphicsItem * parent): + QGraphicsSvgItem(fileName, parent), + m_context(0), + m_texture(0), + m_scale(1.0) +{ + setCacheMode(NoCache); +} + +CachedSvgItem::~CachedSvgItem() +{ + if (m_context && m_texture) { + m_context->makeCurrent(); + glDeleteTextures(1, &m_texture); + } +} + +void CachedSvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + + if (painter->paintEngine()->type() != QPaintEngine::OpenGL && + painter->paintEngine()->type() != QPaintEngine::OpenGL2) { + //Fallback to direct painting + QGraphicsSvgItem::paint(painter, option, widget); + return; + } + + QRectF br = boundingRect(); + QTransform transform = painter->worldTransform(); + qreal sceneScale = transform.map(QLineF(0,0,1,0)).length(); + + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + + painter->beginNativePainting(); + + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); + + bool dirty = false; + if (!m_texture) { + glGenTextures(1, &m_texture); + m_context = const_cast(QGLContext::currentContext()); + + dirty = true; + } + + if (!qFuzzyCompare(sceneScale, m_scale)) { + m_scale = sceneScale; + dirty = true; + } + + int textureWidth = (int(br.width()*m_scale) + 3) & ~3; + int textureHeight = (int(br.height()*m_scale) + 3) & ~3; + + if (dirty) { + //qDebug() << "re-render image"; + + QImage img(textureWidth, textureHeight, QImage::Format_ARGB32); + { + img.fill(Qt::transparent); + QPainter p; + p.begin(&img); + p.setRenderHints(painter->renderHints()); + p.translate(br.topLeft()); + p.scale(m_scale, m_scale); + QGraphicsSvgItem::paint(&p, option, 0); + p.end(); + + img = img.rgbSwapped(); + } + + glEnable(GL_TEXTURE_2D); + + glBindTexture(GL_TEXTURE_2D, m_texture); + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + textureWidth, + textureHeight, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + img.bits()); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glDisable(GL_TEXTURE_2D); + + dirty = false; + } + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + + glBindTexture(GL_TEXTURE_2D, m_texture); + + //texture may be slightly large than svn image, ensure only used area is rendered + qreal tw = br.width()*m_scale/textureWidth; + qreal th = br.height()*m_scale/textureHeight; + + glBegin(GL_QUADS); + glTexCoord2d(0, 0 ); glVertex3d(br.left(), br.top(), -1); + glTexCoord2d(tw, 0 ); glVertex3d(br.right(), br.top(), -1); + glTexCoord2d(tw, th); glVertex3d(br.right(), br.bottom(), -1); + glTexCoord2d(0, th); glVertex3d(br.left(), br.bottom(), -1); + glEnd(); + glDisable(GL_TEXTURE_2D); + + painter->endNativePainting(); +} diff --git a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h new file mode 100644 index 000000000..19f9fd4eb --- /dev/null +++ b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h @@ -0,0 +1,52 @@ +/** + ****************************************************************************** + * + * @file cachedsvgitem.h + * @author Dmytro Poplavskiy Copyright (C) 2011. + * @{ + * @brief OpenGL texture cached SVG item + *****************************************************************************/ +/* + * 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 CACHEDSVGITEM_H +#define CACHEDSVGITEM_H + +#include +#include + +class QGLContext; + +//Cache Svg item as GL Texture. +//Texture is regenerated each time item is scaled +//but it's reused during rotation, unlike DeviceCoordinateCache mode +class CachedSvgItem: public QGraphicsSvgItem +{ + Q_OBJECT +public: + CachedSvgItem(QGraphicsItem * parent = 0); + CachedSvgItem(const QString & fileName, QGraphicsItem * parent = 0); + ~CachedSvgItem(); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +private: + QGLContext *m_context; + GLuint m_texture; + qreal m_scale; +}; + +#endif diff --git a/ground/openpilotgcs/src/libs/utils/utils.pro b/ground/openpilotgcs/src/libs/utils/utils.pro index 804f7c813..003497b4d 100644 --- a/ground/openpilotgcs/src/libs/utils/utils.pro +++ b/ground/openpilotgcs/src/libs/utils/utils.pro @@ -3,7 +3,9 @@ TARGET = Utils QT += gui \ network \ - xml + xml \ + svg \ + opengl DEFINES += QTCREATOR_UTILS_LIB @@ -48,7 +50,8 @@ SOURCES += reloadpromptutils.cpp \ homelocationutil.cpp \ mytabbedstackwidget.cpp \ mytabwidget.cpp \ - mylistwidget.cpp + mylistwidget.cpp \ + cachedsvgitem.cpp SOURCES += xmlconfig.cpp win32 { @@ -102,7 +105,8 @@ HEADERS += utils_global.h \ homelocationutil.h \ mytabbedstackwidget.h \ mytabwidget.h \ - mylistwidget.h + mylistwidget.h \ + cachedsvgitem.h HEADERS += xmlconfig.h FORMS += filewizardpage.ui \ From 6b0da6bc72fc8ea5125a850dfe277e9a20856033 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 21 Aug 2011 21:38:58 +1000 Subject: [PATCH 09/18] Changed PFDGadgetWidget to use CachedSvgItem --- .../src/plugins/pfd/pfdgadgetwidget.cpp | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp index 079a206b5..a38e943a3 100644 --- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp @@ -27,6 +27,7 @@ #include "pfdgadgetwidget.h" #include +#include #include #include #include @@ -383,7 +384,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) - Battery stats: battery-txt */ l_scene->clear(); // Deletes all items contained in the scene as well. - m_background = new QGraphicsSvgItem(); + m_background = new CachedSvgItem(); // All other items will be clipped to the shape of the background m_background->setFlags(QGraphicsItem::ItemClipsChildrenToShape| QGraphicsItem::ItemClipsToShape); @@ -391,28 +392,28 @@ void PFDGadgetWidget::setDialFile(QString dfn) m_background->setElementId("background"); l_scene->addItem(m_background); - m_world = new QGraphicsSvgItem(); + m_world = new CachedSvgItem(); m_world->setParentItem(m_background); m_world->setSharedRenderer(m_renderer); m_world->setElementId("world"); l_scene->addItem(m_world); // red Roll scale: rollscale - m_rollscale = new QGraphicsSvgItem(); + m_rollscale = new CachedSvgItem(); m_rollscale->setSharedRenderer(m_renderer); m_rollscale->setElementId("rollscale"); l_scene->addItem(m_rollscale); // Home point: - m_homewaypoint = new QGraphicsSvgItem(); + m_homewaypoint = new CachedSvgItem(); // Next point: - m_nextwaypoint = new QGraphicsSvgItem(); + m_nextwaypoint = new CachedSvgItem(); // Home point bearing: - m_homepointbearing = new QGraphicsSvgItem(); + m_homepointbearing = new CachedSvgItem(); // Next point bearing: - m_nextpointbearing = new QGraphicsSvgItem(); + m_nextpointbearing = new CachedSvgItem(); - QGraphicsSvgItem *m_foreground = new QGraphicsSvgItem(); + QGraphicsSvgItem *m_foreground = new CachedSvgItem(); m_foreground->setParentItem(m_background); m_foreground->setSharedRenderer(m_renderer); m_foreground->setElementId("foreground"); @@ -429,7 +430,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) // into a QGraphicsSvgItem which we will display at the same // place: we do this so that the heading scale can be clipped to // the compass dial region. - m_compass = new QGraphicsSvgItem(); + m_compass = new CachedSvgItem(); m_compass->setSharedRenderer(m_renderer); m_compass->setElementId("compass"); m_compass->setFlags(QGraphicsItem::ItemClipsChildrenToShape| @@ -440,7 +441,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) m_compass->setTransform(matrix,false); // Now place the compass scale inside: - m_compassband = new QGraphicsSvgItem(); + m_compassband = new CachedSvgItem(); m_compassband->setSharedRenderer(m_renderer); m_compassband->setElementId("compass-band"); m_compassband->setParentItem(m_compass); @@ -462,7 +463,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) compassMatrix = m_renderer->matrixForElement("speed-bg"); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).y(); - QGraphicsSvgItem *verticalbg = new QGraphicsSvgItem(); + QGraphicsSvgItem *verticalbg = new CachedSvgItem(); verticalbg->setSharedRenderer(m_renderer); verticalbg->setElementId("speed-bg"); verticalbg->setFlags(QGraphicsItem::ItemClipsChildrenToShape| @@ -477,7 +478,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) m_speedscale = new QGraphicsItemGroup(); m_speedscale->setParentItem(verticalbg); - QGraphicsSvgItem *speedscalelines = new QGraphicsSvgItem(); + QGraphicsSvgItem *speedscalelines = new CachedSvgItem(); speedscalelines->setSharedRenderer(m_renderer); speedscalelines->setElementId("speed-scale"); speedScaleHeight = m_renderer->matrixForElement("speed-scale").mapRect( @@ -523,7 +524,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).y(); qreal speedWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).height(); - QGraphicsSvgItem *speedwindow = new QGraphicsSvgItem(); + QGraphicsSvgItem *speedwindow = new CachedSvgItem(); speedwindow->setSharedRenderer(m_renderer); speedwindow->setElementId("speed-window"); speedwindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape| @@ -548,7 +549,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) compassMatrix = m_renderer->matrixForElement("altitude-bg"); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-bg")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-bg")).y(); - verticalbg = new QGraphicsSvgItem(); + verticalbg = new CachedSvgItem(); verticalbg->setSharedRenderer(m_renderer); verticalbg->setElementId("altitude-bg"); verticalbg->setFlags(QGraphicsItem::ItemClipsChildrenToShape| @@ -563,7 +564,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) m_altitudescale = new QGraphicsItemGroup(); m_altitudescale->setParentItem(verticalbg); - QGraphicsSvgItem *altitudescalelines = new QGraphicsSvgItem(); + QGraphicsSvgItem *altitudescalelines = new CachedSvgItem(); altitudescalelines->setSharedRenderer(m_renderer); altitudescalelines->setElementId("altitude-scale"); altitudeScaleHeight = m_renderer->matrixForElement("altitude-scale").mapRect( @@ -604,7 +605,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).y(); qreal altitudeWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).height(); - QGraphicsSvgItem *altitudewindow = new QGraphicsSvgItem(); + QGraphicsSvgItem *altitudewindow = new CachedSvgItem(); altitudewindow->setSharedRenderer(m_renderer); altitudewindow->setElementId("altitude-window"); altitudewindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape| @@ -633,7 +634,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected"); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y(); - gcsTelemetryArrow = new QGraphicsSvgItem(); + gcsTelemetryArrow = new CachedSvgItem(); gcsTelemetryArrow->setSharedRenderer(m_renderer); gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected"); l_scene->addItem(gcsTelemetryArrow); @@ -669,7 +670,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected"); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y(); - gcsTelemetryArrow = new QGraphicsSvgItem(); + gcsTelemetryArrow = new CachedSvgItem(); gcsTelemetryArrow->setSharedRenderer(m_renderer); gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected"); l_scene->addItem(gcsTelemetryArrow); @@ -702,7 +703,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected"); startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x(); startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y(); - gcsTelemetryArrow = new QGraphicsSvgItem(); + gcsTelemetryArrow = new CachedSvgItem(); gcsTelemetryArrow->setSharedRenderer(m_renderer); gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected"); l_scene->addItem(gcsTelemetryArrow); @@ -771,7 +772,7 @@ void PFDGadgetWidget::setDialFile(QString dfn) { qDebug()<<"Error on PFD artwork file."; m_renderer->load(QString(":/pfd/images/pfd-default.svg")); l_scene->clear(); // This also deletes all items contained in the scene. - m_background = new QGraphicsSvgItem(); + m_background = new CachedSvgItem(); m_background->setSharedRenderer(m_renderer); l_scene->addItem(m_background); pfdError = true; From 69d5e7fe7e9d22ab62783c0065f549465101c247 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 21 Aug 2011 23:40:11 +1000 Subject: [PATCH 10/18] Added missing Q_DECL_EXPORT to CachedSvgItem --- ground/openpilotgcs/src/libs/utils/cachedsvgitem.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h index 19f9fd4eb..747ef391c 100644 --- a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h +++ b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.h @@ -28,12 +28,14 @@ #include #include +#include "utils_global.h" + class QGLContext; //Cache Svg item as GL Texture. //Texture is regenerated each time item is scaled //but it's reused during rotation, unlike DeviceCoordinateCache mode -class CachedSvgItem: public QGraphicsSvgItem +class QTCREATOR_UTILS_EXPORT CachedSvgItem: public QGraphicsSvgItem { Q_OBJECT public: From 0ce337b42d44ff42602d67befdfd5a50b343f5ad Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 21 Aug 2011 18:15:10 +0200 Subject: [PATCH 11/18] UAVTalk: fix off by one error preventing the largest UAvObject (gpssatellites) from being sent. --- flight/UAVTalk/inc/uavtalk_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/UAVTalk/inc/uavtalk_priv.h b/flight/UAVTalk/inc/uavtalk_priv.h index 1bcf01fd9..06f08b997 100644 --- a/flight/UAVTalk/inc/uavtalk_priv.h +++ b/flight/UAVTalk/inc/uavtalk_priv.h @@ -51,7 +51,7 @@ typedef struct { typedef uint8_t uavtalk_checksum; #define UAVTALK_CHECKSUM_LENGTH sizeof(uavtalk_checksum) -#define UAVTALK_MAX_PAYLOAD_LENGTH UAVOBJECTS_LARGEST +#define UAVTALK_MAX_PAYLOAD_LENGTH (UAVOBJECTS_LARGEST + 1) #define UAVTALK_MIN_PACKET_LENGTH UAVTALK_MAX_HEADER_LENGTH + UAVTALK_CHECKSUM_LENGTH #define UAVTALK_MAX_PACKET_LENGTH UAVTALK_MIN_PACKET_LENGTH + UAVTALK_MAX_PAYLOAD_LENGTH From 838149b53fcd19781723e94478549b52164a3e9e Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 21 Aug 2011 14:23:07 +0200 Subject: [PATCH 12/18] GPS: homelocation init is optional, satellites must be initialized --- flight/Modules/GPS/GPS.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 60ff80184..9bb873654 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -46,6 +46,7 @@ #include "gpsposition.h" #include "homelocation.h" #include "gpstime.h" +#include "gpssatellites.h" #include "WorldMagModel.h" #include "CoordinateConversions.h" @@ -126,7 +127,10 @@ int32_t GPSInitialize(void) { GPSPositionInitialize(); GPSTimeInitialize(); + GPSSatellitesInitialize(); +#ifdef PIOS_GPS_SETS_HOMELOCATION HomeLocationInitialize(); +#endif // TODO: Get gps settings object gpsPort = PIOS_COM_GPS; From 6e506161e0975915aaa536ff6ca4eb1410b27c9b Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Mon, 22 Aug 2011 06:59:34 +1000 Subject: [PATCH 13/18] Compilation fix It's necessary to include GL/glext.h on windows for GL_CLAMP_TO_EDGE define. --- ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp index 4fc80e6d2..93a38afb1 100644 --- a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp +++ b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp @@ -26,6 +26,8 @@ #include #include +#include + CachedSvgItem::CachedSvgItem(QGraphicsItem * parent) : QGraphicsSvgItem(parent), m_context(0), From ed51756191782579fd6811e986a74a61fe252ea2 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Mon, 22 Aug 2011 09:10:25 +1000 Subject: [PATCH 14/18] Compilation fix on mac It's safer to define GL_CLAMP_TO_EDGE if not available than to include GL/glext.h. --- ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp index 93a38afb1..2edef8ddf 100644 --- a/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp +++ b/ground/openpilotgcs/src/libs/utils/cachedsvgitem.cpp @@ -26,7 +26,9 @@ #include #include -#include +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif CachedSvgItem::CachedSvgItem(QGraphicsItem * parent) : QGraphicsSvgItem(parent), From 697ac6067e6eaca756a8175df8959ccc97abdfb8 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Thu, 25 Aug 2011 12:20:19 +0200 Subject: [PATCH 15/18] OP-567 Modules/GPS: Block in PIOS_COM, not in TaskDelay - or we will miss updates! --- flight/Modules/GPS/GPS.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 9bb873654..d2ab2b3c5 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -199,14 +199,12 @@ static void gpsTask(void *parameters) // Loop forever while (1) { + uint8_t c; #ifdef ENABLE_GPS_BINARY_GTOP // GTOP BINARY GPS mode - while (PIOS_COM_ReceiveBufferUsed(gpsPort) > 0) + while (PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, xDelay) > 0) { - uint8_t c; - PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, 0); - if (GTOP_BIN_update_position(c, &numChecksumErrors, &numParsingErrors) >= 0) { numUpdates++; @@ -221,10 +219,8 @@ static void gpsTask(void *parameters) // NMEA or SINGLE-SENTENCE GPS mode // This blocks the task until there is something on the buffer - while (PIOS_COM_ReceiveBufferUsed(gpsPort) > 0) + while (PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, xDelay) > 0) { - uint8_t c; - PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, 0); // detect start while acquiring stream if (!start_flag && (c == '$')) @@ -362,8 +358,6 @@ static void gpsTask(void *parameters) AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_CRITICAL); } - // Block task until next update - vTaskDelay(xDelay); } } From dfdea1606576e7261ca4d8aca0a0b7d6d3d96281 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Thu, 25 Aug 2011 14:46:30 +0200 Subject: [PATCH 16/18] Modules/GPS: Make GPS COM unidirectional (rx only) and use smaller, runtime allocated heap buffers --- flight/Modules/GPS/GPS.c | 252 +++++++------------- flight/Modules/GPS/GTOP_BIN.c | 262 --------------------- flight/Modules/GPS/NMEA.c | 171 +++----------- flight/Modules/GPS/inc/GPS.h | 2 - flight/Modules/GPS/inc/GTOP_BIN.h | 42 ---- flight/Modules/GPS/inc/NMEA.h | 7 +- flight/Modules/GPS/inc/gps_mode.h | 58 ----- flight/OpenPilot/System/pios_board.c | 5 +- flight/OpenPilot/System/pios_board_posix.c | 6 +- 9 files changed, 123 insertions(+), 682 deletions(-) delete mode 100644 flight/Modules/GPS/GTOP_BIN.c delete mode 100644 flight/Modules/GPS/inc/GTOP_BIN.h delete mode 100644 flight/Modules/GPS/inc/gps_mode.h diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index d2ab2b3c5..44b039eb1 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -35,13 +35,7 @@ #include -#ifdef ENABLE_GPS_BINARY_GTOP - #include "GTOP_BIN.h" -#endif - -#if defined(ENABLE_GPS_ONESENTENCE_GTOP) || defined(ENABLE_GPS_NMEA) - #include "NMEA.h" -#endif +#include "NMEA.h" #include "gpsposition.h" #include "homelocation.h" @@ -63,25 +57,16 @@ static float GravityAccel(float latitude, float longitude, float altitude); // **************** // Private constants -//#define FULL_COLD_RESTART // uncomment this to tell the GPS to do a FULL COLD restart -//#define DISABLE_GPS_THRESHOLD // - #define GPS_TIMEOUT_MS 500 -#define GPS_COMMAND_RESEND_TIMEOUT_MS 2000 +#define NMEA_MAX_PACKET_LENGTH 96 // 82 max NMEA msg size plus 12 margin (because some vendors add custom crap) plus CR plus Linefeed +// same as in COM buffer + #ifdef PIOS_GPS_SETS_HOMELOCATION // Unfortunately need a good size stack for the WMM calculation - #ifdef ENABLE_GPS_BINARY_GTOP - #define STACK_SIZE_BYTES 800 - #else - #define STACK_SIZE_BYTES 800 - #endif + #define STACK_SIZE_BYTES 800 #else - #ifdef ENABLE_GPS_BINARY_GTOP - #define STACK_SIZE_BYTES 440 - #else - #define STACK_SIZE_BYTES 440 - #endif + #define STACK_SIZE_BYTES 650 #endif #define TASK_PRIORITY (tskIDLE_PRIORITY + 1) @@ -93,9 +78,7 @@ static uint32_t gpsPort; static xTaskHandle gpsTaskHandle; -#ifndef ENABLE_GPS_BINARY_GTOP - static char gps_rx_buffer[128]; -#endif +static char* gps_rx_buffer; static uint32_t timeOfLastCommandMs; static uint32_t timeOfLastUpdateMs; @@ -135,6 +118,8 @@ int32_t GPSInitialize(void) // TODO: Get gps settings object gpsPort = PIOS_COM_GPS; + gps_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH); + return 0; } MODULE_INITCALL(GPSInitialize, GPSStart) @@ -150,45 +135,11 @@ static void gpsTask(void *parameters) uint32_t timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS;; GPSPositionData GpsData; -#ifdef ENABLE_GPS_BINARY_GTOP - GTOP_BIN_init(); -#else uint8_t rx_count = 0; bool start_flag = false; bool found_cr = false; int32_t gpsRxOverflow = 0; -#endif -#ifdef FULL_COLD_RESTART - // tell the GPS to do a FULL COLD restart - PIOS_COM_SendStringNonBlocking(gpsPort, "$PMTK104*37\r\n"); - timeOfLastCommandMs = timeNowMs; - while (timeNowMs - timeOfLastCommandMs < 300) // delay for 300ms to let the GPS sort itself out - { - vTaskDelay(xDelay); // Block task until next update - timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS;; - } -#endif - -#ifdef DISABLE_GPS_THRESHOLD - PIOS_COM_SendStringNonBlocking(gpsPort, "$PMTK397,0*23\r\n"); -#endif - -#ifdef ENABLE_GPS_BINARY_GTOP - // switch to GTOP binary mode - PIOS_COM_SendStringNonBlocking(gpsPort ,"$PGCMD,21,1*6F\r\n"); -#endif - -#ifdef ENABLE_GPS_ONESENTENCE_GTOP - // switch to single sentence mode - PIOS_COM_SendStringNonBlocking(gpsPort, "$PGCMD,21,2*6C\r\n"); -#endif - -#ifdef ENABLE_GPS_NMEA - // switch to NMEA mode - PIOS_COM_SendStringNonBlocking(gpsPort, "$PGCMD,21,3*6D\r\n"); -#endif - numUpdates = 0; numChecksumErrors = 0; numParsingErrors = 0; @@ -200,103 +151,86 @@ static void gpsTask(void *parameters) while (1) { uint8_t c; - #ifdef ENABLE_GPS_BINARY_GTOP - // GTOP BINARY GPS mode + // NMEA or SINGLE-SENTENCE GPS mode - while (PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, xDelay) > 0) + // This blocks the task until there is something on the buffer + while (PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, xDelay) > 0) + { + + // detect start while acquiring stream + if (!start_flag && (c == '$')) { - if (GTOP_BIN_update_position(c, &numChecksumErrors, &numParsingErrors) >= 0) - { - numUpdates++; + start_flag = true; + found_cr = false; + rx_count = 0; + } + else + if (!start_flag) + continue; + + if (rx_count >= NMEA_MAX_PACKET_LENGTH) + { + // The buffer is already full and we haven't found a valid NMEA sentence. + // Flush the buffer and note the overflow event. + gpsRxOverflow++; + start_flag = false; + found_cr = false; + rx_count = 0; + } + else + { + gps_rx_buffer[rx_count] = c; + rx_count++; + } + + // look for ending '\r\n' sequence + if (!found_cr && (c == '\r') ) + found_cr = true; + else + if (found_cr && (c != '\n') ) + found_cr = false; // false end flag + else + if (found_cr && (c == '\n') ) + { + // The NMEA functions require a zero-terminated string + // As we detected \r\n, the string as for sure 2 bytes long, we will also strip the \r\n + gps_rx_buffer[rx_count-2] = 0; + + // prepare to parse next sentence + start_flag = false; + found_cr = false; + rx_count = 0; + // Our rxBuffer must look like this now: + // [0] = '$' + // ... = zero or more bytes of sentence payload + // [end_pos - 1] = '\r' + // [end_pos] = '\n' + // + // Prepare to consume the sentence from the buffer + + // Validate the checksum over the sentence + if (!NMEA_checksum(&gps_rx_buffer[1])) + { // Invalid checksum. May indicate dropped characters on Rx. + //PIOS_DEBUG_PinHigh(2); + ++numChecksumErrors; + //PIOS_DEBUG_PinLow(2); + } + else + { // Valid checksum, use this packet to update the GPS position + if (!NMEA_update_position(&gps_rx_buffer[1])) { + //PIOS_DEBUG_PinHigh(2); + ++numParsingErrors; + //PIOS_DEBUG_PinLow(2); + } + else + ++numUpdates; timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; timeOfLastUpdateMs = timeNowMs; timeOfLastCommandMs = timeNowMs; } } - - #else - // NMEA or SINGLE-SENTENCE GPS mode - - // This blocks the task until there is something on the buffer - while (PIOS_COM_ReceiveBuffer(gpsPort, &c, 1, xDelay) > 0) - { - - // detect start while acquiring stream - if (!start_flag && (c == '$')) - { - start_flag = true; - found_cr = false; - rx_count = 0; - } - else - if (!start_flag) - continue; - - if (rx_count >= sizeof(gps_rx_buffer)) - { - // The buffer is already full and we haven't found a valid NMEA sentence. - // Flush the buffer and note the overflow event. - gpsRxOverflow++; - start_flag = false; - found_cr = false; - rx_count = 0; - } - else - { - gps_rx_buffer[rx_count] = c; - rx_count++; - } - - // look for ending '\r\n' sequence - if (!found_cr && (c == '\r') ) - found_cr = true; - else - if (found_cr && (c != '\n') ) - found_cr = false; // false end flag - else - if (found_cr && (c == '\n') ) - { - // The NMEA functions require a zero-terminated string - // As we detected \r\n, the string as for sure 2 bytes long, we will also strip the \r\n - gps_rx_buffer[rx_count-2] = 0; - - // prepare to parse next sentence - start_flag = false; - found_cr = false; - rx_count = 0; - // Our rxBuffer must look like this now: - // [0] = '$' - // ... = zero or more bytes of sentence payload - // [end_pos - 1] = '\r' - // [end_pos] = '\n' - // - // Prepare to consume the sentence from the buffer - - // Validate the checksum over the sentence - if (!NMEA_checksum(&gps_rx_buffer[1])) - { // Invalid checksum. May indicate dropped characters on Rx. - //PIOS_DEBUG_PinHigh(2); - ++numChecksumErrors; - //PIOS_DEBUG_PinLow(2); - } - else - { // Valid checksum, use this packet to update the GPS position - if (!NMEA_update_position(&gps_rx_buffer[1])) { - //PIOS_DEBUG_PinHigh(2); - ++numParsingErrors; - //PIOS_DEBUG_PinLow(2); - } - else - ++numUpdates; - - timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; - timeOfLastUpdateMs = timeNowMs; - timeOfLastCommandMs = timeNowMs; - } - } - } - #endif + } // Check for GPS timeout timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; @@ -309,30 +243,6 @@ static void gpsTask(void *parameters) GPSPositionSet(&GpsData); AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR); - if ((timeNowMs - timeOfLastCommandMs) >= GPS_COMMAND_RESEND_TIMEOUT_MS) - { // resend the command .. just incase the gps has only just been plugged in or the gps did not get our last command - timeOfLastCommandMs = timeNowMs; - - #ifdef ENABLE_GPS_BINARY_GTOP - GTOP_BIN_init(); - // switch to binary mode - PIOS_COM_SendStringNonBlocking(gpsPort,"$PGCMD,21,1*6F\r\n"); - #endif - - #ifdef ENABLE_GPS_ONESENTENCE_GTOP - // switch to single sentence mode - PIOS_COM_SendStringNonBlocking(gpsPort,"$PGCMD,21,2*6C\r\n"); - #endif - - #ifdef ENABLE_GPS_NMEA - // switch to NMEA mode - PIOS_COM_SendStringNonBlocking(gpsPort,"$PGCMD,21,3*6D\r\n"); - #endif - - #ifdef DISABLE_GPS_TRESHOLD - PIOS_COM_SendStringNonBlocking(gpsPort,"$PMTK397,0*23\r\n"); - #endif - } } else { // we appear to be receiving GPS sentences OK, we've had an update diff --git a/flight/Modules/GPS/GTOP_BIN.c b/flight/Modules/GPS/GTOP_BIN.c deleted file mode 100644 index 7bd2964d9..000000000 --- a/flight/Modules/GPS/GTOP_BIN.c +++ /dev/null @@ -1,262 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @{ - * @addtogroup GSPModule GPS Module - * @brief Process GPS information - * @{ - * - * @file GTOP_BIN.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief GPS module, handles GPS and NMEA stream - * @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 "pios.h" -#include "GTOP_BIN.h" -#include "gpsposition.h" -#include "gpstime.h" -#include "gpssatellites.h" - -#include // memmove - -#ifdef ENABLE_GPS_BINARY_GTOP - -// ************ -// the structure of the binary packet - -typedef struct -{ - uint32_t utc_time; - - int32_t latitude; - uint8_t ns_indicator; - - int32_t longitude; - uint8_t ew_indicator; - - uint8_t fix_quality; - - uint8_t satellites_used; - - uint16_t hdop; - - int32_t msl_altitude; - - int32_t geoidal_seperation; - - uint8_t fix_type; - - int32_t course_over_ground; - - int32_t speed_over_ground; - - uint8_t day; - uint8_t month; - uint16_t year; -} __attribute__((__packed__)) t_gps_bin_packet_data; - -typedef struct -{ - uint16_t header; - t_gps_bin_packet_data data; - uint8_t asterisk; - uint8_t checksum; - uint16_t end_word; -} __attribute__((__packed__)) t_gps_bin_packet; - -// ************ - -// buffer that holds the incoming binary packet -static uint8_t gps_rx_buffer[sizeof(t_gps_bin_packet)] __attribute__ ((aligned(4))); - -// number of bytes currently in the rx buffer -static int16_t gps_rx_buffer_wr = 0; - -// ************ -// endian swapping functions - -static uint16_t swap2Bytes(uint16_t data) -{ - return (((data >> 8) & 0x00ff) | - ((data << 8) & 0xff00)); -} - -static uint32_t swap4Bytes(uint32_t data) -{ - return (((data >> 24) & 0x000000ff) | - ((data >> 8) & 0x0000ff00) | - ((data << 8) & 0x00ff0000) | - ((data << 24) & 0xff000000)); -} - -// ************ -/** - * Parses a complete binary packet and update the GPSPosition and GPSTime UAVObjects - * - * param[in] .. b = a new received byte from the GPS - * - * return '0' if we have found a valid binary packet - * return <0 if any errors were encountered with the packet or no packet found - */ - -int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volatile uint32_t *parsing_errors) -{ - if (gps_rx_buffer_wr >= sizeof(gps_rx_buffer)) - { // make room for the new byte .. this will actually never get executed, just here as a safe guard really - memmove(gps_rx_buffer, gps_rx_buffer + 1, sizeof(gps_rx_buffer) - 1); - gps_rx_buffer_wr = sizeof(gps_rx_buffer) - 1; - } - - // add the new byte into the buffer - gps_rx_buffer[gps_rx_buffer_wr++] = b; - - int16_t i = 0; - - while (gps_rx_buffer_wr > 0) - { - t_gps_bin_packet *rx_packet = (t_gps_bin_packet *)(gps_rx_buffer + i); - - // scan for the start of a binary packet (the header bytes) - while (gps_rx_buffer_wr - i >= sizeof(rx_packet->header)) - { - if (rx_packet->header == 0x2404) - break; // found a valid header marker - rx_packet = (t_gps_bin_packet *)(gps_rx_buffer + ++i); - } - - // remove unwanted bytes before the start of the packet header - if (i > 0) - { - gps_rx_buffer_wr -= i; - if (gps_rx_buffer_wr > 0) - memmove(gps_rx_buffer, gps_rx_buffer + i, gps_rx_buffer_wr); - i = 0; - } - - if (gps_rx_buffer_wr < sizeof(t_gps_bin_packet)) - break; // not yet enough bytes for a complete binary packet - - // we have enough bytes for a complete binary packet - - // check to see if certain parameters in the binary packet are valid - if (rx_packet->header != 0x2404 || - rx_packet->end_word != 0x0A0D || - rx_packet->asterisk != 0x2A || - (rx_packet->data.ns_indicator != 1 && rx_packet->data.ns_indicator != 2) || - (rx_packet->data.ew_indicator != 1 && rx_packet->data.ew_indicator != 2) || - (rx_packet->data.fix_quality > 2) || - (rx_packet->data.fix_type < 1 || rx_packet->data.fix_type > 3) ) - { // invalid packet - if (parsing_errors) *parsing_errors++; - i++; - continue; - } - - { // check the checksum is valid - uint8_t *p = (uint8_t *)&rx_packet->data; - uint8_t checksum = 0; - for (int i = 0; i < sizeof(t_gps_bin_packet_data); i++) - checksum ^= *p++; - - if (checksum != rx_packet->checksum) - { // checksum error - if (chksum_errors) *chksum_errors++; - i++; - continue; - } - } - - // we now have a valid complete binary packet, update the GpsData and GpsTime objects - - // correct the endian order of the parameters - rx_packet->data.utc_time = swap4Bytes(rx_packet->data.utc_time); - rx_packet->data.latitude = swap4Bytes(rx_packet->data.latitude); - rx_packet->data.longitude = swap4Bytes(rx_packet->data.longitude); - rx_packet->data.hdop = swap2Bytes(rx_packet->data.hdop); - rx_packet->data.msl_altitude = swap4Bytes(rx_packet->data.msl_altitude); - rx_packet->data.geoidal_seperation = swap4Bytes(rx_packet->data.geoidal_seperation); - rx_packet->data.course_over_ground = swap4Bytes(rx_packet->data.course_over_ground); - rx_packet->data.speed_over_ground = swap4Bytes(rx_packet->data.speed_over_ground); - rx_packet->data.year = swap2Bytes(rx_packet->data.year); - - // set the gps time object - GPSTimeData GpsTime; -// GPSTimeGet(&GpsTime); - uint32_t utc_time = rx_packet->data.utc_time / 1000; - GpsTime.Second = utc_time % 100; // seconds - GpsTime.Minute = (utc_time / 100) % 100; // minutes - GpsTime.Hour = utc_time / 10000; // hours - GpsTime.Day = rx_packet->data.day; // day - GpsTime.Month = rx_packet->data.month; // month - GpsTime.Year = rx_packet->data.year; // year - GPSTimeSet(&GpsTime); - - // set the gps position object - GPSPositionData GpsData; -// GPSPositionGet(&GpsData); - switch (rx_packet->data.fix_type) - { - case 1: GpsData.Status = GPSPOSITION_STATUS_NOFIX; break; - case 2: GpsData.Status = GPSPOSITION_STATUS_FIX2D; break; - case 3: GpsData.Status = GPSPOSITION_STATUS_FIX3D; break; - default: GpsData.Status = GPSPOSITION_STATUS_NOGPS; break; - } - GpsData.Latitude = rx_packet->data.latitude * (rx_packet->data.ns_indicator == 1 ? +1 : -1) * 10; // degrees * 10e6 - GpsData.Longitude = rx_packet->data.longitude * (rx_packet->data.ew_indicator == 1 ? +1 : -1) * 10; // degrees * 10e6 - GpsData.Altitude = (float)rx_packet->data.msl_altitude / 1000; // meters - GpsData.GeoidSeparation = (float)rx_packet->data.geoidal_seperation / 1000; // meters - GpsData.Heading = (float)rx_packet->data.course_over_ground / 1000; // degrees - GpsData.Groundspeed = (float)rx_packet->data.speed_over_ground / 3600; // m/s - GpsData.Satellites = rx_packet->data.satellites_used; // - GpsData.PDOP = 99.99; // not available in binary mode - GpsData.HDOP = (float)rx_packet->data.hdop / 100; // - GpsData.VDOP = 99.99; // not available in binary mode - GPSPositionSet(&GpsData); - - // set the number of satellites -// GPSSatellitesData SattelliteData; -//// GPSSatellitesGet(&SattelliteData); -// memset(&SattelliteData, 0, sizeof(SattelliteData)); -// SattelliteData.SatsInView = rx_packet->data.satellites_used; // -// GPSSatellitesSet(&SattelliteData); - - // remove the spent binary packet from the buffer - gps_rx_buffer_wr -= sizeof(t_gps_bin_packet); - if (gps_rx_buffer_wr > 0) - memmove(gps_rx_buffer, gps_rx_buffer + sizeof(t_gps_bin_packet), gps_rx_buffer_wr); - - return 0; // found a valid packet - } - - return -1; // no valid packet found -} - -// ************ - -void GTOP_BIN_init(void) -{ - gps_rx_buffer_wr = 0; -} - -// ************ - -#endif // ENABLE_GPS_BINARY_GTOP - diff --git a/flight/Modules/GPS/NMEA.c b/flight/Modules/GPS/NMEA.c index 3dfd98d40..adadc588a 100644 --- a/flight/Modules/GPS/NMEA.c +++ b/flight/Modules/GPS/NMEA.c @@ -40,8 +40,6 @@ -#if defined(ENABLE_GPS_NMEA) || defined(ENABLE_GPS_ONESENTENCE_GTOP) - // Debugging #ifdef ENABLE_DEBUG_MSG //#define DEBUG_MSG_IN ///< define to display the incoming NMEA messages @@ -54,7 +52,6 @@ //#define NMEA_DEBUG_GSA ///< define to enable debug of GSA messages //#define NMEA_DEBUG_GSV ///< define to enable debug of GSV messages //#define NMEA_DEBUG_ZDA ///< define to enable debug of ZDA messages -//#define NMEA_DEBUG_PGTOP ///< define to enable debug of PGTOP messages #define DEBUG_MSG(format, ...) PIOS_COM_SendFormattedString(DEBUG_PORT, format, ## __VA_ARGS__) #else #define DEBUG_MSG(format, ...) @@ -69,56 +66,45 @@ struct nmea_parser { uint32_t cnt; }; - #ifdef ENABLE_GPS_NMEA - static bool nmeaProcessGPGGA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessGPVTG(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessGPGSA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessGPZDA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessGPGSV(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - #endif +static bool nmeaProcessGPGGA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); +static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); +static bool nmeaProcessGPVTG(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); +static bool nmeaProcessGPGSA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); +static bool nmeaProcessGPZDA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); +static bool nmeaProcessGPGSV(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static bool nmeaProcessPGTOP(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam); - static struct nmea_parser nmea_parsers[] = { - - #ifdef ENABLE_GPS_NMEA - { - .prefix = "GPGGA", - .handler = nmeaProcessGPGGA, - .cnt = 0, - }, - { - .prefix = "GPVTG", - .handler = nmeaProcessGPVTG, - .cnt = 0, - }, - { - .prefix = "GPGSA", - .handler = nmeaProcessGPGSA, - .cnt = 0, - }, - { - .prefix = "GPRMC", - .handler = nmeaProcessGPRMC, - .cnt = 0, - }, - { - .prefix = "GPZDA", - .handler = nmeaProcessGPZDA, - .cnt = 0, - }, - { - .prefix = "GPGSV", - .handler = nmeaProcessGPGSV, - .cnt = 0, - }, - #endif - { - .prefix = "PGTOP", - .handler = nmeaProcessPGTOP, - .cnt = 0, - }, +static struct nmea_parser nmea_parsers[] = { + { + .prefix = "GPGGA", + .handler = nmeaProcessGPGGA, + .cnt = 0, + }, + { + .prefix = "GPVTG", + .handler = nmeaProcessGPVTG, + .cnt = 0, + }, + { + .prefix = "GPGSA", + .handler = nmeaProcessGPGSA, + .cnt = 0, + }, + { + .prefix = "GPRMC", + .handler = nmeaProcessGPRMC, + .cnt = 0, + }, + { + .prefix = "GPZDA", + .handler = nmeaProcessGPZDA, + .cnt = 0, + }, + { + .prefix = "GPGSV", + .handler = nmeaProcessGPGSV, + .cnt = 0, + }, }; static struct nmea_parser *NMEA_find_parser_by_prefix(const char *prefix) @@ -229,7 +215,6 @@ static float NMEA_real_to_float(char *nmea_real) return (((float)whole) + fract * pow(10, -fract_units)); } -#ifdef ENABLE_GPS_NMEA /* * Parse a field in the format: * DD[D]MM.mmmm[mm] @@ -287,7 +272,6 @@ static bool NMEA_latlon_to_fixed_point(int32_t * latlon, char *nmea_latlon, bool return true; } -#endif // ENABLE_GPS_NMEA /** @@ -376,7 +360,6 @@ bool NMEA_update_position(char *nmea_sentence) return true; } -#ifdef ENABLE_GPS_NMEA /** * Parse an NMEA GPGGA sentence and update the given UAVObject @@ -675,83 +658,3 @@ static bool nmeaProcessGPGSA(GPSPositionData * GpsData, bool* gpsDataUpdated, ch return true; } -#endif // ENABLE_GPS_NMEA - -/** - * Parse an NMEA PGTOP sentence and update the given UAVObject - * \param[in] A pointer to a GPSPosition UAVObject to be updated. - * \param[in] An NMEA sentence with a valid checksum - */ -static bool nmeaProcessPGTOP(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam) -{ - if (nbParam != 17) - return false; - - GPSTimeData gpst; - GPSTimeGet(&gpst); - - *gpsDataUpdated = true; - - // get UTC time [hhmmss.sss] - float hms = NMEA_real_to_float(param[1]); - gpst.Second = (int)hms % 100; - gpst.Minute = (((int)hms - gpst.Second) / 100) % 100; - gpst.Hour = (int)hms / 10000; - - // get latitude decimal degrees - GpsData->Latitude = NMEA_real_to_float(param[2])*1e7; - if (param[3][0] == 'S') - GpsData->Latitude = -GpsData->Latitude; - - - // get longitude decimal degrees - GpsData->Longitude = NMEA_real_to_float(param[4])*1e7; - if (param[5][0] == 'W') - GpsData->Longitude = -GpsData->Longitude; - - // get number of satellites used in GPS solution - GpsData->Satellites = atoi(param[7]); - - // next field: HDOP - GpsData->HDOP = NMEA_real_to_float(param[8]); - - // get altitude (in meters mm.m) - GpsData->Altitude = NMEA_real_to_float(param[9]); - - // next field: geoid separation - GpsData->GeoidSeparation = NMEA_real_to_float(param[10]); - - // Mode: 1=Fix not available, 2=2D, 3=3D - switch (atoi(param[11])) { - case 1: - GpsData->Status = GPSPOSITION_STATUS_NOFIX; - break; - case 2: - GpsData->Status = GPSPOSITION_STATUS_FIX2D; - break; - case 3: - GpsData->Status = GPSPOSITION_STATUS_FIX3D; - break; - default: - /* Unhandled */ - return false; - break; - } - - // get course over ground in degrees [ddd.dd] - GpsData->Heading = NMEA_real_to_float(param[12]); - - // get speed in km/h - GpsData->Groundspeed = NMEA_real_to_float(param[13]); - // to m/s - GpsData->Groundspeed /= 3.6; - - gpst.Day = atoi(param[14]); - gpst.Month = atoi(param[15]); - gpst.Year = atoi(param[16]); - GPSTimeSet(&gpst); - - return true; -} - -#endif // #if defined(ENABLE_GPS_NMEA) || defined(ENABLE_GPS_ONESENTENCE_GTOP) diff --git a/flight/Modules/GPS/inc/GPS.h b/flight/Modules/GPS/inc/GPS.h index 1ae683c9a..86a92d285 100644 --- a/flight/Modules/GPS/inc/GPS.h +++ b/flight/Modules/GPS/inc/GPS.h @@ -34,8 +34,6 @@ #ifndef GPS_H #define GPS_H -#include "gps_mode.h" - int32_t GPSInitialize(void); #endif // GPS_H diff --git a/flight/Modules/GPS/inc/GTOP_BIN.h b/flight/Modules/GPS/inc/GTOP_BIN.h deleted file mode 100644 index 6a5234430..000000000 --- a/flight/Modules/GPS/inc/GTOP_BIN.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @{ - * @addtogroup GSPModule GPS Module - * @brief Process GPS information - * @{ - * - * @file GTOP_BIN.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief GPS module, handles GPS and NMEA stream - * @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 GTOP_BIN_H -#define GTOP_BIN_H - -#include -#include "gps_mode.h" - -#ifdef ENABLE_GPS_BINARY_GTOP - extern int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volatile uint32_t *parsing_errors); - extern void GTOP_BIN_init(void); -#endif - -#endif diff --git a/flight/Modules/GPS/inc/NMEA.h b/flight/Modules/GPS/inc/NMEA.h index 5c1b13f8b..6ff6b1195 100644 --- a/flight/Modules/GPS/inc/NMEA.h +++ b/flight/Modules/GPS/inc/NMEA.h @@ -33,11 +33,8 @@ #include #include -#include "gps_mode.h" -#if defined(ENABLE_GPS_NMEA) || defined(ENABLE_GPS_ONESENTENCE_GTOP) - extern bool NMEA_update_position(char *nmea_sentence); - extern bool NMEA_checksum(char *nmea_sentence); -#endif +extern bool NMEA_update_position(char *nmea_sentence); +extern bool NMEA_checksum(char *nmea_sentence); #endif /* NMEA_H */ diff --git a/flight/Modules/GPS/inc/gps_mode.h b/flight/Modules/GPS/inc/gps_mode.h deleted file mode 100644 index 43e5b0398..000000000 --- a/flight/Modules/GPS/inc/gps_mode.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @{ - * @addtogroup GSPModule GPS Module - * @brief Process GPS information - * @{ - * - * @file gps_mode.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Include file of the GPS module. - * As with all modules only the initialize function is exposed all other - * interactions with the module take place through the event queue and - * objects. - * @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 GPS_MODE_H -#define GPS_MODE_H - -// **************** -// you MUST have one of these uncommented - and ONLY one - -//#define ENABLE_GPS_BINARY_GTOP // uncomment this if we are using GTOP BINARY mode -//#define ENABLE_GPS_ONESENTENCE_GTOP // uncomment this if we are using GTOP SINGLE SENTENCE mode -#define ENABLE_GPS_NMEA // uncomment this if we are using NMEA mode - -// **************** -// make sure they have defined a protocol to use - -#if !defined(ENABLE_GPS_BINARY_GTOP) && !defined(ENABLE_GPS_ONESENTENCE_GTOP) && !defined(ENABLE_GPS_NMEA) - #error YOU MUST SELECT THE DESIRED GPS PROTOCOL IN gps_mode.h! -#endif - -// **************** - -#endif - -/** - * @} - * @} - */ diff --git a/flight/OpenPilot/System/pios_board.c b/flight/OpenPilot/System/pios_board.c index 12d365b67..150bfb938 100644 --- a/flight/OpenPilot/System/pios_board.c +++ b/flight/OpenPilot/System/pios_board.c @@ -525,7 +525,6 @@ static const struct pios_spektrum_cfg pios_spektrum_cfg = { #define PIOS_COM_TELEM_RF_TX_BUF_LEN 192 #define PIOS_COM_GPS_RX_BUF_LEN 96 -#define PIOS_COM_GPS_TX_BUF_LEN 96 #define PIOS_COM_TELEM_USB_RX_BUF_LEN 192 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 192 @@ -1075,12 +1074,10 @@ void PIOS_Board_Init(void) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_TX_BUF_LEN); PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id, rx_buffer, PIOS_COM_GPS_RX_BUF_LEN, - tx_buffer, PIOS_COM_GPS_TX_BUF_LEN)) { + NULL, 0)) { PIOS_Assert(0); } } diff --git a/flight/OpenPilot/System/pios_board_posix.c b/flight/OpenPilot/System/pios_board_posix.c index e1e8dcc54..37fadd760 100644 --- a/flight/OpenPilot/System/pios_board_posix.c +++ b/flight/OpenPilot/System/pios_board_posix.c @@ -71,7 +71,7 @@ const struct pios_udp_cfg pios_udp_aux_cfg = { #define PIOS_COM_TELEM_RF_RX_BUF_LEN 192 #define PIOS_COM_TELEM_RF_TX_BUF_LEN 192 -#define PIOS_COM_GPS_RX_BUF_LEN 192 +#define PIOS_COM_GPS_RX_BUF_LEN 96 /* * Board specific number of devices. @@ -164,12 +164,10 @@ void PIOS_Board_Init(void) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN); PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_gps_id, &pios_udp_com_driver, pios_udp_gps_id, rx_buffer, PIOS_COM_GPS_RX_BUF_LEN, - tx_buffer, PIOS_COM_GPS_RX_BUF_LEN)) { + NULL, 0)) { PIOS_Assert(0); } } From 7e396efbbf90a133d50791427c04bd996e7d7cb2 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Thu, 25 Aug 2011 15:11:29 +0200 Subject: [PATCH 17/18] Modules/GPS: Assert buffer creation --- flight/Modules/GPS/GPS.c | 1 + 1 file changed, 1 insertion(+) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 44b039eb1..3d9cd1b20 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -119,6 +119,7 @@ int32_t GPSInitialize(void) gpsPort = PIOS_COM_GPS; gps_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH); + PIOS_ASSERT(gps_rx_buffer); return 0; } From 54ecf233f31fc8cb812e0a7b9fde8ef6f344cf39 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Thu, 25 Aug 2011 15:13:50 +0200 Subject: [PATCH 18/18] Modules/PS: typo fix --- flight/Modules/GPS/GPS.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 3d9cd1b20..2e6b0901b 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -119,7 +119,7 @@ int32_t GPSInitialize(void) gpsPort = PIOS_COM_GPS; gps_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH); - PIOS_ASSERT(gps_rx_buffer); + PIOS_Assert(gps_rx_buffer); return 0; }