From 4c9327da7e0134697ebc70e9f60d2bf7e4e95d1f Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Mon, 9 Jul 2012 00:15:21 +0100 Subject: [PATCH 1/2] GCS-Fixes some crashes on hw disconnection. --- .../openpilotgcs/src/plugins/uavtalk/telemetry.cpp | 12 ++++++------ ground/openpilotgcs/src/plugins/uavtalk/telemetry.h | 4 ++-- ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp index 93812d44a..ba65e84e5 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp @@ -389,7 +389,7 @@ void Telemetry::processObjectQueue() if ( ( objInfo.event != EV_UNPACKED ) && ( ( objInfo.event != EV_UPDATED_PERIODIC ) || ( updateMode != UAVObject::UPDATEMODE_THROTTLED ) ) ) { UAVObject::Metadata metadata = objInfo.obj->getMetadata(); - ObjectTransactionInfo *transInfo = new ObjectTransactionInfo(); + ObjectTransactionInfo *transInfo = new ObjectTransactionInfo(this); transInfo->obj = objInfo.obj; transInfo->allInstances = objInfo.allInstances; transInfo->retriesRemaining = MAX_RETRIES; @@ -402,9 +402,9 @@ void Telemetry::processObjectQueue() { transInfo->objRequest = true; } - transInfo->telem = this; - // Insert the transaction into the transaction map. - transMap.insert(objInfo.obj->getObjID(), transInfo); + transInfo->telem = this; + // Insert the transaction into the transaction map. + transMap.insert(objInfo.obj->getObjID(), transInfo); processObjectTransaction(transInfo); } @@ -559,7 +559,7 @@ void Telemetry::newInstance(UAVObject* obj) registerObject(obj); } -ObjectTransactionInfo::ObjectTransactionInfo() +ObjectTransactionInfo::ObjectTransactionInfo(QObject* parent):QObject(parent) { obj = 0; allInstances = false; @@ -582,6 +582,6 @@ ObjectTransactionInfo::~ObjectTransactionInfo() void ObjectTransactionInfo::timeout() { - if (telem) + if (!telem.isNull()) telem->transactionTimeout(this); } diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h index 1fe62521b..aaa9bc171 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h @@ -41,14 +41,14 @@ class ObjectTransactionInfo: public QObject { Q_OBJECT public: - ObjectTransactionInfo(); + ObjectTransactionInfo(QObject * parent); ~ObjectTransactionInfo(); UAVObject* obj; bool allInstances; bool objRequest; qint32 retriesRemaining; bool acked; - class Telemetry* telem; + QPointertelem; QTimer* timer; private slots: void timeout(); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp index 66b8024ac..e1aa5ecf6 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp @@ -159,6 +159,8 @@ void UAVTalk::cancelTransaction(UAVObject* obj) { QMutexLocker locker(mutex); quint32 objId = obj->getObjID(); + if(io.isNull()) + return; QMap::iterator itr = transMap.find(objId); if ( itr != transMap.end() ) { @@ -827,7 +829,7 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance txBuffer[dataOffset+length] = updateCRC(0, txBuffer, dataOffset + length); // Send buffer, check that the transmit backlog does not grow above limit - if (io && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) + if (!io.isNull() && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) { io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH); } From 9c716abb11cda60976fbb1c3d57b173e7b3b03e9 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Sun, 8 Jul 2012 18:34:23 -0700 Subject: [PATCH 2/2] Bugfixes: get both confighardware and firmware widgets to show CC3D image if detected. --- .../plugins/config/config_cc_hw_widget.cpp | 24 ++++++++++++++++++- .../plugins/uploader/runningdevicewidget.cpp | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index 97cfccd47..4af991a6e 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -41,8 +41,30 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry = new Ui_CC_HW_Widget(); m_telemetry->setupUi(this); - m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg")); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager* utilMngr = pm->getObject(); + int id = utilMngr->getBoardModel(); + switch (id) { + case 0x0101: + m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0101.svg")); + break; + case 0x0301: + m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0301.svg")); + break; + case 0x0401: + m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0401.svg")); + break; + case 0x0402: + m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0402.svg")); + break; + case 0x0201: + m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0201.svg")); + break; + default: + m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg")); + break; + } addApplySaveButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); addUAVObjectToWidgetRelation("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); addUAVObjectToWidgetRelation("HwSettings","CC_MainPort",m_telemetry->cbTele); diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp index 4bf17e615..145e0f322 100644 --- a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp @@ -94,6 +94,9 @@ void runningDeviceWidget::populate() case 0x0401: devicePic->renderer()->load(QString(":/uploader/images/deviceID-0401.svg")); break; + case 0x0402: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-0402.svg")); + break; case 0x0201: devicePic->renderer()->load(QString(":/uploader/images/deviceID-0201.svg")); break;