From 68d12b1b2f150579268ac385349cc635fadbb697 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sun, 13 May 2012 14:24:00 -0700 Subject: [PATCH 1/2] Fixed some bugs with setting PairIDs in GCS. --- .../Modules/RadioComBridge/RadioComBridge.c | 25 +++++--- flight/PipXtreme/System/pios_board.c | 21 +++--- .../plugins/config/configpipxtremewidget.cpp | 64 +++++++++++++++---- .../plugins/config/configpipxtremewidget.h | 6 +- 4 files changed, 84 insertions(+), 32 deletions(-) mode change 100644 => 100755 flight/Modules/RadioComBridge/RadioComBridge.c mode change 100644 => 100755 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp mode change 100644 => 100755 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c old mode 100644 new mode 100755 index 8f9ce7a8b..981acc4cb --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -172,7 +172,7 @@ static int32_t RadioComBridgeStart(void) PIOS_WDG_RegisterFlag(PIOS_WDG_TRANSCOMM); PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORECEIVE); PIOS_WDG_RegisterFlag(PIOS_WDG_SENDPACKET); - PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA); + //PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA); #endif return 0; } @@ -535,7 +535,9 @@ static void sendDataTask(void *parameters) while (1) { #ifdef PIOS_INCLUDE_WDG // Update the watchdog timer. - PIOS_WDG_UpdateFlag(PIOS_WDG_SENDDATA); + // NOTE: this is temporarily turned off becase PIOS_Com_SendBuffer appears to block for an uncontrollable time, + // and SendBufferNonBlocking doesn't seem to be working in this case. + //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) { @@ -587,7 +589,7 @@ static void sendDataTask(void *parameters) static void transparentCommTask(void * parameters) { portTickType packet_start_time = 0; - uint32_t timeout = 250; + uint32_t timeout = MAX_PORT_DELAY; PHPacketHandle p = NULL; /* Handle usart/usb -> radio direction */ @@ -621,7 +623,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, - PH_MAX_DATA - p->header.data_size, timeout); + PH_MAX_DATA - p->header.data_size, timeout); // Do we have an data to send? p->header.data_size += cur_rx_bytes; @@ -655,7 +657,7 @@ static void transparentCommTask(void * parameters) PHTransmitPacket(pios_packet_handler, p); // Reset the timeout - timeout = 500; + timeout = MAX_PORT_DELAY; p = NULL; packet_start_time = 0; } @@ -752,7 +754,10 @@ static int32_t transmitData(uint8_t *buf, int32_t length) if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) outputPort = PIOS_COM_USB_HID; #endif /* PIOS_INCLUDE_USB */ - return PIOS_COM_SendBuffer(outputPort, buf, length); + if(outputPort) + return PIOS_COM_SendBuffer(outputPort, buf, length); + else + return -1; } /** @@ -774,16 +779,16 @@ static int32_t transmitPacket(PHPacketHandle p) */ static void receiveData(uint8_t *buf, uint8_t len) { - // Packet data should to to transparent com if it's configured, + // 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) - // Determine output port (USB takes priority over telemetry port) - if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) - outputPort = PIOS_COM_USB_HID; + // 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) diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index dc752b51a..1ca4ea680 100755 --- 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 192 -#define PIOS_COM_SERIAL_TX_BUF_LEN 192 +#define PIOS_COM_SERIAL_RX_BUF_LEN 256 +#define PIOS_COM_SERIAL_TX_BUF_LEN 256 -#define PIOS_COM_FLEXI_RX_BUF_LEN 192 -#define PIOS_COM_FLEXI_TX_BUF_LEN 192 +#define PIOS_COM_FLEXI_RX_BUF_LEN 256 +#define PIOS_COM_FLEXI_TX_BUF_LEN 256 -#define PIOS_COM_TELEM_USB_RX_BUF_LEN 512 -#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192 +#define PIOS_COM_TELEM_USB_RX_BUF_LEN 256 +#define PIOS_COM_TELEM_USB_TX_BUF_LEN 256 -#define PIOS_COM_VCP_USB_RX_BUF_LEN 192 -#define PIOS_COM_VCP_USB_TX_BUF_LEN 192 +#define PIOS_COM_VCP_USB_RX_BUF_LEN 256 +#define PIOS_COM_VCP_USB_TX_BUF_LEN 256 -#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 192 -#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 192 +#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 256 +#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 256 uint32_t pios_com_usb_hid_id = 0; uint32_t pios_com_telemetry_id; @@ -97,6 +97,7 @@ void PIOS_Board_Init(void) { 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 */ PipXSettingsData pipxSettings; if (PIOS_EEPROM_Load((uint8_t*)&pipxSettings, sizeof(PipXSettingsData)) == 0) PipXSettingsSet(&pipxSettings); diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp old mode 100644 new mode 100755 index 295338f1a..b782eafb3 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -54,8 +54,6 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget } addApplySaveButtons(m_pipx->Apply, m_pipx->Save); - //connect(m_pipx->Apply, SIGNAL(clicked()), this, SLOT(applySettings())); - //connect(m_pipx->Save, SIGNAL(clicked()), this, SLOT(saveSettings())); addUAVObjectToWidgetRelation("PipXSettings", "TelemetryConfig", m_pipx->TelemPortConfig); addUAVObjectToWidgetRelation("PipXSettings", "TelemetrySpeed", m_pipx->TelemPortSpeed); @@ -81,6 +79,12 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget addUAVObjectToWidgetRelation("PipXStatus", "RXRate", m_pipx->RXRate); addUAVObjectToWidgetRelation("PipXStatus", "TXRate", m_pipx->TXRate); + // Connect to the pair ID radio buttons. + 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))); + connect(m_pipx->PairSelect4, SIGNAL(toggled(bool)), this, SLOT(pair4Toggled(bool))); + // Create the timer that is used to timeout the connection to the PipX. timeOut = new QTimer(this); connect(timeOut, SIGNAL(timeout()),this,SLOT(disconnected())); @@ -139,28 +143,34 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object) if (!settingsUpdated) pipxSettingsObj->requestUpdate(); + // Get the current pairID + PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager()); + quint32 pairID = 0; + if (pipxSettings) + pipxSettings->getPairID(); + // Update the detected devices. UAVObjectField* pairIdField = object->getField("PairIDs"); if (pairIdField) { quint32 pairid1 = pairIdField->getValue(0).toUInt(); m_pipx->PairID1->setText(QString::number(pairid1, 16).toUpper()); m_pipx->PairID1->setEnabled(false); - m_pipx->PairSelect1->setChecked(pairID == pairid1); + m_pipx->PairSelect1->setChecked(pairID && (pairID == pairid1)); m_pipx->PairSelect1->setEnabled(pairid1); quint32 pairid2 = pairIdField->getValue(1).toUInt(); m_pipx->PairID2->setText(QString::number(pairIdField->getValue(1).toUInt(), 16).toUpper()); m_pipx->PairID2->setEnabled(false); - m_pipx->PairSelect2->setChecked(pairID == pairid2); + m_pipx->PairSelect2->setChecked(pairID && (pairID == pairid2)); m_pipx->PairSelect2->setEnabled(pairid2); quint32 pairid3 = pairIdField->getValue(2).toUInt(); m_pipx->PairID3->setText(QString::number(pairIdField->getValue(2).toUInt(), 16).toUpper()); m_pipx->PairID3->setEnabled(false); - m_pipx->PairSelect3->setChecked(pairID == pairid3); + m_pipx->PairSelect3->setChecked(pairID && (pairID == pairid3)); m_pipx->PairSelect3->setEnabled(pairid3); quint32 pairid4 = pairIdField->getValue(3).toUInt(); m_pipx->PairID4->setText(QString::number(pairIdField->getValue(3).toUInt(), 16).toUpper()); m_pipx->PairID4->setEnabled(false); - m_pipx->PairSelect4->setChecked(pairID == pairid4); + m_pipx->PairSelect4->setChecked(pairID && (pairID == pairid4)); m_pipx->PairSelect4->setEnabled(pairid4); } else { qDebug() << "PipXtremeGadgetWidget: Count not read PairID field."; @@ -240,11 +250,6 @@ void ConfigPipXtremeWidget::updateSettings(UAVObject *object) { settingsUpdated = true; enableControls(true); - - // Get the settings object. - PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager()); - PipXSettings::DataFields pipxSettingsData = pipxSettings->getData(); - pairID = pipxSettingsData.PairID; } void ConfigPipXtremeWidget::disconnected() @@ -253,6 +258,43 @@ void ConfigPipXtremeWidget::disconnected() enableControls(false); } +void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx) +{ + qDebug() << "Toggled"; + if(checked) + { + PipXStatus *pipxStatus = PipXStatus::GetInstance(getObjectManager()); + PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager()); + + if (pipxStatus && pipxSettings) + { + quint32 pairID = pipxStatus->getPairIDs(idx); + if (pairID) + pipxSettings->setPairID(pairID); + } + } +} + +void ConfigPipXtremeWidget::pair1Toggled(bool checked) +{ + pairIDToggled(checked, 0); +} + +void ConfigPipXtremeWidget::pair2Toggled(bool checked) +{ + pairIDToggled(checked, 1); +} + +void ConfigPipXtremeWidget::pair3Toggled(bool checked) +{ + pairIDToggled(checked, 2); +} + +void ConfigPipXtremeWidget::pair4Toggled(bool checked) +{ + pairIDToggled(checked, 3); +} + /** @} @} diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h old mode 100644 new mode 100755 index d0ca690af..34c1f1673 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h @@ -52,7 +52,6 @@ private: UAVDataObject* pipxSettingsObj; bool settingsUpdated; - quint32 pairID; // A timer that timesout the connction to the PipX. QTimer *timeOut; @@ -62,6 +61,11 @@ private slots: void applySettings(); void saveSettings(); void disconnected(); + void pairIDToggled(bool checked, quint8 idx); + void pair1Toggled(bool checked); + void pair2Toggled(bool checked); + void pair3Toggled(bool checked); + void pair4Toggled(bool checked); }; #endif // CONFIGTXPIDWIDGET_H From a3269aaf2f9f2e62d2d3ad0af93a856b06cb839f Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Sun, 13 May 2012 14:24:57 -0700 Subject: [PATCH 2/2] Reverted some file permission changes. --- flight/Modules/RadioComBridge/RadioComBridge.c | 0 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp | 0 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 flight/Modules/RadioComBridge/RadioComBridge.c mode change 100755 => 100644 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp mode change 100755 => 100644 ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c old mode 100755 new mode 100644 diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp old mode 100755 new mode 100644 diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h old mode 100755 new mode 100644