From 2088753ee54e9d034b732b54ac4c2698cfbbd16a Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 9 Jun 2012 10:52:40 -0700 Subject: [PATCH 01/20] Changed the flight side access of GCSReceiver to readwrite to support sending GCSReceiver object in response to PPM packets on the PipX. --- shared/uavobjectdefinition/gcsreceiver.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/uavobjectdefinition/gcsreceiver.xml b/shared/uavobjectdefinition/gcsreceiver.xml index cbc00c965..ee4fa696f 100644 --- a/shared/uavobjectdefinition/gcsreceiver.xml +++ b/shared/uavobjectdefinition/gcsreceiver.xml @@ -2,7 +2,7 @@ A receiver channel group carried over the telemetry link. - + From 71287e4cb475e277affb1e0b5c69bc9c0b937417 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 9 Jun 2012 10:53:34 -0700 Subject: [PATCH 02/20] Fixed setting of the PairID on PipX GCS and added selection for broadcast mode. --- .../plugins/config/configpipxtremewidget.cpp | 5 +- .../src/plugins/config/pipxtreme.ui | 234 +++++++++++------- 2 files changed, 146 insertions(+), 93 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index fb1223607..29604b6e7 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -148,7 +148,7 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object) PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager()); quint32 pairID = 0; if (pipxSettings) - pipxSettings->getPairID(); + pairID = pipxSettings->getPairID(); // Update the detected devices. UAVObjectField* pairIdField = object->getField("PairIDs"); @@ -245,6 +245,9 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object) qDebug() << "PipXtremeGadgetWidget: Count not read DeviceID field."; } + // Update the PairID field + m_pipx->PairID->setText(QString::number(pairID, 16).toUpper()); + // Update the link state UAVObjectField* linkField = object->getField("LinkState"); if (linkField) { diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index 8a5c2dec4..5dc9e372a 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -135,16 +135,40 @@ + + + + + + + + + + 0 + + + false + + + + + + + Broadcast Address + + + + - + - + -127 @@ -163,17 +187,24 @@ - + + + + -100dB + + + + - + - + -127 @@ -192,17 +223,24 @@ - + + + + -100dB + + + + - + - + -127 @@ -221,17 +259,24 @@ - + + + + -100dB + + + + - + - + -127 @@ -250,28 +295,7 @@ - - - - -100dB - - - - - - - -100dB - - - - - - - -100dB - - - - + -100dB @@ -393,7 +417,69 @@ + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + false + + + true + + + + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + false + + + true + + + + + + Pair ID + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + Min Frequency @@ -403,7 +489,7 @@ - + @@ -444,7 +530,7 @@ - + Max Frequency @@ -454,7 +540,7 @@ - + @@ -495,7 +581,7 @@ - + Freq. Step Size @@ -505,7 +591,7 @@ - + @@ -546,7 +632,7 @@ - + Link State @@ -556,7 +642,7 @@ - + @@ -597,7 +683,7 @@ - + Rx AFC @@ -607,7 +693,7 @@ - + @@ -630,7 +716,7 @@ - + Retries @@ -640,7 +726,7 @@ - + @@ -666,7 +752,7 @@ - + @@ -692,7 +778,7 @@ - + Errors @@ -702,7 +788,7 @@ - + UAVTalk Errors @@ -712,7 +798,7 @@ - + @@ -738,7 +824,7 @@ - + Resets @@ -748,7 +834,7 @@ - + @@ -774,7 +860,7 @@ - + Dropped @@ -784,7 +870,7 @@ - + @@ -810,7 +896,7 @@ - + TX Rate (B/s) @@ -820,7 +906,7 @@ - + @@ -846,7 +932,7 @@ - + RX Rate (B/s) @@ -856,7 +942,7 @@ - + @@ -882,42 +968,6 @@ - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 8px; - background: rgba(0, 0, 0, 16); -/* background: transparent; */ -/* selection-background-color: darkgray;*/ -} - - - false - - - true - - - - - - - Device ID - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - From 33cae7645de1fc8b20ad2f4959bbd1f6951de243 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Tue, 12 Jun 2012 19:47:25 -0700 Subject: [PATCH 03/20] Fixed calculation of retries on PipX. --- flight/Modules/RadioComBridge/RadioComBridge.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index ceb547fd1..7124e5ae0 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -567,8 +567,9 @@ static void sendDataTask(void *parameters) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendObject(data->outUAVTalkCon, ev.obj, 0, 0, RETRY_TIMEOUT_MS); - ++retries; + success = UAVTalkSendObject(data->outUAVTalkCon, ev.obj, 0, 0, RETRY_TIMEOUT_MS) == 0; + if (!success) + ++retries; } data->comTxRetries += retries; } @@ -578,8 +579,9 @@ static void sendDataTask(void *parameters) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendAck(data->outUAVTalkCon, ev.obj, ev.instId); - ++retries; + success = UAVTalkSendAck(data->outUAVTalkCon, ev.obj, ev.instId) == 0; + if (!success) + ++retries; } data->comTxRetries += retries; } @@ -589,8 +591,9 @@ static void sendDataTask(void *parameters) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendNack(data->outUAVTalkCon, UAVObjGetID(ev.obj)); - ++retries; + success = UAVTalkSendNack(data->outUAVTalkCon, UAVObjGetID(ev.obj)) == 0; + if (!success) + ++retries; } data->comTxRetries += retries; } From 69a38ddd77cfd504c70e780133bece28b16cef87 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Tue, 12 Jun 2012 19:47:53 -0700 Subject: [PATCH 04/20] PipX configuration screen improvements. --- .../plugins/config/configpipxtremewidget.cpp | 28 +- .../plugins/config/configpipxtremewidget.h | 1 + .../src/plugins/config/pipxtreme.ui | 424 +++++++++++------- 3 files changed, 285 insertions(+), 168 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index 29604b6e7..5a7c5618c 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -71,6 +71,8 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget addUAVObjectToWidgetRelation("PipXStatus", "MinFrequency", m_pipx->MinFrequency); addUAVObjectToWidgetRelation("PipXStatus", "MaxFrequency", m_pipx->MaxFrequency); addUAVObjectToWidgetRelation("PipXStatus", "FrequencyStepSize", m_pipx->FrequencyStepSize); + addUAVObjectToWidgetRelation("PipXStatus", "FrequencyBand", m_pipx->FreqBand); + addUAVObjectToWidgetRelation("PipXStatus", "RSSI", m_pipx->RSSI); addUAVObjectToWidgetRelation("PipXStatus", "AFC", m_pipx->RxAFC); addUAVObjectToWidgetRelation("PipXStatus", "Retries", m_pipx->Retries); addUAVObjectToWidgetRelation("PipXStatus", "Errors", m_pipx->Errors); @@ -81,6 +83,7 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget addUAVObjectToWidgetRelation("PipXStatus", "TXRate", m_pipx->TXRate); // Connect to the pair ID radio buttons. + connect(m_pipx->PairSelectB, SIGNAL(toggled(bool)), this, SLOT(pairBToggled(bool))); connect(m_pipx->PairSelect1, SIGNAL(toggled(bool)), this, SLOT(pair1Toggled(bool))); connect(m_pipx->PairSelect2, SIGNAL(toggled(bool)), this, SLOT(pair2Toggled(bool))); connect(m_pipx->PairSelect3, SIGNAL(toggled(bool)), this, SLOT(pair3Toggled(bool))); @@ -89,6 +92,7 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget //Add scroll bar when necessary QScrollArea *scroll = new QScrollArea; scroll->setWidget(m_pipx->frame_3); + scroll->setWidgetResizable(true); m_pipx->verticalLayout_3->addWidget(scroll); // Request and update of the setting object. @@ -280,6 +284,8 @@ void ConfigPipXtremeWidget::disconnected() void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx) { + qDebug() << QString("Pairid toggled %1").arg(checked); + qDebug() << QString("idx %1").arg(idx); if(checked) { PipXStatus *pipxStatus = PipXStatus::GetInstance(getObjectManager()); @@ -287,9 +293,20 @@ void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx) if (pipxStatus && pipxSettings) { - quint32 pairID = pipxStatus->getPairIDs(idx); - if (pairID) - pipxSettings->setPairID(pairID); + if (idx == 4) + { + qDebug() << QString("PairID 0"); + pipxSettings->setPairID(0); + } + else + { + quint32 pairID = pipxStatus->getPairIDs(idx); + if (pairID) + { + qDebug() << QString("Pairid %1").arg(pairID); + pipxSettings->setPairID(pairID); + } + } } } } @@ -314,6 +331,11 @@ void ConfigPipXtremeWidget::pair4Toggled(bool checked) pairIDToggled(checked, 3); } +void ConfigPipXtremeWidget::pairBToggled(bool checked) +{ + pairIDToggled(checked, 4); +} + /** @} @} diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h index b702326e8..28db67b74 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h @@ -63,6 +63,7 @@ private slots: void pair2Toggled(bool checked); void pair3Toggled(bool checked); void pair4Toggled(bool checked); + void pairBToggled(bool checked); }; #endif // CONFIGTXPIDWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index 5dc9e372a..0a50d90da 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -81,7 +81,7 @@ 40 - 20 + 5 @@ -144,7 +144,7 @@ - 0 + Broadcast false @@ -326,14 +326,14 @@ - Firmware Version + Firmware Ver. Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + @@ -369,7 +369,7 @@ - + @@ -417,6 +417,16 @@ + + + + Device ID + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -443,7 +453,17 @@ - + + + + Pair ID + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + @@ -470,16 +490,6 @@ - - - Pair ID - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - Min Frequency @@ -489,7 +499,7 @@ - + @@ -530,7 +540,7 @@ - + Max Frequency @@ -540,7 +550,7 @@ - + @@ -581,7 +591,7 @@ - + Freq. Step Size @@ -591,7 +601,7 @@ - + @@ -632,6 +642,195 @@ + + + + Freq. Band + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 75 + true + + + + The current frequency band + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + RSSI + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + true + + + + + + + Rx AFC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + true + + + + + + + TX Rate (B/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + false + + + true + + + + + + + RX Rate (B/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + false + + + true + + + @@ -683,76 +882,17 @@ - - + + - Rx AFC + Errors Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 8px; - background: rgba(0, 0, 0, 16); -/* background: transparent; */ -/* selection-background-color: darkgray;*/ -} - - - true - - - - - - - Retries - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 8px; - background: rgba(0, 0, 0, 16); -/* background: transparent; */ -/* selection-background-color: darkgray;*/ -} - - - false - - - true - - - - + @@ -778,17 +918,43 @@ - - + + - Errors + Retries Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + + + + + 75 + true + + + + QLineEdit { + border: none; + border-radius: 1px; + padding: 0 8px; + background: rgba(0, 0, 0, 16); +/* background: transparent; */ +/* selection-background-color: darkgray;*/ +} + + + false + + + true + + + + UAVTalk Errors @@ -798,7 +964,7 @@ - + @@ -824,7 +990,7 @@ - + Resets @@ -834,7 +1000,7 @@ - + @@ -860,7 +1026,7 @@ - + Dropped @@ -870,7 +1036,7 @@ - + @@ -886,78 +1052,6 @@ background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ -} - - - false - - - true - - - - - - - TX Rate (B/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 8px; - background: rgba(0, 0, 0, 16); -/* background: transparent; */ -/* selection-background-color: darkgray;*/ -} - - - false - - - true - - - - - - - RX Rate (B/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 75 - true - - - - QLineEdit { - border: none; - border-radius: 1px; - padding: 0 8px; - background: rgba(0, 0, 0, 16); -/* background: transparent; */ -/* selection-background-color: darkgray;*/ } From c06412f83bb2d152f706f63c66815ac52af177f1 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Tue, 12 Jun 2012 20:00:58 -0700 Subject: [PATCH 05/20] Removed some qDebug from PipX configuration widget. --- .../src/plugins/config/configpipxtremewidget.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index 5a7c5618c..7808b6dfa 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -284,8 +284,6 @@ void ConfigPipXtremeWidget::disconnected() void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx) { - qDebug() << QString("Pairid toggled %1").arg(checked); - qDebug() << QString("idx %1").arg(idx); if(checked) { PipXStatus *pipxStatus = PipXStatus::GetInstance(getObjectManager()); @@ -295,17 +293,13 @@ void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx) { if (idx == 4) { - qDebug() << QString("PairID 0"); pipxSettings->setPairID(0); } else { quint32 pairID = pipxStatus->getPairIDs(idx); if (pairID) - { - qDebug() << QString("Pairid %1").arg(pairID); pipxSettings->setPairID(pairID); - } } } } From 9409ea53da4d3d8922377dbfbcf958256eb0e755 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Wed, 13 Jun 2012 08:40:29 +0300 Subject: [PATCH 06/20] Minor GUI settings upgrades, to fit small screens better. --- .../src/plugins/config/pipxtreme.ui | 258 +++++++++++++++--- 1 file changed, 224 insertions(+), 34 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index 0a50d90da..9de1a7120 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -6,8 +6,8 @@ 0 0 - 840 - 834 + 834 + 772 @@ -143,12 +143,18 @@ + + false + + + + 100 + 16777215 + + Broadcast - - false - @@ -166,7 +172,17 @@ - + + + + 100 + 16777215 + + + + 12345678 + + @@ -202,7 +218,14 @@ - + + + + 100 + 16777215 + + + @@ -238,7 +261,14 @@ - + + + + 100 + 16777215 + + + @@ -274,7 +304,14 @@ - + + + + 100 + 16777215 + + + @@ -309,7 +346,7 @@ - 400 + 430 0 @@ -335,6 +372,18 @@ + + + 0 + 0 + + + + + 16777215 + 16777215 + + 75 @@ -345,7 +394,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -377,6 +426,12 @@ 0 + + + 0 + 0 + + 16777215 @@ -400,7 +455,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -429,6 +484,18 @@ + + + 0 + 0 + + + + + 101 + 16777215 + + 75 @@ -439,7 +506,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -448,9 +515,15 @@ false + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + true + + 12345678 + @@ -465,6 +538,12 @@ + + + 101 + 16777215 + + 75 @@ -475,7 +554,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -484,9 +563,15 @@ false + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + true + + 90ABCDEF + @@ -507,9 +592,15 @@ 0 + + + 0 + 0 + + - 16777215 + 101 16777215 @@ -526,7 +617,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -560,7 +651,7 @@ - 16777215 + 101 16777215 @@ -577,7 +668,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -609,9 +700,15 @@ 0 + + + 0 + 0 + + - 16777215 + 101 16777215 @@ -628,7 +725,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -662,7 +759,7 @@ - 16777215 + 101 16777215 @@ -679,7 +776,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -705,6 +802,18 @@ + + + 0 + 0 + + + + + 101 + 16777215 + + 75 @@ -715,7 +824,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -738,6 +847,12 @@ + + + 101 + 16777215 + + 75 @@ -748,7 +863,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -771,6 +886,18 @@ + + + 0 + 0 + + + + + 101 + 16777215 + + 75 @@ -781,7 +908,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -807,6 +934,12 @@ + + + 101 + 16777215 + + 75 @@ -817,7 +950,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -844,14 +977,20 @@ - + 0 0 + + + 0 + 0 + + - 16777215 + 101 16777215 @@ -868,7 +1007,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 3px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -880,6 +1019,9 @@ true + + Disconnected + @@ -894,6 +1036,12 @@ + + + 101 + 16777215 + + 75 @@ -904,7 +1052,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -930,6 +1078,18 @@ + + + 0 + 0 + + + + + 101 + 16777215 + + 75 @@ -940,7 +1100,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -966,6 +1126,12 @@ + + + 101 + 16777215 + + 75 @@ -976,7 +1142,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -1002,6 +1168,18 @@ + + + 0 + 0 + + + + + 101 + 16777215 + + 75 @@ -1012,7 +1190,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -1038,6 +1216,12 @@ + + + 101 + 16777215 + + 75 @@ -1048,7 +1232,7 @@ QLineEdit { border: none; border-radius: 1px; - padding: 0 8px; + padding: 0 4px; background: rgba(0, 0, 0, 16); /* background: transparent; */ /* selection-background-color: darkgray;*/ @@ -1070,6 +1254,12 @@ + + + 0 + 0 + + 75 From 005ba0f8c8c55da0529ec3d2b673c838a8776cf6 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 16 Jun 2012 19:19:23 -0700 Subject: [PATCH 07/20] Added erase pipx settings to PipX firmware (no GCS support yet). --- flight/Modules/RadioComBridge/RadioComBridge.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index 7124e5ae0..06245e5a7 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -390,6 +390,19 @@ static void comUAVTalkTask(void *parameters) int32_t ret = PIOS_EEPROM_Save((uint8_t*)&pipxSettings, sizeof(PipXSettingsData)); if (ret != 0) success = false; +#endif + break; + } + case OBJECTPERSISTENCE_OPERATION_DELETE: + { +#if defined(PIOS_INCLUDE_FLASH_EEPROM) + // Erase the settings. + PipXSettingsData pipxSettings; + uint8_t *ptr = (uint8_t*)&pipxSettings; + memset(ptr, 0, sizeof(PipXSettingsData)); + int32_t ret = PIOS_EEPROM_Save(ptr, sizeof(PipXSettingsData)); + if (ret != 0) + success = false; #endif break; } From 10e52b31c5a68f26c284e4b47d0e1d20699ad2b2 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 30 Jun 2012 10:06:01 -0700 Subject: [PATCH 08/20] Added the ability on the PipX to specify if a comport is used to connect to the GCS (ground side), so it will receive status, etc, or UAVTalk (flight side). The data passing in RadioComBridge was also made more uniform, which allows for easier reconfiguration. --- flight/Libraries/inc/packet_handler.h | 2 +- .../Modules/RadioComBridge/RadioComBridge.c | 295 ++++++++++++------ .../PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 3 + flight/PipXtreme/System/pios_board.c | 11 +- shared/uavobjectdefinition/pipxsettings.xml | 4 +- 5 files changed, 222 insertions(+), 93 deletions(-) diff --git a/flight/Libraries/inc/packet_handler.h b/flight/Libraries/inc/packet_handler.h index b0bd8315c..1e9f60807 100644 --- a/flight/Libraries/inc/packet_handler.h +++ b/flight/Libraries/inc/packet_handler.h @@ -106,7 +106,7 @@ void PHRegisterStatusHandler(PHInstHandle h, PHStatusHandler f); void PHRegisterPPMHandler(PHInstHandle h, PHPPMHandler f); uint32_t PHConnect(PHInstHandle h, uint32_t dest_id); PHPacketHandle PHGetRXPacket(PHInstHandle h); -void PHReleaseTXPacket(PHInstHandle h, PHPacketHandle p); +void PHReleaseRXPacket(PHInstHandle h, PHPacketHandle p); PHPacketHandle PHGetTXPacket(PHInstHandle h); void PHReleaseTXPacket(PHInstHandle h, PHPacketHandle p); uint8_t PHTransmitPacket(PHInstHandle h, PHPacketHandle p); diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index 06245e5a7..86373bd28 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -61,8 +61,9 @@ #define PACKET_QUEUE_SIZE 10 #define MAX_PORT_DELAY 200 #define EV_PACKET_RECEIVED 0x20 +#define EV_TRANSMIT_PACKET 0x30 #define EV_SEND_ACK 0x40 -#define EV_SEND_NACK 0x80 +#define EV_SEND_NACK 0x50 // **************** // Private types @@ -79,22 +80,35 @@ typedef struct { } PairStats; typedef struct { + uint32_t comPort; + UAVTalkConnection UAVTalkCon; + xQueueHandle sendQueue; + xQueueHandle recvQueue; + uint16_t wdg; + bool checkHID; +} UAVTalkComTaskParams; + +typedef struct { + // The task handles. - xTaskHandle comUAVTalkTaskHandle; + xTaskHandle GCSUAVTalkRecvTaskHandle; + xTaskHandle UAVTalkRecvTaskHandle; xTaskHandle radioReceiveTaskHandle; xTaskHandle sendPacketTaskHandle; - xTaskHandle sendDataTaskHandle; + xTaskHandle UAVTalkSendTaskHandle; xTaskHandle radioStatusTaskHandle; xTaskHandle transparentCommTaskHandle; xTaskHandle ppmInputTaskHandle; // The UAVTalk connection on the com side. - UAVTalkConnection inUAVTalkCon; - UAVTalkConnection outUAVTalkCon; + UAVTalkConnection UAVTalkCon; + UAVTalkConnection GCSUAVTalkCon; // Queue handles. - xQueueHandle sendPacketQueue; - xQueueHandle objEventQueue; + xQueueHandle radioPacketQueue; + xQueueHandle gcsEventQueue; + xQueueHandle uavtalkEventQueue; + xQueueHandle ppmOutQueue; // Error statistics. uint32_t comTxErrors; @@ -122,6 +136,10 @@ typedef struct { // The RSSI of the last packet received. int8_t RSSI; + // Thread parameters. + UAVTalkComTaskParams uavtalk_params; + UAVTalkComTaskParams gcs_uavtalk_params; + } RadioComBridgeData; typedef struct { @@ -135,21 +153,24 @@ typedef struct { // **************** // Private functions -static void comUAVTalkTask(void *parameters); +static void UAVTalkRecvTask(void *parameters); static void radioReceiveTask(void *parameters); static void sendPacketTask(void *parameters); -static void sendDataTask(void *parameters); +static void UAVTalkSendTask(void *parameters); static void transparentCommTask(void * parameters); static void radioStatusTask(void *parameters); static void ppmInputTask(void *parameters); -static int32_t transmitData(uint8_t * data, int32_t length); +static int32_t UAVTalkSendHandler(uint8_t * data, int32_t length); +static int32_t GCSUAVTalkSendHandler(uint8_t * data, int32_t length); static int32_t transmitPacket(PHPacketHandle packet); static void receiveData(uint8_t *buf, uint8_t len, int8_t rssi, int8_t afc); +static void transmitData(uint32_t outputPort, uint8_t *buf, uint8_t len, bool checkHid); static void StatusHandler(PHStatusPacketHandle p, int8_t rssi, int8_t afc); static void PPMHandler(uint16_t *channels); static BufferedReadHandle BufferedReadInit(uint32_t com_port, uint16_t buffer_length); static bool BufferedRead(BufferedReadHandle h, uint8_t *value, uint32_t timeout_ms); static void BufferedReadSetCom(BufferedReadHandle h, uint32_t com_port); +static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEventType type); static void updateSettings(); // **************** @@ -165,23 +186,34 @@ static RadioComBridgeData *data; static int32_t RadioComBridgeStart(void) { if(data) { + // Start the primary tasks for receiving/sending UAVTalk packets from the GCS. + xTaskCreate(UAVTalkRecvTask, (signed char *)"GCSUAVTalkRecvTask", STACK_SIZE_BYTES, (void*)&(data->gcs_uavtalk_params), TASK_PRIORITY + 2, &(data->GCSUAVTalkRecvTaskHandle)); + xTaskCreate(UAVTalkSendTask, (signed char *)"GCSUAVTalkSendTask", STACK_SIZE_BYTES, (void*)&(data->gcs_uavtalk_params), TASK_PRIORITY+ 2, &(data->UAVTalkSendTaskHandle)); + + // If a UAVTalk (non-GCS) com port is set it implies that the com port is connected on the flight side. + // In this case we want to start another com thread on the HID port to talk to the GCS when connected. + if (PIOS_COM_UAVTALK) + { + xTaskCreate(UAVTalkRecvTask, (signed char *)"UAVTalkRecvTask", STACK_SIZE_BYTES, (void*)&(data->uavtalk_params), TASK_PRIORITY + 2, &(data->UAVTalkRecvTaskHandle)); + xTaskCreate(UAVTalkSendTask, (signed char *)"UAVTalkSendTask", STACK_SIZE_BYTES, (void*)&(data->uavtalk_params), TASK_PRIORITY+ 2, &(data->UAVTalkSendTaskHandle)); + } + // Start the tasks - xTaskCreate(comUAVTalkTask, (signed char *)"ComUAVTalk", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->comUAVTalkTaskHandle)); if(PIOS_COM_TRANS_COM) xTaskCreate(transparentCommTask, (signed char *)"transparentComm", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->transparentCommTaskHandle)); xTaskCreate(radioReceiveTask, (signed char *)"RadioReceive", STACK_SIZE_BYTES, NULL, TASK_PRIORITY+ 2, &(data->radioReceiveTaskHandle)); xTaskCreate(sendPacketTask, (signed char *)"SendPacketTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->sendPacketTaskHandle)); - xTaskCreate(sendDataTask, (signed char *)"SendDataTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY+ 2, &(data->sendDataTaskHandle)); xTaskCreate(radioStatusTask, (signed char *)"RadioStatus", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioStatusTaskHandle)); if(PIOS_PPM_RECEIVER) xTaskCreate(ppmInputTask, (signed char *)"PPMInputTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->ppmInputTaskHandle)); #ifdef PIOS_INCLUDE_WDG - PIOS_WDG_RegisterFlag(PIOS_WDG_COMUAVTALK); + PIOS_WDG_RegisterFlag(PIOS_WDG_COMGCS); + if(PIOS_COM_UAVTALK) + PIOS_WDG_RegisterFlag(PIOS_WDG_COMUAVTALK); if(PIOS_COM_TRANS_COM) PIOS_WDG_RegisterFlag(PIOS_WDG_TRANSCOMM); PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORECEIVE); //PIOS_WDG_RegisterFlag(PIOS_WDG_SENDPACKET); - //PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA); if(PIOS_PPM_RECEIVER) PIOS_WDG_RegisterFlag(PIOS_WDG_PPMINPUT); #endif @@ -211,12 +243,21 @@ static int32_t RadioComBridgeInitialize(void) updateSettings(); // Initialise UAVTalk - data->inUAVTalkCon = UAVTalkInitialize(0); - data->outUAVTalkCon = UAVTalkInitialize(&transmitData); + data->GCSUAVTalkCon = UAVTalkInitialize(&GCSUAVTalkSendHandler); + if (PIOS_COM_UAVTALK) + data->UAVTalkCon = UAVTalkInitialize(&UAVTalkSendHandler); // Initialize the queues. - data->sendPacketQueue = xQueueCreate(PACKET_QUEUE_SIZE, sizeof(PHPacketHandle)); - data->objEventQueue = xQueueCreate(PACKET_QUEUE_SIZE, sizeof(UAVObjEvent)); + data->ppmOutQueue = 0; + data->radioPacketQueue = xQueueCreate(PACKET_QUEUE_SIZE, sizeof(UAVObjEvent)); + data->gcsEventQueue = xQueueCreate(PACKET_QUEUE_SIZE, sizeof(UAVObjEvent)); + if (PIOS_COM_UAVTALK) + data->uavtalkEventQueue = xQueueCreate(PACKET_QUEUE_SIZE, sizeof(UAVObjEvent)); + else + { + data->uavtalkEventQueue = 0; + data->ppmOutQueue = data->radioPacketQueue; + } // Initialize the statistics. data->radioTxErrors = 0; @@ -232,8 +273,8 @@ static int32_t RadioComBridgeInitialize(void) // Register the callbacks with the packet handler PHRegisterOutputStream(pios_packet_handler, transmitPacket); PHRegisterDataHandler(pios_packet_handler, receiveData); - PHRegisterStatusHandler(pios_packet_handler, StatusHandler); PHRegisterPPMHandler(pios_packet_handler, PPMHandler); + PHRegisterStatusHandler(pios_packet_handler, StatusHandler); // Initialize the packet send timeout data->send_timeout = 25; // ms @@ -255,9 +296,27 @@ static int32_t RadioComBridgeInitialize(void) PipXSettingsPairIDGet(&(data->pairStats[0].pairID)); // Configure our UAVObjects for updates. - UAVObjConnectQueue(UAVObjGetByName("PipXStatus"), data->objEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); - UAVObjConnectQueue(UAVObjGetByName("GCSReceiver"), data->objEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); - UAVObjConnectQueue(UAVObjGetByName("ObjectPersistence"), data->objEventQueue, EV_UPDATED | EV_UPDATED_MANUAL); + UAVObjConnectQueue(UAVObjGetByName("PipXStatus"), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); + UAVObjConnectQueue(UAVObjGetByName("GCSReceiver"), data->uavtalkEventQueue ? data->uavtalkEventQueue : data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); + UAVObjConnectQueue(UAVObjGetByName("ObjectPersistence"), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL); + + // Initialize the UAVTalk comm parameters. + data->gcs_uavtalk_params.UAVTalkCon = data->GCSUAVTalkCon; + data->gcs_uavtalk_params.sendQueue = data->radioPacketQueue; + data->gcs_uavtalk_params.recvQueue = data->gcsEventQueue; + data->gcs_uavtalk_params.wdg = PIOS_WDG_COMGCS; + data->gcs_uavtalk_params.checkHID = true; + data->gcs_uavtalk_params.comPort = PIOS_COM_GCS; + if (PIOS_COM_UAVTALK) + { + data->gcs_uavtalk_params.sendQueue = data->uavtalkEventQueue; + data->uavtalk_params.UAVTalkCon = data->UAVTalkCon; + data->uavtalk_params.sendQueue = data->radioPacketQueue; + data->uavtalk_params.recvQueue = data->uavtalkEventQueue; + data->uavtalk_params.wdg = PIOS_WDG_COMUAVTALK; + data->uavtalk_params.checkHID = false; + data->uavtalk_params.comPort = PIOS_COM_UAVTALK; + } return 0; } @@ -266,30 +325,32 @@ MODULE_INITCALL(RadioComBridgeInitialize, RadioComBridgeStart) /** * Reads UAVTalk messages froma com port and creates packets out of them. */ -static void comUAVTalkTask(void *parameters) +static void UAVTalkRecvTask(void *parameters) { + UAVTalkComTaskParams *params = (UAVTalkComTaskParams *)parameters; PHPacketHandle p = NULL; // Create the buffered reader. - BufferedReadHandle f = BufferedReadInit(PIOS_COM_UAVTALK, TEMP_BUFFER_SIZE); + BufferedReadHandle f = BufferedReadInit(params->comPort, TEMP_BUFFER_SIZE); while (1) { #ifdef PIOS_INCLUDE_WDG // Update the watchdog timer. - PIOS_WDG_UpdateFlag(PIOS_WDG_COMUAVTALK); + if (params->wdg) + PIOS_WDG_UpdateFlag(params->wdg); #endif /* PIOS_INCLUDE_WDG */ // Receive from USB HID if available, otherwise UAVTalk com if it's available. #if defined(PIOS_INCLUDE_USB) // Determine input port (USB takes priority over telemetry port) - if (PIOS_USB_CheckAvailable(0)) + if (params->checkHID && PIOS_USB_CheckAvailable(0)) BufferedReadSetCom(f, PIOS_COM_USB_HID); else #endif /* PIOS_INCLUDE_USB */ { - if (PIOS_COM_UAVTALK) - BufferedReadSetCom(f, PIOS_COM_UAVTALK); + if (params->comPort) + BufferedReadSetCom(f, params->comPort); else { vTaskDelay(5); @@ -307,7 +368,7 @@ static void comUAVTalkTask(void *parameters) { // Wait until we receive a sync. - UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(data->inUAVTalkCon, rx_byte); + UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(params->UAVTalkCon, rx_byte); if (state != UAVTALK_STATE_TYPE) continue; @@ -324,7 +385,6 @@ static void comUAVTalkTask(void *parameters) // Initialize the packet. p->header.destination_id = data->destination_id; p->header.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id); - //p->header.type = PACKET_TYPE_ACKED_DATA; p->header.type = PACKET_TYPE_DATA; p->data[0] = rx_byte; p->header.data_size = 1; @@ -335,12 +395,13 @@ static void comUAVTalkTask(void *parameters) p->data[p->header.data_size++] = rx_byte; // Keep reading until we receive a completed packet. - UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(data->inUAVTalkCon, rx_byte); - UAVTalkConnectionData *connection = (UAVTalkConnectionData*)(data->inUAVTalkCon); + UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(params->UAVTalkCon, rx_byte); + UAVTalkConnectionData *connection = (UAVTalkConnectionData*)(params->UAVTalkCon); UAVTalkInputProcessor *iproc = &(connection->iproc); if (state == UAVTALK_STATE_COMPLETE) { + // Is this a local UAVObject? // We only generate GcsReceiver ojects, we don't consume them. if ((iproc->obj != NULL) && (iproc->objId != GCSRECEIVER_OBJID)) @@ -359,11 +420,7 @@ static void comUAVTalkTask(void *parameters) if (obj_per.ObjectID == PIPXSETTINGS_OBJID) { // Queue up the ACK. - UAVObjEvent ev; - ev.obj = iproc->obj; - ev.instId = iproc->instId; - ev.event = EV_SEND_ACK; - xQueueSend(data->objEventQueue, &ev, MAX_PORT_DELAY); + queueEvent(params->recvQueue, (void*)iproc->obj, iproc->instId, EV_SEND_ACK); // Is this a save, load, or delete? bool success = true; @@ -421,7 +478,7 @@ static void comUAVTalkTask(void *parameters) else { // Otherwise, queue the packet for transmission. - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } } else @@ -438,14 +495,14 @@ static void comUAVTalkTask(void *parameters) case UAVTALK_TYPE_OBJ_REQ: // Queue up an object send request. ev.event = EV_UPDATE_REQ; - xQueueSend(data->objEventQueue, &ev, MAX_PORT_DELAY); + xQueueSend(params->recvQueue, &ev, MAX_PORT_DELAY); break; case UAVTALK_TYPE_OBJ_ACK: if (UAVObjUnpack(iproc->obj, iproc->instId, connection->rxBuffer) == 0) { // Queue up an ACK ev.event = EV_SEND_ACK; - xQueueSend(data->objEventQueue, &ev, MAX_PORT_DELAY); + xQueueSend(params->recvQueue, &ev, MAX_PORT_DELAY); } break; } @@ -457,22 +514,18 @@ static void comUAVTalkTask(void *parameters) else { // Queue the packet for transmission. - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } p = NULL; } else if(state == UAVTALK_STATE_ERROR) { - DEBUG_PRINTF(1, "UAVTalk FAILED!\n\r"); data->UAVTalkErrors++; // Send a NACK if required. if((iproc->obj) && (iproc->type == UAVTALK_TYPE_OBJ_ACK)) { // Queue up a NACK - UAVObjEvent ev; - ev.obj = iproc->obj; - ev.event = EV_SEND_NACK; - xQueueSend(data->objEventQueue, &ev, MAX_PORT_DELAY); + queueEvent(params->recvQueue, iproc->obj, iproc->instId, EV_SEND_NACK); // Release the packet and start over again. PHReleaseTXPacket(pios_packet_handler, p); @@ -480,7 +533,7 @@ static void comUAVTalkTask(void *parameters) else { // Transmit the packet anyway... - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } p = NULL; } @@ -525,7 +578,7 @@ static void radioReceiveTask(void *parameters) UAVObjEvent ev; ev.obj = (UAVObjHandle)p; ev.event = EV_PACKET_RECEIVED; - xQueueSend(data->objEventQueue, &ev, portMAX_DELAY); + xQueueSend(data->gcsEventQueue, &ev, portMAX_DELAY); } else { data->packetErrors++; @@ -540,7 +593,7 @@ static void radioReceiveTask(void *parameters) */ static void sendPacketTask(void *parameters) { - PHPacketHandle p; + UAVObjEvent ev; // Loop forever while (1) { @@ -549,19 +602,21 @@ static void sendPacketTask(void *parameters) //PIOS_WDG_UpdateFlag(PIOS_WDG_SENDPACKET); #endif /* PIOS_INCLUDE_WDG */ // Wait for a packet on the queue. - if (xQueueReceive(data->sendPacketQueue, &p, MAX_PORT_DELAY) == pdTRUE) { + if (xQueueReceive(data->radioPacketQueue, &ev, MAX_PORT_DELAY) == pdTRUE) { + PHPacketHandle p = (PHPacketHandle)ev.obj; // Send the packet. if(!PHTransmitPacket(pios_packet_handler, p)) - PHReleaseTXPacket(pios_packet_handler, p); + PHReleaseRXPacket(pios_packet_handler, p); } } } /** - * Send packets to the radio. + * Send packets to the com port. */ -static void sendDataTask(void *parameters) +static void UAVTalkSendTask(void *parameters) { + UAVTalkComTaskParams *params = (UAVTalkComTaskParams *)parameters; UAVObjEvent ev; // Loop forever @@ -573,14 +628,14 @@ static void sendDataTask(void *parameters) //PIOS_WDG_UpdateFlag(PIOS_WDG_SENDDATA); #endif /* PIOS_INCLUDE_WDG */ // Wait for a packet on the queue. - if (xQueueReceive(data->objEventQueue, &ev, MAX_PORT_DELAY) == pdTRUE) { + if (xQueueReceive(params->recvQueue, &ev, MAX_PORT_DELAY) == pdTRUE) { if ((ev.event == EV_UPDATED) || (ev.event == EV_UPDATE_REQ)) { // Send update (with retries) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendObject(data->outUAVTalkCon, ev.obj, 0, 0, RETRY_TIMEOUT_MS) == 0; + success = UAVTalkSendObject(params->UAVTalkCon, ev.obj, 0, 0, RETRY_TIMEOUT_MS) == 0; if (!success) ++retries; } @@ -592,7 +647,7 @@ static void sendDataTask(void *parameters) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendAck(data->outUAVTalkCon, ev.obj, ev.instId) == 0; + success = UAVTalkSendAck(params->UAVTalkCon, ev.obj, ev.instId) == 0; if (!success) ++retries; } @@ -604,7 +659,7 @@ static void sendDataTask(void *parameters) uint32_t retries = 0; int32_t success = -1; while (retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendNack(data->outUAVTalkCon, UAVObjGetID(ev.obj)) == 0; + success = UAVTalkSendNack(params->UAVTalkCon, UAVObjGetID(ev.obj)) == 0; if (!success) ++retries; } @@ -615,6 +670,13 @@ static void sendDataTask(void *parameters) // Receive the packet. PHReceivePacket(pios_packet_handler, (PHPacketHandle)ev.obj, false); } + else if(ev.event == EV_TRANSMIT_PACKET) + { + // Transmit the packet. + PHPacketHandle p = (PHPacketHandle)ev.obj; + transmitData(params->comPort, p->data, p->header.data_size, params->checkHID); + PHReleaseTXPacket(pios_packet_handler, p); + } } } } @@ -691,7 +753,7 @@ static void transparentCommTask(void * parameters) if (send_packet) { // Queue the packet for transmission. - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + queueEvent(data->radioPacketQueue, (void*)p, 0, EV_TRANSMIT_PACKET); // Reset the timeout timeout = MAX_PORT_DELAY; @@ -783,7 +845,7 @@ static void radioStatusTask(void *parameters) status_packet.dropped = data->droppedPackets; status_packet.resets = PIOS_RFM22B_Resets(pios_rfm22b_id); PHPacketHandle sph = (PHPacketHandle)&status_packet; - xQueueSend(data->sendPacketQueue, &sph, MAX_PORT_DELAY); + queueEvent(data->radioPacketQueue, (void*)sph, 0, EV_TRANSMIT_PACKET); cntr = 0; } } @@ -809,21 +871,51 @@ static void ppmInputTask(void *parameters) #endif /* PIOS_INCLUDE_WDG */ // Send the PPM packet - for (uint8_t i = 1; i <= PIOS_PPM_NUM_INPUTS; ++i) - ppm_packet.channels[i - 1] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i); + if (data->ppmOutQueue) + { + for (uint8_t i = 1; i <= PIOS_PPM_NUM_INPUTS; ++i) + ppm_packet.channels[i - 1] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i); - // Send the packet. - ppm_packet.header.destination_id = data->destination_id; - ppm_packet.header.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id); - ppm_packet.header.type = PACKET_TYPE_PPM; - ppm_packet.header.data_size = PH_PPM_DATA_SIZE(&ppm_packet); - xQueueSend(data->sendPacketQueue, &pph, MAX_PORT_DELAY); + // Send the packet. + ppm_packet.header.destination_id = data->destination_id; + ppm_packet.header.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id); + ppm_packet.header.type = PACKET_TYPE_PPM; + ppm_packet.header.data_size = PH_PPM_DATA_SIZE(&ppm_packet); + queueEvent(data->ppmOutQueue, (void*)pph, 0, EV_TRANSMIT_PACKET); + } + else + PPMHandler(ppm_packet.channels); // Delay until the next update period. vTaskDelay(PIOS_PPM_PACKET_UPDATE_PERIOD_MS / portTICK_RATE_MS); } } +/** + * Transmit data buffer to the com port. + * \param[in] params The comm parameters. + * \param[in] buf Data buffer to send + * \param[in] length Length of buffer + * \return -1 on failure + * \return number of bytes transmitted on success + */ +static int32_t UAVTalkSend(UAVTalkComTaskParams *params, uint8_t *buf, int32_t length) +{ + uint32_t outputPort = params->comPort; +#if defined(PIOS_INCLUDE_USB) + if (params->checkHID) + { + // Determine output port (USB takes priority over telemetry port) + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) + outputPort = PIOS_COM_USB_HID; + } +#endif /* PIOS_INCLUDE_USB */ + if(outputPort) + return PIOS_COM_SendBuffer(outputPort, buf, length); + else + return -1; +} + /** * Transmit data buffer to the com port. * \param[in] buf Data buffer to send @@ -831,18 +923,21 @@ static void ppmInputTask(void *parameters) * \return -1 on failure * \return number of bytes transmitted on success */ -static int32_t transmitData(uint8_t *buf, int32_t length) +static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length) { - uint32_t outputPort = PIOS_COM_UAVTALK; -#if defined(PIOS_INCLUDE_USB) - // Determine output port (USB takes priority over telemetry port) - if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) - outputPort = PIOS_COM_USB_HID; -#endif /* PIOS_INCLUDE_USB */ - if(outputPort) - return PIOS_COM_SendBuffer(outputPort, buf, length); - else - return -1; + return UAVTalkSend(&(data->uavtalk_params), buf, length); +} + +/** + * Transmit data buffer to the com port. + * \param[in] buf Data buffer to send + * \param[in] length Length of buffer + * \return -1 on failure + * \return number of bytes transmitted on success + */ +static int32_t GCSUAVTalkSendHandler(uint8_t *buf, int32_t length) +{ + return UAVTalkSend(&(data->gcs_uavtalk_params), buf, length); } /** @@ -863,22 +958,15 @@ static int32_t transmitPacket(PHPacketHandle p) * \param[in] buf The received data buffer * \param[in] length Length of buffer */ -static void receiveData(uint8_t *buf, uint8_t len, int8_t rssi, int8_t afc) +static void transmitData(uint32_t outputPort, uint8_t *buf, uint8_t len, bool checkHid) { - data->RSSI = rssi; - - // Packet data should go to transparent com if it's configured, - // USB HID if it's connected, otherwise, UAVTalk com if it's configured. - uint32_t outputPort = PIOS_COM_TRANS_COM; - if (!outputPort) - { - outputPort = PIOS_COM_UAVTALK; #if defined(PIOS_INCLUDE_USB) + // See if USB is connected if requested. + if(checkHid) // Determine output port (USB takes priority over telemetry port) if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) outputPort = PIOS_COM_USB_HID; #endif /* PIOS_INCLUDE_USB */ - } if (!outputPort) return; @@ -888,6 +976,21 @@ static void receiveData(uint8_t *buf, uint8_t len, int8_t rssi, int8_t afc) data->comTxErrors++; } +/** + * Receive a packet + * \param[in] buf The received data buffer + * \param[in] length Length of buffer + */ +static void receiveData(uint8_t *buf, uint8_t len, int8_t rssi, int8_t afc) +{ + data->RSSI = rssi; + + // Packet data should go to transparent com if it's configured, + // USB HID if it's connected, otherwise, UAVTalk com if it's configured. + uint32_t outputPort = PIOS_COM_TRANS_COM ? PIOS_COM_TRANS_COM : PIOS_COM_UAVTALK; + transmitData(outputPort, buf, len, true); +} + /** * Receive a status packet * \param[in] status The status structure @@ -1003,6 +1106,21 @@ static void BufferedReadSetCom(BufferedReadHandle h, uint32_t com_port) h->com_port = com_port; } +/** + * Queue and event into an event queue. + * \param[in] queue The event queue + * \param[in] obj The data pointer + * \param[in] type The event type + */ +static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEventType type) +{ + UAVObjEvent ev; + ev.obj = (UAVObjHandle)obj; + ev.instId = instId; + ev.event = type; + xQueueSend(queue, &ev, portMAX_DELAY); +} + /** * Update the telemetry settings, called on startup. * FIXME: This should be in the TelemetrySettings object. But objects @@ -1019,7 +1137,6 @@ static void updateSettings() // Initialize the destination ID data->destination_id = pipxSettings.PairID ? pipxSettings.PairID : 0xffffffff; - DEBUG_PRINTF(2, "PairID: %x\n\r", data->destination_id); if (PIOS_COM_TELEMETRY) { switch (pipxSettings.TelemetrySpeed) { diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 868bba722..71426d594 100755 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -77,6 +77,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1 #define PIOS_WDG_SENDDATA 0x0008 #define PIOS_WDG_TRANSCOMM 0x0010 #define PIOS_WDG_PPMINPUT 0x0020 +#define PIOS_WDG_COMGCS 0x0040 //------------------------ // TELEMETRY @@ -157,6 +158,7 @@ extern uint32_t pios_com_telemetry_id; extern uint32_t pios_com_flexi_id; extern uint32_t pios_com_vcp_id; extern uint32_t pios_com_uavtalk_com_id; +extern uint32_t pios_com_gcs_com_id; extern uint32_t pios_com_trans_com_id; extern uint32_t pios_com_debug_id; extern uint32_t pios_com_rfm22b_id; @@ -166,6 +168,7 @@ extern uint32_t pios_ppm_rcvr_id; #define PIOS_COM_FLEXI (pios_com_flexi_id) #define PIOS_COM_VCP (pios_com_vcp_id) #define PIOS_COM_UAVTALK (pios_com_uavtalk_com_id) +#define PIOS_COM_GCS (pios_com_gcs_com_id) #define PIOS_COM_TRANS_COM (pios_com_trans_com_id) #define PIOS_COM_DEBUG (pios_com_debug_id) #define PIOS_COM_RADIO (pios_com_rfm22b_id) diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index d1ab4bcfd..af77b6360 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -53,6 +53,7 @@ uint32_t pios_com_telemetry_id; uint32_t pios_com_flexi_id; uint32_t pios_com_vcp_id; uint32_t pios_com_uavtalk_com_id = 0; +uint32_t pios_com_gcs_com_id = 0; uint32_t pios_com_trans_com_id = 0; uint32_t pios_com_debug_id = 0; uint32_t pios_com_rfm22b_id = 0; @@ -96,7 +97,7 @@ void PIOS_Board_Init(void) { PipXSettingsData pipxSettings; #if defined(PIOS_INCLUDE_FLASH_EEPROM) - PIOS_EEPROM_Init(&pios_eeprom_cfg); + PIOS_EEPROM_Init(&pios_eeprom_cfg); /* Read the settings from flash. */ /* NOTE: We probably need to save/restore the objID here incase the object changed but the size doesn't */ @@ -218,6 +219,7 @@ void PIOS_Board_Init(void) { { case PIPXSETTINGS_TELEMETRYCONFIG_SERIAL: case PIPXSETTINGS_TELEMETRYCONFIG_UAVTALK: + case PIPXSETTINGS_TELEMETRYCONFIG_GCS: case PIPXSETTINGS_TELEMETRYCONFIG_DEBUG: { uint32_t pios_usart1_id; @@ -241,6 +243,9 @@ void PIOS_Board_Init(void) { case PIPXSETTINGS_TELEMETRYCONFIG_UAVTALK: pios_com_uavtalk_com_id = pios_com_telemetry_id; break; + case PIPXSETTINGS_TELEMETRYCONFIG_GCS: + pios_com_gcs_com_id = pios_com_telemetry_id; + break; case PIPXSETTINGS_TELEMETRYCONFIG_DEBUG: pios_com_debug_id = pios_com_telemetry_id; break; @@ -256,6 +261,7 @@ void PIOS_Board_Init(void) { { case PIPXSETTINGS_FLEXICONFIG_SERIAL: case PIPXSETTINGS_FLEXICONFIG_UAVTALK: + case PIPXSETTINGS_FLEXICONFIG_GCS: case PIPXSETTINGS_FLEXICONFIG_DEBUG: { uint32_t pios_usart3_id; @@ -279,6 +285,9 @@ void PIOS_Board_Init(void) { case PIPXSETTINGS_FLEXICONFIG_UAVTALK: pios_com_uavtalk_com_id = pios_com_flexi_id; break; + case PIPXSETTINGS_FLEXICONFIG_GCS: + pios_com_gcs_com_id = pios_com_flexi_id; + break; case PIPXSETTINGS_FLEXICONFIG_DEBUG: pios_com_debug_id = pios_com_flexi_id; break; diff --git a/shared/uavobjectdefinition/pipxsettings.xml b/shared/uavobjectdefinition/pipxsettings.xml index a8899ff47..52524aa22 100644 --- a/shared/uavobjectdefinition/pipxsettings.xml +++ b/shared/uavobjectdefinition/pipxsettings.xml @@ -2,9 +2,9 @@ PipXtreme configurations options. - + - + From 499e2ff989260df962aa5a8fbe70207bc33577a1 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 30 Jun 2012 17:12:33 -0700 Subject: [PATCH 09/20] Fixed PipX passthrough when connected via USB HID. --- .../Modules/RadioComBridge/RadioComBridge.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index 86373bd28..c76a295f6 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -84,6 +84,7 @@ typedef struct { UAVTalkConnection UAVTalkCon; xQueueHandle sendQueue; xQueueHandle recvQueue; + xQueueHandle gcsQueue; uint16_t wdg; bool checkHID; } UAVTalkComTaskParams; @@ -313,6 +314,7 @@ static int32_t RadioComBridgeInitialize(void) data->uavtalk_params.UAVTalkCon = data->UAVTalkCon; data->uavtalk_params.sendQueue = data->radioPacketQueue; data->uavtalk_params.recvQueue = data->uavtalkEventQueue; + data->uavtalk_params.gcsQueue = data->gcsEventQueue; data->uavtalk_params.wdg = PIOS_WDG_COMUAVTALK; data->uavtalk_params.checkHID = false; data->uavtalk_params.comPort = PIOS_COM_UAVTALK; @@ -401,6 +403,12 @@ static void UAVTalkRecvTask(void *parameters) if (state == UAVTALK_STATE_COMPLETE) { + xQueueHandle sendQueue = params->sendQueue; +#if defined(PIOS_INCLUDE_USB) + if (params->gcsQueue) + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) + sendQueue = params->gcsQueue; +#endif /* PIOS_INCLUDE_USB */ // Is this a local UAVObject? // We only generate GcsReceiver ojects, we don't consume them. @@ -478,7 +486,7 @@ static void UAVTalkRecvTask(void *parameters) else { // Otherwise, queue the packet for transmission. - queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); + queueEvent(sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } } else @@ -514,11 +522,17 @@ static void UAVTalkRecvTask(void *parameters) else { // Queue the packet for transmission. - queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); + queueEvent(sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } p = NULL; } else if(state == UAVTALK_STATE_ERROR) { + xQueueHandle sendQueue = params->sendQueue; +#if defined(PIOS_INCLUDE_USB) + if (params->gcsQueue) + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) + sendQueue = params->gcsQueue; +#endif /* PIOS_INCLUDE_USB */ data->UAVTalkErrors++; // Send a NACK if required. @@ -533,7 +547,7 @@ static void UAVTalkRecvTask(void *parameters) else { // Transmit the packet anyway... - queueEvent(params->sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); + queueEvent(sendQueue, (void*)p, 0, EV_TRANSMIT_PACKET); } p = NULL; } From 54455d60df7fc79b4ce71c5c5eeade24c291af98 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sun, 1 Jul 2012 08:32:34 -0700 Subject: [PATCH 10/20] Read PPM outside of the output test. --- flight/Modules/RadioComBridge/RadioComBridge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index c76a295f6..e1f7b767a 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -884,13 +884,13 @@ static void ppmInputTask(void *parameters) PIOS_WDG_UpdateFlag(PIOS_WDG_PPMINPUT); #endif /* PIOS_INCLUDE_WDG */ + // Read the receiver. + for (uint8_t i = 1; i <= PIOS_PPM_NUM_INPUTS; ++i) + ppm_packet.channels[i - 1] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i); + // Send the PPM packet if (data->ppmOutQueue) { - for (uint8_t i = 1; i <= PIOS_PPM_NUM_INPUTS; ++i) - ppm_packet.channels[i - 1] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i); - - // Send the packet. ppm_packet.header.destination_id = data->destination_id; ppm_packet.header.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id); ppm_packet.header.type = PACKET_TYPE_PPM; From 622ea04a1fdd79ca7d48b4f5aecac6be92ef38fe Mon Sep 17 00:00:00 2001 From: Kenz Dale Date: Mon, 9 Jul 2012 18:09:57 +0200 Subject: [PATCH 11/20] Changed .gitignore the ignore build files from XCode project. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 17b41c76c..a5af05849 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ /flight/OpenPilot/Build /flight/OpenPilot/Build.win32 +#flight/Project/OpenPilotOSX +flight/Project/OpenPilotOSX/build + # /flight/PipBee/ /flight/PipBee/Build From 4df81c5f852af3a836829f117c8c81b2d95e2f2c Mon Sep 17 00:00:00 2001 From: Kenz Dale Date: Mon, 9 Jul 2012 18:18:57 +0200 Subject: [PATCH 12/20] UDP Control Plugin. Initial merge for review. --- flight/Revolution/System/pios_board.c | 6 +- .../plugins/gcscontrol/Matlab/GCSControl.m | 29 +++++ .../src/plugins/gcscontrol/gcscontrol.pro | 1 + .../src/plugins/gcscontrol/gcscontrol.ui | 13 +++ .../plugins/gcscontrol/gcscontrolgadget.cpp | 107 +++++++++++++++++- .../src/plugins/gcscontrol/gcscontrolgadget.h | 7 ++ .../gcscontrolgadgetconfiguration.cpp | 24 ++++ .../gcscontrolgadgetconfiguration.h | 11 ++ .../gcscontrolgadgetoptionspage.cpp | 11 +- .../gcscontrol/gcscontrolgadgetoptionspage.ui | 68 ++++++++++- .../gcscontrol/gcscontrolgadgetwidget.cpp | 33 +++++- .../gcscontrol/gcscontrolgadgetwidget.h | 5 + 12 files changed, 305 insertions(+), 10 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 705463186..6e2319134 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -31,7 +31,7 @@ #include #include -#include "hwsettings.h" +#include #include "manualcontrolsettings.h" #include "board_hw_defs.c" @@ -483,8 +483,8 @@ void PIOS_Board_Init(void) { case HWSETTINGS_USB_HIDPORT_USBTELEMETRY: #if defined(PIOS_INCLUDE_COM) { - uint32_t pios_usb_hid_id; - if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) { + uint32_t pios_usb_cdc_id; + if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN); diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m b/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m new file mode 100644 index 000000000..218a0b78b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m @@ -0,0 +1,29 @@ +classdef GCSControl < handle + + properties + udpObj; + isConnected=false; + end + + methods + function obj=GCSControl() + obj.isConnected = false; + end + function obj=connect(obj,rhost,rport) + obj.udpObj = udp(rhost,rport); + fopen(obj.udpObj); + obj.isConnected = true; + end + function obj=command(obj,pitch,yaw,roll,throttle) + if(obj.isConnected) + fwrite(obj.udpObj,[42,pitch,yaw,roll,throttle,36],'double') + end + end + function obj=close(obj) + if(obj.isConnected) + fclose(obj.udpObj); + obj.isConnected = false; + end + end + end +end \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.pro b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.pro index 426579e77..2e4695328 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.pro +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.pro @@ -2,6 +2,7 @@ TEMPLATE = lib TARGET = GCSControl QT += svg QT += opengl +QT += network include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.ui b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.ui index 024db71bb..0d2889785 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.ui +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrol.ui @@ -41,8 +41,21 @@ + + + + false + + + UDP Control + + + + + true + Armed diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp index 3c00987f7..f5ddbdc94 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -44,6 +44,10 @@ GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widg manualControlCommandUpdated(getManualControlCommand()); + control_sock = new QUdpSocket(this); + + connect(control_sock,SIGNAL(readyRead()),this,SLOT(readUDPCommand())); + joystickTime.start(); GCSControlPlugin *pl = dynamic_cast(plugin); connect(pl->sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8))); @@ -67,6 +71,12 @@ void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config) yawChannel = ql.at(2); throttleChannel = ql.at(3); + // if(control_sock->isOpen()) + // control_sock->close(); + control_sock->bind(GCSControlConfig->getUDPControlHost(), GCSControlConfig->getUDPControlPort(),QUdpSocket::ShareAddress); + + + controlsMode = GCSControlConfig->getControlsMode(); int i; @@ -159,6 +169,7 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r newThrottle = leftY; break; } + newThrottle = (newThrottle + 1)/2.0; //check if buttons have control over this axis... if so don't update it int buttonRollControl=0; @@ -174,7 +185,8 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r } //if we are not in local gcs control mode, ignore the joystick input - if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false)return; + if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false || ((GCSControlGadgetWidget *)m_widget)->getUDPControl()) + return; if((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) { if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll); @@ -191,6 +203,93 @@ void GCSControlGadget::gamepads(quint8 count) // sdlGamepad.setTickRate(JOYSTICK_UPDATE_RATE); } +void GCSControlGadget::readUDPCommand() +{ + double pitch, yaw, roll, throttle; + while (control_sock->hasPendingDatagrams()) { + QByteArray datagram; + datagram.resize(control_sock->pendingDatagramSize()); + control_sock->readDatagram(datagram.data(), datagram.size()); + QDataStream readData(datagram); + bool badPack = false; + int state = 0; + while(!readData.atEnd() && !badPack) + { + double buffer; + readData >> buffer; + switch(state) + { + case 0: + if(buffer == 42){ + state = 1; + }else{ + state = 0; + badPack = true; + } + break; + case 1: + pitch = buffer; + state = 2; + break; + case 2: + yaw = buffer; + state = 3; + break; + case 3: + roll = buffer; + state = 4; + break; + case 4: + throttle = buffer; + state = 5; + break; + case 5: + if(buffer != 36 || !readData.atEnd()) + badPack=true; + break; + } + + } + if(!badPack && ((GCSControlGadgetWidget *)m_widget)->getUDPControl()) + { + ManualControlCommand * obj = getManualControlCommand(); + bool update = false; + + if(pitch != obj->getField("Pitch")->getDouble()){ + obj->getField("Pitch")->setDouble(constrain(pitch)); + update = true; + } + if(yaw != obj->getField("Yaw")->getDouble()){ + obj->getField("Yaw")->setDouble(constrain(yaw)); + update = true; + } + if(roll != obj->getField("Roll")->getDouble()){ + obj->getField("Roll")->setDouble(constrain(roll)); + update = true; + } + if(throttle != obj->getField("Throttle")->getDouble()){ + obj->getField("Throttle")->setDouble(constrain(throttle)); + update = true; + } + if(update) + obj->updated(); + } + } + + qDebug() << "Pitch: " << pitch << " Yaw: " << yaw << " Roll: " << roll << " Throttle: " << throttle; + + +} + +double GCSControlGadget::constrain(double value) +{ + if(value < -1) + return -1; + if(value > 1) + return 1; + return value; +} + void GCSControlGadget::buttonState(ButtonNumber number, bool pressed) { int state; @@ -200,6 +299,7 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed) UAVObjectManager *objManager = pm->getObject(); UAVDataObject* obj = dynamic_cast( objManager->getObject(QString("ManualControlCommand")) ); bool currentCGSControl = ((GCSControlGadgetWidget *)m_widget)->getGCSControl(); + bool currentUDPControl = ((GCSControlGadgetWidget *)m_widget)->getUDPControl(); switch (buttonSettings[number].ActionID) { @@ -268,6 +368,11 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed) ((GCSControlGadgetWidget *)m_widget)->setGCSControl(!currentCGSControl); break; + case 3: //UDP Control + if(currentCGSControl) + ((GCSControlGadgetWidget *)m_widget)->setUDPControl(!currentUDPControl); + + break; } break; diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.h b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.h index 4d465b0cd..216e6d075 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.h +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.h @@ -34,6 +34,9 @@ #include "sdlgamepad/sdlgamepad.h" #include #include "gcscontrolplugin.h" +#include +#include + namespace Core { class IUAVGadget; @@ -59,6 +62,7 @@ public: private: ManualControlCommand* getManualControlCommand(); + double constrain(double value); QTime joystickTime; QWidget *m_widget; QList m_context; @@ -72,6 +76,8 @@ private: double bound(double input); double wrap(double input); bool channelReverse[8]; + QUdpSocket *control_sock; + signals: void sticksChangedRemotely(double leftX, double leftY, double rightX, double rightY); @@ -79,6 +85,7 @@ signals: protected slots: void manualControlCommandUpdated(UAVObject *); void sticksChangedLocally(double leftX, double leftY, double rightX, double rightY); + void readUDPCommand(); // signals from joystick void gamepads(quint8 count); diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp index 24a72e62a..969b4556b 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp @@ -54,6 +54,9 @@ GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QS yawChannel = qSettings->value("yawChannel").toInt(); throttleChannel = qSettings->value("throttleChannel").toInt(); + udp_port = qSettings->value("controlPortUDP").toInt(); + udp_host = QHostAddress(qSettings->value("controlHostUDP").toString()); + int i; for (i=0;i<8;i++) { @@ -66,6 +69,21 @@ GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QS } +void GCSControlGadgetConfiguration::setUDPControlSettings(int port, QString host) +{ + udp_port = port; + udp_host = QHostAddress(host); +} + +int GCSControlGadgetConfiguration::getUDPControlPort() +{ + return udp_port; +} +QHostAddress GCSControlGadgetConfiguration::getUDPControlHost() +{ + return udp_host; +} + void GCSControlGadgetConfiguration::setRPYTchannels(int roll, int pitch, int yaw, int throttle) { rollChannel = roll; pitchChannel = pitch; @@ -102,6 +120,9 @@ IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone() m->yawChannel = yawChannel; m->throttleChannel = throttleChannel; + m->udp_host = udp_host; + m->udp_port = udp_port; + int i; for (i=0;i<8;i++) { @@ -126,6 +147,9 @@ void GCSControlGadgetConfiguration::saveConfig(QSettings* settings) const { settings->setValue("yawChannel", yawChannel); settings->setValue("throttleChannel", throttleChannel); + settings->setValue("controlPortUDP",QString::number(udp_port)); + settings->setValue("controlHostUDP",udp_host.toString()); + int i; for (i=0;i<8;i++) { diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h index c3ca4c6d3..8f1a07359 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h @@ -29,6 +29,7 @@ #define GCSCONTROLGADGETCONFIGURATION_H #include +#include typedef struct{ int ActionID; @@ -36,6 +37,11 @@ typedef struct{ double Amount; }buttonSettingsStruct; +typedef struct{ + int port; + QHostAddress address; +}portSettingsStruct; + using namespace Core; @@ -49,6 +55,9 @@ class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration void setControlsMode(int mode) { controlsMode = mode; } void setRPYTchannels(int roll, int pitch, int yaw, int throttle); + void setUDPControlSettings(int port, QString host); + int getUDPControlPort(); + QHostAddress getUDPControlHost(); int getControlsMode() { return controlsMode; } QList getChannelsMapping(); QList getChannelsReverse(); @@ -72,6 +81,8 @@ class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration int throttleChannel; buttonSettingsStruct buttonSettings[8]; bool channelReverse[8]; + int udp_port; + QHostAddress udp_host; }; diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp index ad0bf9a34..1a68c6be6 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp @@ -137,7 +137,7 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent) options_page->buttonFunction4 << options_page->buttonFunction5 << options_page->buttonFunction6 << options_page->buttonFunction7; QStringList buttonOptions; - buttonOptions <<"-" << "Roll" << "Pitch" << "Yaw" << "Throttle" << "Armed" << "GCS Control" ; + buttonOptions <<"-" << "Roll" << "Pitch" << "Yaw" << "Throttle" << "Armed" << "GCS Control"; //added UDP control to action list foreach (QComboBox* qb, buttonFunctionList) { qb->addItems(buttonOptions); } @@ -187,6 +187,9 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent) //updateButtonFunction(); + options_page->udp_host->setText(m_config->getUDPControlHost().toString()); + options_page->udp_port->setText(QString::number(m_config->getUDPControlPort())); + // Controls mode are from 1 to 4. if (m_config->getControlsMode()>0 && m_config->getControlsMode() < 5) @@ -262,6 +265,9 @@ void GCSControlGadgetOptionsPage::apply() } m_config->setRPYTchannels(roll,pitch,yaw,throttle); + m_config->setUDPControlSettings(options_page->udp_port->text().toInt(),options_page->udp_host->text()); + + int j; for (j=0;j<8;j++) { @@ -271,6 +277,7 @@ void GCSControlGadgetOptionsPage::apply() m_config->setChannelReverse(j,chRevList.at(j)->isChecked()); } + } void GCSControlGadgetOptionsPage::finish() @@ -369,7 +376,7 @@ void GCSControlGadgetOptionsPage::updateButtonAction(int controlID) if (buttonActionList.at(i)->currentText().compare("Toggles")==0) { disconnect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction())); - buttonOptions <<"-" << "Armed" << "GCS Control" ; + buttonOptions <<"-" << "Armed" << "GCS Control" << "UDP Control"; buttonFunctionList.at(i)->clear(); buttonFunctionList.at(i)->insertItems(-1,buttonOptions); diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui index 260aa4e04..1f2c50e18 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui @@ -141,9 +141,9 @@ - + - 0 + 1 @@ -1011,6 +1011,70 @@ + + + UDP Setup + + + + + 20 + 20 + 191 + 121 + + + + UDP Port Configuration + + + + + 60 + 30 + 113 + 30 + + + + + + + 10 + 40 + 67 + 17 + + + + Port: + + + + + + 60 + 70 + 113 + 30 + + + + + + + 10 + 80 + 67 + 17 + + + + Host: + + + + diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp index 6ee123ff6..09e25132d 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp @@ -34,6 +34,7 @@ #include #include + #include "uavobject.h" #include "uavobjectmanager.h" #include "manualcontrolcommand.h" @@ -64,9 +65,14 @@ GCSControlGadgetWidget::GCSControlGadgetWidget(QWidget *parent) : QLabel(parent) connect(m_gcscontrol->checkBoxArmed, SIGNAL(stateChanged(int)), this, SLOT(toggleArmed(int))); connect(m_gcscontrol->comboBoxFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFlightMode(int))); + connect(m_gcscontrol->checkBoxUDPControl, SIGNAL(stateChanged(int)),this,SLOT(toggleUDPControl(int))); //UDP control checkbox + // Connect object updated event from UAVObject to also update check boxes and dropdown connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(mccChanged(UAVObject*))); + + + leftX = 0; leftY = 0; rightX = 0; @@ -122,11 +128,14 @@ void GCSControlGadgetWidget::toggleControl(int state) UAVObject::SetGcsTelemetryAcked(mdata, false); UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE); mdata.gcsTelemetryUpdatePeriod = 100; + m_gcscontrol->checkBoxUDPControl->setEnabled(true); } else { mdata = mccInitialData; + toggleUDPControl(false); + m_gcscontrol->checkBoxUDPControl->setEnabled(false); } obj->setMetadata(mdata); } @@ -152,6 +161,16 @@ void GCSControlGadgetWidget::mccChanged(UAVObject * obj) m_gcscontrol->checkBoxArmed->setChecked(flightStatus->getField("Armed")->getValue() == "Armed"); } +void GCSControlGadgetWidget::toggleUDPControl(int state) +{ + if(state) + { + setUDPControl(true); + }else{ + setUDPControl(false); + } +} + /*! \brief Called when the flight mode drop down is changed and sets the ManualControlCommand->FlightMode accordingly */ @@ -168,11 +187,21 @@ void GCSControlGadgetWidget::selectFlightMode(int state) void GCSControlGadgetWidget::setGCSControl(bool newState) { m_gcscontrol->checkBoxGcsControl->setChecked(newState); -}; +} bool GCSControlGadgetWidget::getGCSControl(void) { return m_gcscontrol->checkBoxGcsControl->isChecked(); -}; +} + +void GCSControlGadgetWidget::setUDPControl(bool newState) +{ + m_gcscontrol->checkBoxUDPControl->setChecked(newState); +} + +bool GCSControlGadgetWidget::getUDPControl(void) +{ + return m_gcscontrol->checkBoxUDPControl->isChecked(); +} /** diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.h b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.h index 58c2ecb0f..5f4b3eba0 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetwidget.h @@ -31,6 +31,8 @@ #include #include "manualcontrolcommand.h" +#define UDP_PORT 2323 + class Ui_GCSControl; class GCSControlGadgetWidget : public QLabel @@ -42,6 +44,8 @@ public: ~GCSControlGadgetWidget(); void setGCSControl(bool newState); bool getGCSControl(void); + void setUDPControl(bool newState); + bool getUDPControl(void); signals: void sticksChanged(double leftX, double leftY, double rightX, double rightY); @@ -59,6 +63,7 @@ protected slots: void toggleArmed(int state); void selectFlightMode(int state); void mccChanged(UAVObject *); + void toggleUDPControl(int state); private: Ui_GCSControl *m_gcscontrol; From 8c252f4474bd5f949101c68495627296e01fac5d Mon Sep 17 00:00:00 2001 From: Kenz Dale Date: Thu, 12 Jul 2012 14:39:36 +0200 Subject: [PATCH 13/20] Fixed bug in throttle. Slightly reworked UDP config page. Added comments to matlab file. --- .../plugins/gcscontrol/Matlab/GCSControl.m | 19 ++++ .../plugins/gcscontrol/gcscontrolgadget.cpp | 1 - .../gcscontrol/gcscontrolgadgetoptionspage.ui | 94 +++++++++---------- 3 files changed, 64 insertions(+), 50 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m b/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m index 218a0b78b..39e89ffc1 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m +++ b/ground/openpilotgcs/src/plugins/gcscontrol/Matlab/GCSControl.m @@ -1,3 +1,22 @@ +% GCSCONTROL +% This class allows the user to send 4-axis stick commands to OpenPilot +% GCS. +% +% Create class by +% control = GCSControl +% +% Open connection by +% control.connect('01.23.45.67', 89) +% where the first value is the IP address of the computer running GCS and +% the second value is the port on which GCS is listening. +% +% Send command by +% control.command(pitch, yaw, roll, throttle) +% where all variables are between [-1,1] +% +% Close connection by +% control.close() + classdef GCSControl < handle properties diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp index f5ddbdc94..b95082fb9 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -169,7 +169,6 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r newThrottle = leftY; break; } - newThrottle = (newThrottle + 1)/2.0; //check if buttons have control over this axis... if so don't update it int buttonRollControl=0; diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui index 1f2c50e18..5191788a0 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui @@ -143,7 +143,7 @@ - 1 + 0 @@ -1020,59 +1020,55 @@ 20 20 - 191 - 121 + 301 + 71 UDP Port Configuration - - - - 60 - 30 - 113 - 30 - - - - - - - 10 - 40 - 67 - 17 - - - - Port: - - - - - - 60 - 70 - 113 - 30 - - - - - - - 10 - 80 - 67 - 17 - - - - Host: - - + + + + + Host: + + + + + + + + 120 + 16777215 + + + + 127.0.0.1 + + + + + + + Port: + + + + + + + + 50 + 16777215 + + + + 2323 + + + + From bc87319a0382aacd1bfb8b3b1b1cb2b929345aec Mon Sep 17 00:00:00 2001 From: Kenz Dale Date: Thu, 12 Jul 2012 14:41:41 +0200 Subject: [PATCH 14/20] Minor int vs. unsigned int bugfix. --- .../src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp index 969b4556b..c213088c6 100644 --- a/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp @@ -54,7 +54,7 @@ GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QS yawChannel = qSettings->value("yawChannel").toInt(); throttleChannel = qSettings->value("throttleChannel").toInt(); - udp_port = qSettings->value("controlPortUDP").toInt(); + udp_port = qSettings->value("controlPortUDP").toUInt(); udp_host = QHostAddress(qSettings->value("controlHostUDP").toString()); int i; From 03beb0bad6b055c370e3f7e09893efc67a0cabfc Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 14 Jul 2012 08:17:57 -0700 Subject: [PATCH 15/20] Fixes to PipX firmware to compile with non codesourcery compiler. --- flight/PipXtreme/Makefile | 2 +- flight/PipXtreme/System/pios_board.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 9ef5e9842..63f2e7907 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -53,7 +53,7 @@ USE_GPS ?= NO USE_I2C ?= YES # Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= YES +CODE_SOURCERY ?= NO # Remove command is different for Code Sourcery on Windows ifeq ($(CODE_SOURCERY), YES) diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index af77b6360..d61fee4ac 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -130,20 +130,17 @@ void PIOS_Board_Init(void) { /* Flags to determine if various USB interfaces are advertised */ - bool usb_hid_present = false; bool usb_cdc_present = false; #if defined(PIOS_INCLUDE_USB_CDC) if (PIOS_USB_DESC_HID_CDC_Init()) { PIOS_Assert(0); } - usb_hid_present = true; usb_cdc_present = true; #else if (PIOS_USB_DESC_HID_ONLY_Init()) { PIOS_Assert(0); } - usb_hid_present = true; #endif uint32_t pios_usb_id; From a252b78feabd4ee8572cfd3cfc39337122cea3d6 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 14 Jul 2012 17:14:17 -0700 Subject: [PATCH 16/20] Fixed transparent comms on PipX. --- flight/Libraries/packet_handler.c | 35 +++++++++---------- .../Modules/RadioComBridge/RadioComBridge.c | 16 +++------ flight/PipXtreme/System/pios_board.c | 2 +- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/flight/Libraries/packet_handler.c b/flight/Libraries/packet_handler.c index 59a9a187f..f4e8e28d7 100644 --- a/flight/Libraries/packet_handler.c +++ b/flight/Libraries/packet_handler.c @@ -169,16 +169,15 @@ PHPacketHandle PHGetTXPacket(PHInstHandle h) // Lock xSemaphoreTakeRecursive(data->lock, portMAX_DELAY); - PHPacketHandle p = data->tx_packets + data->tx_win_end; - // Is the window full? - uint8_t next_end = (data->tx_win_end + 1) % data->cfg.winSize; - if(next_end == data->tx_win_start) - { - xSemaphoreGiveRecursive(data->lock); - return NULL; - } - data->tx_win_end = next_end; + // Find a free packet. + PHPacketHandle p = NULL; + for (uint8_t i = 0; i < data->cfg.winSize; ++i) + if (data->tx_packets[i].header.type == PACKET_TYPE_NONE) + { + p = data->tx_packets + i; + break; + } // Release lock xSemaphoreGiveRecursive(data->lock); @@ -224,17 +223,15 @@ PHPacketHandle PHGetRXPacket(PHInstHandle h) // Lock xSemaphoreTakeRecursive(data->lock, portMAX_DELAY); - PHPacketHandle p = data->rx_packets + data->rx_win_end; - // Is the window full? - uint8_t next_end = (data->rx_win_end + 1) % data->cfg.winSize; - if(next_end == data->rx_win_start) - { - // Release lock - xSemaphoreGiveRecursive(data->lock); - return NULL; - } - data->rx_win_end = next_end; + // Find a free packet. + PHPacketHandle p = NULL; + for (uint8_t i = 0; i < data->cfg.winSize; ++i) + if (data->rx_packets[i].header.type == PACKET_TYPE_NONE) + { + p = data->rx_packets + i; + break; + } // Release lock xSemaphoreGiveRecursive(data->lock); diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index d48c6de06..eb674cbdd 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -491,9 +491,6 @@ static void UAVTalkRecvTask(void *parameters) } else { - UAVObjEvent ev; - ev.obj = iproc->obj; - ev.instId = 0; switch (iproc->type) { case UAVTALK_TYPE_OBJ: @@ -502,16 +499,12 @@ static void UAVTalkRecvTask(void *parameters) break; case UAVTALK_TYPE_OBJ_REQ: // Queue up an object send request. - ev.event = EV_UPDATE_REQ; - xQueueSend(params->recvQueue, &ev, MAX_PORT_DELAY); + queueEvent(params->recvQueue, (void*)iproc->obj, iproc->instId, EV_UPDATE_REQ); break; case UAVTALK_TYPE_OBJ_ACK: if (UAVObjUnpack(iproc->obj, iproc->instId, connection->rxBuffer) == 0) - { // Queue up an ACK - ev.event = EV_SEND_ACK; - xQueueSend(params->recvQueue, &ev, MAX_PORT_DELAY); - } + queueEvent(params->recvQueue, (void*)iproc->obj, iproc->instId, EV_SEND_ACK); break; } @@ -735,7 +728,7 @@ static void transparentCommTask(void * parameters) } // Receive data from the com port - uint32_t cur_rx_bytes = PIOS_COM_ReceiveBuffer(PIOS_COM_TRANS_COM, p->data + p->header.data_size, + uint32_t cur_rx_bytes = PIOS_COM_ReceiveBuffer(PIOS_COM_TRANS_COM, p->data + p->header.data_size, PH_MAX_DATA - p->header.data_size, timeout); // Do we have an data to send? @@ -1002,7 +995,8 @@ static void receiveData(uint8_t *buf, uint8_t len, int8_t rssi, int8_t afc) // Packet data should go to transparent com if it's configured, // USB HID if it's connected, otherwise, UAVTalk com if it's configured. uint32_t outputPort = PIOS_COM_TRANS_COM ? PIOS_COM_TRANS_COM : PIOS_COM_UAVTALK; - transmitData(outputPort, buf, len, true); + bool checkHid = (PIOS_COM_TRANS_COM == 0); + transmitData(outputPort, buf, len, checkHid); } /** diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index d61fee4ac..e08aba454 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -170,7 +170,7 @@ void PIOS_Board_Init(void) { tx_buffer, PIOS_COM_VCP_USB_TX_BUF_LEN)) { PIOS_Assert(0); } - switch (pipxSettings.TelemetryConfig) + switch (pipxSettings.VCPConfig) { case PIPXSETTINGS_VCPCONFIG_SERIAL: pios_com_trans_com_id = pios_com_vcp_id; From cc6b48754d060ec85f0a3b23f5fc0ca8e495ab0b Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sat, 14 Jul 2012 17:17:01 -0700 Subject: [PATCH 17/20] Reduced buffer sizes on PipX. --- flight/PipXtreme/System/pios_board.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index e08aba454..3a2dd0544 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -33,20 +33,20 @@ #include #include -#define PIOS_COM_SERIAL_RX_BUF_LEN 256 -#define PIOS_COM_SERIAL_TX_BUF_LEN 256 +#define PIOS_COM_SERIAL_RX_BUF_LEN 128 +#define PIOS_COM_SERIAL_TX_BUF_LEN 128 -#define PIOS_COM_FLEXI_RX_BUF_LEN 256 -#define PIOS_COM_FLEXI_TX_BUF_LEN 256 +#define PIOS_COM_FLEXI_RX_BUF_LEN 128 +#define PIOS_COM_FLEXI_TX_BUF_LEN 128 -#define PIOS_COM_TELEM_USB_RX_BUF_LEN 256 -#define PIOS_COM_TELEM_USB_TX_BUF_LEN 256 +#define PIOS_COM_TELEM_USB_RX_BUF_LEN 128 +#define PIOS_COM_TELEM_USB_TX_BUF_LEN 128 -#define PIOS_COM_VCP_USB_RX_BUF_LEN 256 -#define PIOS_COM_VCP_USB_TX_BUF_LEN 256 +#define PIOS_COM_VCP_USB_RX_BUF_LEN 128 +#define PIOS_COM_VCP_USB_TX_BUF_LEN 128 -#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 256 -#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 256 +#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 128 +#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 128 uint32_t pios_com_telem_usb_id = 0; uint32_t pios_com_telemetry_id; From 9f67e24ee582a66230e683f40b1b843446f7041f Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Mon, 16 Jul 2012 13:08:12 -0700 Subject: [PATCH 18/20] MultiRotor Config, Bugfix: include TriYaw channel in getChannelDescriptions --- .../plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index d27f4c530..bfa4fe7a2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -274,6 +274,8 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions() channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW"); if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < ConfigMultiRotorWidget::CHANNEL_NUMELEM) channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE"); + if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.TRIYaw-1] = QString("Tri-Yaw"); return channelDesc; } From 3ad711142392f83596548997a28641457898c8ac Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 17 Jul 2012 23:06:47 +0200 Subject: [PATCH 19/20] Reverted change in pios_board.c, relating to revo udp control. Original commit had unnecessary changes. --- flight/Revolution/System/pios_board.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 6e2319134..705463186 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -31,7 +31,7 @@ #include #include -#include +#include "hwsettings.h" #include "manualcontrolsettings.h" #include "board_hw_defs.c" @@ -483,8 +483,8 @@ void PIOS_Board_Init(void) { case HWSETTINGS_USB_HIDPORT_USBTELEMETRY: #if defined(PIOS_INCLUDE_COM) { - uint32_t pios_usb_cdc_id; - if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) { + uint32_t pios_usb_hid_id; + if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN); From 707f63b884d074c787693ad8ab3f303080a6374a Mon Sep 17 00:00:00 2001 From: David Date: Thu, 19 Jul 2012 07:02:49 +1000 Subject: [PATCH 20/20] Change the wording to be less harsh --- ground/openpilotgcs/src/plugins/config/airframe.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 47006a789..ba3396ac7 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -2788,7 +2788,7 @@ p, li { white-space: pre-wrap; } <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD NEEDS CAUTION</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</p></td></tr></table></body></html>