1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

Merge remote-tracking branch 'raid/Brian-PipXtreme-V2' into Brian-PipXtreme-V2

This commit is contained in:
Brian Webb 2012-05-13 14:25:40 -07:00
commit 13b649f6e0
4 changed files with 84 additions and 32 deletions

View File

@ -172,7 +172,7 @@ static int32_t RadioComBridgeStart(void)
PIOS_WDG_RegisterFlag(PIOS_WDG_TRANSCOMM); PIOS_WDG_RegisterFlag(PIOS_WDG_TRANSCOMM);
PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORECEIVE); PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORECEIVE);
PIOS_WDG_RegisterFlag(PIOS_WDG_SENDPACKET); PIOS_WDG_RegisterFlag(PIOS_WDG_SENDPACKET);
PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA); //PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA);
#endif #endif
return 0; return 0;
} }
@ -535,7 +535,9 @@ static void sendDataTask(void *parameters)
while (1) { while (1) {
#ifdef PIOS_INCLUDE_WDG #ifdef PIOS_INCLUDE_WDG
// Update the watchdog timer. // 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 */ #endif /* PIOS_INCLUDE_WDG */
// Wait for a packet on the queue. // Wait for a packet on the queue.
if (xQueueReceive(data->objEventQueue, &ev, MAX_PORT_DELAY) == pdTRUE) { if (xQueueReceive(data->objEventQueue, &ev, MAX_PORT_DELAY) == pdTRUE) {
@ -587,7 +589,7 @@ static void sendDataTask(void *parameters)
static void transparentCommTask(void * parameters) static void transparentCommTask(void * parameters)
{ {
portTickType packet_start_time = 0; portTickType packet_start_time = 0;
uint32_t timeout = 250; uint32_t timeout = MAX_PORT_DELAY;
PHPacketHandle p = NULL; PHPacketHandle p = NULL;
/* Handle usart/usb -> radio direction */ /* Handle usart/usb -> radio direction */
@ -621,7 +623,7 @@ static void transparentCommTask(void * parameters)
// Receive data from the com port // 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); PH_MAX_DATA - p->header.data_size, timeout);
// Do we have an data to send? // Do we have an data to send?
p->header.data_size += cur_rx_bytes; p->header.data_size += cur_rx_bytes;
@ -655,7 +657,7 @@ static void transparentCommTask(void * parameters)
PHTransmitPacket(pios_packet_handler, p); PHTransmitPacket(pios_packet_handler, p);
// Reset the timeout // Reset the timeout
timeout = 500; timeout = MAX_PORT_DELAY;
p = NULL; p = NULL;
packet_start_time = 0; 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) if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID)
outputPort = PIOS_COM_USB_HID; outputPort = PIOS_COM_USB_HID;
#endif /* PIOS_INCLUDE_USB */ #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) 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. // USB HID if it's connected, otherwise, UAVTalk com if it's configured.
uint32_t outputPort = PIOS_COM_TRANS_COM; uint32_t outputPort = PIOS_COM_TRANS_COM;
if (!outputPort) if (!outputPort)
{ {
outputPort = PIOS_COM_UAVTALK; outputPort = PIOS_COM_UAVTALK;
#if defined(PIOS_INCLUDE_USB) #if defined(PIOS_INCLUDE_USB)
// Determine output port (USB takes priority over telemetry port) // Determine output port (USB takes priority over telemetry port)
if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID) if (PIOS_USB_CheckAvailable(0) && PIOS_COM_USB_HID)
outputPort = PIOS_COM_USB_HID; outputPort = PIOS_COM_USB_HID;
#endif /* PIOS_INCLUDE_USB */ #endif /* PIOS_INCLUDE_USB */
} }
if (!outputPort) if (!outputPort)

View File

@ -33,20 +33,20 @@
#include <pipxsettings.h> #include <pipxsettings.h>
#include <board_hw_defs.c> #include <board_hw_defs.c>
#define PIOS_COM_SERIAL_RX_BUF_LEN 192 #define PIOS_COM_SERIAL_RX_BUF_LEN 256
#define PIOS_COM_SERIAL_TX_BUF_LEN 192 #define PIOS_COM_SERIAL_TX_BUF_LEN 256
#define PIOS_COM_FLEXI_RX_BUF_LEN 192 #define PIOS_COM_FLEXI_RX_BUF_LEN 256
#define PIOS_COM_FLEXI_TX_BUF_LEN 192 #define PIOS_COM_FLEXI_TX_BUF_LEN 256
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 512 #define PIOS_COM_TELEM_USB_RX_BUF_LEN 256
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 256
#define PIOS_COM_VCP_USB_RX_BUF_LEN 192 #define PIOS_COM_VCP_USB_RX_BUF_LEN 256
#define PIOS_COM_VCP_USB_TX_BUF_LEN 192 #define PIOS_COM_VCP_USB_TX_BUF_LEN 256
#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 192 #define PIOS_COM_RFM22B_RF_RX_BUF_LEN 256
#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 192 #define PIOS_COM_RFM22B_RF_TX_BUF_LEN 256
uint32_t pios_com_usb_hid_id = 0; uint32_t pios_com_usb_hid_id = 0;
uint32_t pios_com_telemetry_id; uint32_t pios_com_telemetry_id;
@ -97,6 +97,7 @@ void PIOS_Board_Init(void) {
PIOS_EEPROM_Init(&pios_eeprom_cfg); PIOS_EEPROM_Init(&pios_eeprom_cfg);
/* Read the settings from flash. */ /* 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; PipXSettingsData pipxSettings;
if (PIOS_EEPROM_Load((uint8_t*)&pipxSettings, sizeof(PipXSettingsData)) == 0) if (PIOS_EEPROM_Load((uint8_t*)&pipxSettings, sizeof(PipXSettingsData)) == 0)
PipXSettingsSet(&pipxSettings); PipXSettingsSet(&pipxSettings);

View File

@ -54,8 +54,6 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
} }
addApplySaveButtons(m_pipx->Apply, m_pipx->Save); 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", "TelemetryConfig", m_pipx->TelemPortConfig);
addUAVObjectToWidgetRelation("PipXSettings", "TelemetrySpeed", m_pipx->TelemPortSpeed); addUAVObjectToWidgetRelation("PipXSettings", "TelemetrySpeed", m_pipx->TelemPortSpeed);
@ -81,6 +79,12 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
addUAVObjectToWidgetRelation("PipXStatus", "RXRate", m_pipx->RXRate); addUAVObjectToWidgetRelation("PipXStatus", "RXRate", m_pipx->RXRate);
addUAVObjectToWidgetRelation("PipXStatus", "TXRate", m_pipx->TXRate); 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. // Create the timer that is used to timeout the connection to the PipX.
timeOut = new QTimer(this); timeOut = new QTimer(this);
connect(timeOut, SIGNAL(timeout()),this,SLOT(disconnected())); connect(timeOut, SIGNAL(timeout()),this,SLOT(disconnected()));
@ -139,28 +143,34 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
if (!settingsUpdated) if (!settingsUpdated)
pipxSettingsObj->requestUpdate(); pipxSettingsObj->requestUpdate();
// Get the current pairID
PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager());
quint32 pairID = 0;
if (pipxSettings)
pipxSettings->getPairID();
// Update the detected devices. // Update the detected devices.
UAVObjectField* pairIdField = object->getField("PairIDs"); UAVObjectField* pairIdField = object->getField("PairIDs");
if (pairIdField) { if (pairIdField) {
quint32 pairid1 = pairIdField->getValue(0).toUInt(); quint32 pairid1 = pairIdField->getValue(0).toUInt();
m_pipx->PairID1->setText(QString::number(pairid1, 16).toUpper()); m_pipx->PairID1->setText(QString::number(pairid1, 16).toUpper());
m_pipx->PairID1->setEnabled(false); m_pipx->PairID1->setEnabled(false);
m_pipx->PairSelect1->setChecked(pairID == pairid1); m_pipx->PairSelect1->setChecked(pairID && (pairID == pairid1));
m_pipx->PairSelect1->setEnabled(pairid1); m_pipx->PairSelect1->setEnabled(pairid1);
quint32 pairid2 = pairIdField->getValue(1).toUInt(); quint32 pairid2 = pairIdField->getValue(1).toUInt();
m_pipx->PairID2->setText(QString::number(pairIdField->getValue(1).toUInt(), 16).toUpper()); m_pipx->PairID2->setText(QString::number(pairIdField->getValue(1).toUInt(), 16).toUpper());
m_pipx->PairID2->setEnabled(false); m_pipx->PairID2->setEnabled(false);
m_pipx->PairSelect2->setChecked(pairID == pairid2); m_pipx->PairSelect2->setChecked(pairID && (pairID == pairid2));
m_pipx->PairSelect2->setEnabled(pairid2); m_pipx->PairSelect2->setEnabled(pairid2);
quint32 pairid3 = pairIdField->getValue(2).toUInt(); quint32 pairid3 = pairIdField->getValue(2).toUInt();
m_pipx->PairID3->setText(QString::number(pairIdField->getValue(2).toUInt(), 16).toUpper()); m_pipx->PairID3->setText(QString::number(pairIdField->getValue(2).toUInt(), 16).toUpper());
m_pipx->PairID3->setEnabled(false); m_pipx->PairID3->setEnabled(false);
m_pipx->PairSelect3->setChecked(pairID == pairid3); m_pipx->PairSelect3->setChecked(pairID && (pairID == pairid3));
m_pipx->PairSelect3->setEnabled(pairid3); m_pipx->PairSelect3->setEnabled(pairid3);
quint32 pairid4 = pairIdField->getValue(3).toUInt(); quint32 pairid4 = pairIdField->getValue(3).toUInt();
m_pipx->PairID4->setText(QString::number(pairIdField->getValue(3).toUInt(), 16).toUpper()); m_pipx->PairID4->setText(QString::number(pairIdField->getValue(3).toUInt(), 16).toUpper());
m_pipx->PairID4->setEnabled(false); m_pipx->PairID4->setEnabled(false);
m_pipx->PairSelect4->setChecked(pairID == pairid4); m_pipx->PairSelect4->setChecked(pairID && (pairID == pairid4));
m_pipx->PairSelect4->setEnabled(pairid4); m_pipx->PairSelect4->setEnabled(pairid4);
} else { } else {
qDebug() << "PipXtremeGadgetWidget: Count not read PairID field."; qDebug() << "PipXtremeGadgetWidget: Count not read PairID field.";
@ -240,11 +250,6 @@ void ConfigPipXtremeWidget::updateSettings(UAVObject *object)
{ {
settingsUpdated = true; settingsUpdated = true;
enableControls(true); enableControls(true);
// Get the settings object.
PipXSettings *pipxSettings = PipXSettings::GetInstance(getObjectManager());
PipXSettings::DataFields pipxSettingsData = pipxSettings->getData();
pairID = pipxSettingsData.PairID;
} }
void ConfigPipXtremeWidget::disconnected() void ConfigPipXtremeWidget::disconnected()
@ -253,6 +258,43 @@ void ConfigPipXtremeWidget::disconnected()
enableControls(false); 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);
}
/** /**
@} @}
@} @}

View File

@ -52,7 +52,6 @@ private:
UAVDataObject* pipxSettingsObj; UAVDataObject* pipxSettingsObj;
bool settingsUpdated; bool settingsUpdated;
quint32 pairID;
// A timer that timesout the connction to the PipX. // A timer that timesout the connction to the PipX.
QTimer *timeOut; QTimer *timeOut;
@ -62,6 +61,11 @@ private slots:
void applySettings(); void applySettings();
void saveSettings(); void saveSettings();
void disconnected(); 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 #endif // CONFIGTXPIDWIDGET_H