From 8283d4280e6577d57b6a68868b8e793e10fe1088 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 13 Jun 2012 14:57:43 -0700 Subject: [PATCH 1/3] UAVTalk, change private member QIODevice* io to smart pointer QPointer --- .../openpilotgcs/src/plugins/uavtalk/uavtalk.cpp | 15 ++++++++------- ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp index 4c218379d..03da96a6f 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp @@ -112,10 +112,12 @@ void UAVTalk::processInputStream() { quint8 tmp; - while (io->bytesAvailable() > 0) - { - io->read((char*)&tmp, 1); - processInputByte(tmp); + if (io && io->isReadable()) { + while (io->bytesAvailable() > 0) + { + io->read((char*)&tmp, 1); + processInputByte(tmp); + } } } @@ -719,9 +721,8 @@ bool UAVTalk::transmitNack(quint32 objId) qToLittleEndian(dataOffset, &txBuffer[2]); - // Send buffer, check that the transmit backlog does not grow above limit - if ( io->bytesToWrite() < TX_BUFFER_SIZE ) + if (io && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) { io->write((const char*)txBuffer, dataOffset+CHECKSUM_LENGTH); } @@ -811,7 +812,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->bytesToWrite() < TX_BUFFER_SIZE ) + if (io && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) { io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH); } diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h index 163fb9fa3..de7ca8542 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h @@ -27,6 +27,7 @@ #ifndef UAVTALK_H #define UAVTALK_H +#include #include #include #include @@ -93,7 +94,7 @@ private: typedef enum {STATE_SYNC, STATE_TYPE, STATE_SIZE, STATE_OBJID, STATE_INSTID, STATE_DATA, STATE_CS} RxStateType; // Variables - QIODevice* io; + QPointer io; UAVObjectManager* objMngr; QMutex* mutex; UAVObject* respObj; From 8de40c7847c24becca400a27d38745dcc7067578 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 13 Jun 2012 15:09:54 -0700 Subject: [PATCH 2/3] BugFix: ConfigFixedWing reset the mixer vectors to zero prior to writing anew. --- .../plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index b1354a447..8b2e428e2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -312,7 +312,10 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) int channel; //disable all for (channel=0; channelfwEngineChannelBox->currentIndex()-1; From a7ae258bc8c0c66cbba5a68cc5b6ac577bf7e68c Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 13 Jun 2012 15:14:18 -0700 Subject: [PATCH 3/3] Bugfix, oops: missed a couple resetMixerVector opportunities. --- .../config/cfg_vehicletypes/configfixedwingwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 8b2e428e2..dc1f6bbcc 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -399,7 +399,10 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) double value; //disable all for (channel=0; channelfwEngineChannelBox->currentIndex()-1; @@ -481,7 +484,10 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) double value; //disable all for (channel=0; channelfwEngineChannelBox->currentIndex()-1;