1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +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_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)

View File

@ -33,20 +33,20 @@
#include <pipxsettings.h>
#include <board_hw_defs.c>
#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);

View File

@ -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);
}
/**
@}
@}

View File

@ -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