From ac7cfcc358c3128cff0fdfdcc6a0cd05f2fed8e0 Mon Sep 17 00:00:00 2001 From: pip Date: Tue, 15 Feb 2011 12:57:46 +0000 Subject: [PATCH] Added "Ready-To-Send-Time" parameter adjustment git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2795 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PipXtreme/api_config.c | 9 +- flight/PipXtreme/inc/main.h | 2 +- flight/PipXtreme/inc/saved_settings.h | 4 +- flight/PipXtreme/main.c | 33 +++++-- flight/PipXtreme/packet_handler.c | 7 +- flight/PipXtreme/ppm.c | 5 +- flight/PipXtreme/saved_settings.c | 2 + flight/PipXtreme/scan_spectrum.c | 5 +- flight/PipXtreme/stream.c | 5 +- .../src/plugins/pipxtreme/pipxtreme.pro | 2 +- .../src/plugins/pipxtreme/pipxtreme.ui | 17 ++++ .../pipxtreme/pipxtremegadgetfactory.cpp | 1 - .../pipxtreme/pipxtremegadgetwidget.cpp | 17 ++-- .../plugins/pipxtreme/pipxtremegadgetwidget.h | 2 + .../src/plugins/pipxtreme/pipxtremeplugin.cpp | 10 +- .../src/plugins/pipxtreme/pipxtremeplugin.h | 93 ++++++++++--------- 16 files changed, 131 insertions(+), 83 deletions(-) diff --git a/flight/PipXtreme/api_config.c b/flight/PipXtreme/api_config.c index de5f4f13e..91936a6a7 100644 --- a/flight/PipXtreme/api_config.c +++ b/flight/PipXtreme/api_config.c @@ -95,6 +95,8 @@ typedef struct uint8_t rf_xtal_cap; bool aes_enable; uint8_t aes_key[16]; + uint8_t rts_time; + uint8_t spare[16]; } __attribute__((__packed__)) t_pipx_config_settings; typedef struct @@ -220,6 +222,8 @@ int apiconfig_sendSettingsPacket(void) settings->serial_baudrate = saved_settings.serial_baudrate; settings->aes_enable = saved_settings.aes_enable; memcpy((char *)settings->aes_key, (char *)saved_settings.aes_key, sizeof(settings->aes_key)); + settings->rts_time = saved_settings.rts_time; + memset(settings->spare, 0xff, sizeof(settings->spare)); header->data_crc = updateCRC32Data(0xffffffff, settings, header->data_size); header->header_crc = 0; @@ -296,10 +300,9 @@ void apiconfig_processInputPacket(void *buf, uint16_t len) saved_settings.max_rf_bandwidth = settings->max_rf_bandwidth; saved_settings.rf_xtal_cap = settings->rf_xtal_cap; saved_settings.serial_baudrate = settings->serial_baudrate; - saved_settings.aes_enable = settings->aes_enable; -// if (saved_settings.aes_enable) - memcpy((char *)saved_settings.aes_key, (char *)settings->aes_key, sizeof(saved_settings.aes_key)); + memcpy((char *)saved_settings.aes_key, (char *)settings->aes_key, sizeof(saved_settings.aes_key)); + saved_settings.rts_time = settings->rts_time; saved_settings_save(); // save the new settings diff --git a/flight/PipXtreme/inc/main.h b/flight/PipXtreme/inc/main.h index 0cd7d18c0..f72ce50b6 100644 --- a/flight/PipXtreme/inc/main.h +++ b/flight/PipXtreme/inc/main.h @@ -33,7 +33,7 @@ // firmware version #define VERSION_MAJOR 0 // 0 to 255 -#define VERSION_MINOR 4 // 0 to 255 +#define VERSION_MINOR 5 // 0 to 255 // macro's for reading internal flash memory #define mem8(addr) (*((volatile uint8_t *)(addr))) diff --git a/flight/PipXtreme/inc/saved_settings.h b/flight/PipXtreme/inc/saved_settings.h index 14534ca77..d174281fc 100644 --- a/flight/PipXtreme/inc/saved_settings.h +++ b/flight/PipXtreme/inc/saved_settings.h @@ -56,7 +56,9 @@ typedef struct uint8_t mode; - uint8_t spare[31]; // allow for future unknown settings + uint8_t rts_time; + + uint8_t spare[30]; // allow for future unknown settings uint32_t crc; } __attribute__((__packed__)) t_saved_settings; diff --git a/flight/PipXtreme/main.c b/flight/PipXtreme/main.c index c2a5a232a..5ee1532f1 100644 --- a/flight/PipXtreme/main.c +++ b/flight/PipXtreme/main.c @@ -669,6 +669,15 @@ int main() saved_settings_init(); + if (saved_settings.mode == 0xff || + saved_settings.mode == MODE_TX_BLANK_CARRIER_TEST || + saved_settings.mode == MODE_TX_SPECTRUM_TEST || + saved_settings.mode == MODE_SCAN_SPECTRUM) + saved_settings.mode = MODE_NORMAL; + + if (saved_settings.rts_time == 0xff || saved_settings.rts_time > 100) + saved_settings.rts_time = 10; + #if !defined(PIOS_COM_DEBUG) if (saved_settings.serial_baudrate != 0xffffffff) PIOS_COM_ChangeBaud(PIOS_COM_SERIAL, saved_settings.serial_baudrate); @@ -689,12 +698,6 @@ int main() else if ( GPIO_IN(_868MHz_PIN) && !GPIO_IN(_915MHz_PIN)) saved_settings.frequency_band = FREQBAND_915MHz; // 915MHz band - if (saved_settings.mode == 0xff || - saved_settings.mode == MODE_TX_BLANK_CARRIER_TEST || - saved_settings.mode == MODE_TX_SPECTRUM_TEST || - saved_settings.mode == MODE_SCAN_SPECTRUM) - saved_settings.mode = MODE_NORMAL; - // set some defaults if they are not set switch (saved_settings.frequency_band) { @@ -811,10 +814,6 @@ int main() break; } -// if (serial_number_crc32 == 0x176C1EC6) saved_settings.destination_id = 0xA524A3B0; // modem 1, open a connection to modem 2 -// else -// if (serial_number_crc32 == 0xA524A3B0) saved_settings.destination_id = 0x176C1EC6; // modem 2, open a connection to modem 1 - // ************* processReset(); // Determine what caused the reset/reboot @@ -866,6 +865,20 @@ int main() DEBUG_PRINTF("RF datarate: %dbps\r\n", ph_getDatarate()); DEBUG_PRINTF("RF frequency: %dHz\r\n", rfm22_getNominalCarrierFrequency()); DEBUG_PRINTF("RF TX power: %d\r\n", ph_getTxPower()); + + DEBUG_PRINTF("\r\nUnit mode: "); + switch (saved_settings.mode) + { + case MODE_NORMAL: DEBUG_PRINTF("NORMAL\r\n"); break; + case MODE_STREAM_TX: DEBUG_PRINTF("STREAM-TX\r\n"); break; + case MODE_STREAM_RX: DEBUG_PRINTF("STREAM-RX\r\n"); break; + case MODE_PPM_TX: DEBUG_PRINTF("PPM-TX\r\n"); break; + case MODE_PPM_RX: DEBUG_PRINTF("PPM-RX\r\n"); break; + case MODE_SCAN_SPECTRUM: DEBUG_PRINTF("SCAN-SPECTRUM\r\n"); break; + case MODE_TX_BLANK_CARRIER_TEST: DEBUG_PRINTF("TX-BLANK-CARRIER\r\n"); break; + case MODE_TX_SPECTRUM_TEST: DEBUG_PRINTF("TX_SPECTRUM\r\n"); break; + default: DEBUG_PRINTF("UNKNOWN [%u]\r\n", saved_settings.mode); break; + } #endif // start a remote connection going diff --git a/flight/PipXtreme/packet_handler.c b/flight/PipXtreme/packet_handler.c index 7e95d042f..6658073ef 100644 --- a/flight/PipXtreme/packet_handler.c +++ b/flight/PipXtreme/packet_handler.c @@ -1,5 +1,4 @@ -/** - ****************************************************************************** +/****************************************************************************** * * @file packet_handler.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. @@ -1348,12 +1347,12 @@ void ph_processLinks(int connection_index) uint16_t size = fifoBuf_getUsed(&conn->tx_fifo_buffer); if (size == 0) - conn->ready_to_send_timer = -1; // no data to send + conn->ready_to_send_timer = -1; // no data to send else if (conn->ready_to_send_timer < 0) conn->ready_to_send_timer = 0; // start timer - if (size >= 200 || (conn->ready_to_send_timer >= 10 && size > 0) || (conn->tx_sequence_data_size > 0 && size > 0)) + if (size >= 200 || (conn->ready_to_send_timer >= saved_settings.rts_time && size > 0) || (conn->tx_sequence_data_size > 0 && size > 0)) { // send data uint8_t pack_type = PACKET_TYPE_DATA; diff --git a/flight/PipXtreme/ppm.c b/flight/PipXtreme/ppm.c index ab49bfa52..fbee8e258 100644 --- a/flight/PipXtreme/ppm.c +++ b/flight/PipXtreme/ppm.c @@ -31,7 +31,7 @@ #include "ppm.h" #if defined(PIOS_COM_DEBUG) -// #define PPM_DEBUG + #define PPM_DEBUG #endif // ************************************************************* @@ -67,6 +67,9 @@ void ppm_process(void) void ppm_init(void) { + #if defined(PPM_DEBUG) + DEBUG_PRINTF("\r\nPPM init\r\n"); + #endif } diff --git a/flight/PipXtreme/saved_settings.c b/flight/PipXtreme/saved_settings.c index 975aa557c..badef5673 100644 --- a/flight/PipXtreme/saved_settings.c +++ b/flight/PipXtreme/saved_settings.c @@ -308,6 +308,8 @@ void saved_settings_init(void) saved_settings.serial_baudrate = 57600; + saved_settings.rts_time = 10; // ms + // saved_settings.crc = 0; // saved_settings.crc = updateCRC32Data(0xffffffff, (void *)&saved_settings, sizeof(t_saved_settings)); diff --git a/flight/PipXtreme/scan_spectrum.c b/flight/PipXtreme/scan_spectrum.c index 994f718fc..dfc2fcecd 100644 --- a/flight/PipXtreme/scan_spectrum.c +++ b/flight/PipXtreme/scan_spectrum.c @@ -31,7 +31,7 @@ #include "scan_spectrum.h" #if defined(PIOS_COM_DEBUG) -// #define SS_DEBUG + #define SS_DEBUG #endif // ************************************************************* @@ -59,6 +59,9 @@ void ss_process(void) void ss_init(void) { + #if defined(SS_DEBUG) + DEBUG_PRINTF("\r\nSS init\r\n"); + #endif } diff --git a/flight/PipXtreme/stream.c b/flight/PipXtreme/stream.c index ff72a3a2f..f354cdc61 100644 --- a/flight/PipXtreme/stream.c +++ b/flight/PipXtreme/stream.c @@ -34,7 +34,7 @@ #include "stream.h" #if defined(PIOS_COM_DEBUG) -// #define STREAM_DEBUG + #define STREAM_DEBUG #endif // ************************************************************* @@ -70,6 +70,9 @@ void stream_process(void) void stream_init(void) { + #if defined(STREAM_DEBUG) + DEBUG_PRINTF("\r\nSTREAM init\r\n"); + #endif } diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.pro b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.pro index 4ddbd9986..5d03fd233 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.pro +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.pro @@ -26,7 +26,7 @@ SOURCES += pipxtremegadget.cpp \ pipxtremegadgetwidget.cpp \ pipxtremeplugin.cpp \ -OTHER_FILES += PipXtreme.pluginspec +OTHER_FILES += pipxtreme.pluginspec FORMS += \ pipxtreme.ui \ diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.ui b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.ui index aea4627f4..fe0f84095 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtreme.ui @@ -798,6 +798,23 @@ + + + + RTS time (ms) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 100 + + + diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetfactory.cpp b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetfactory.cpp index a0ed6bf93..42ce2ec91 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetfactory.cpp @@ -54,4 +54,3 @@ IOptionsPage * PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration { return new PipXtremeGadgetOptionsPage(qobject_cast(config)); } - diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.cpp index 1683a7399..fe5b632b9 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.cpp @@ -536,12 +536,10 @@ void PipXtremeGadgetWidget::saveToFlash() } settings.max_rf_bandwidth = m_widget->comboBox_MaxRFBandwidth->itemData(m_widget->comboBox_MaxRFBandwidth->currentIndex()).toInt(); - settings.max_tx_power = m_widget->comboBox_MaxRFTxPower->itemData(m_widget->comboBox_MaxRFTxPower->currentIndex()).toInt(); - settings.serial_baudrate = m_widget->comboBox_SerialPortSpeed->itemData(m_widget->comboBox_SerialPortSpeed->currentIndex()).toInt(); - settings.aes_enable = m_widget->checkBox_AESEnable->isChecked(); + settings.rts_time = m_widget->spinBox_RTSTime->value(); memset(settings.aes_key, 0, sizeof(settings.aes_key)); s = m_widget->lineEdit_AESKey->text().trimmed(); @@ -872,11 +870,11 @@ void PipXtremeGadgetWidget::processRxPacket(quint8 *packet, int packet_size) memcpy(&pipx_config_details, data, sizeof(t_pipx_config_details)); - if (pipx_config_details.major_version < 0 || (pipx_config_details.major_version <= 0 && pipx_config_details.minor_version < 3)) + if (pipx_config_details.major_version < 0 || (pipx_config_details.major_version <= 0 && pipx_config_details.minor_version < 5)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Critical); - msgBox.setText("You need to update your modem firmware to V0.3 or later"); + msgBox.setText("You need to update your PipX modem firmware to V0.5 or later"); msgBox.exec(); disconnectPort(true); return; @@ -928,17 +926,13 @@ void PipXtremeGadgetWidget::processRxPacket(quint8 *packet, int packet_size) memcpy(&pipx_config_settings, data, sizeof(t_pipx_config_settings)); m_widget->comboBox_Mode->setCurrentIndex(m_widget->comboBox_Mode->findData(pipx_config_settings.mode)); - m_widget->lineEdit_PairedSerialNumber->setText(QString::number(pipx_config_settings.destination_id, 16).toUpper()); m_widget->spinBox_FrequencyCalibration->setValue(pipx_config_settings.rf_xtal_cap); - m_widget->doubleSpinBox_Frequency->setValue((double)pipx_config_settings.frequency_Hz / 1e6); - m_widget->comboBox_MaxRFBandwidth->setCurrentIndex(m_widget->comboBox_MaxRFBandwidth->findData(pipx_config_settings.max_rf_bandwidth)); - m_widget->comboBox_MaxRFTxPower->setCurrentIndex(m_widget->comboBox_MaxRFTxPower->findData(pipx_config_settings.max_tx_power)); - m_widget->comboBox_SerialPortSpeed->setCurrentIndex(m_widget->comboBox_SerialPortSpeed->findData(pipx_config_settings.serial_baudrate)); + m_widget->spinBox_RTSTime->setValue(pipx_config_settings.rts_time); QString key = ""; for (int i = 0; i < (int)sizeof(pipx_config_settings.aes_key); i++) @@ -1305,6 +1299,7 @@ void PipXtremeGadgetWidget::importSettings() pipx_config_settings.aes_enable = settings.value("settings/aes_enable", false).toBool(); for (int i = 0; i < (int)sizeof(pipx_config_settings.aes_key); i++) pipx_config_settings.aes_key[i] = settings.value("settings/aes_key_" + QString::number(i), 0).toUInt(); + pipx_config_settings.rts_time = settings.value("settings/ready_to_send_time", 10).toUInt(); m_widget->comboBox_Mode->setCurrentIndex(m_widget->comboBox_Mode->findData(pipx_config_settings.mode)); m_widget->lineEdit_PairedSerialNumber->setText(QString::number(pipx_config_settings.destination_id, 16).toUpper()); @@ -1313,6 +1308,7 @@ void PipXtremeGadgetWidget::importSettings() m_widget->comboBox_MaxRFBandwidth->setCurrentIndex(m_widget->comboBox_MaxRFBandwidth->findData(pipx_config_settings.max_rf_bandwidth)); m_widget->comboBox_MaxRFTxPower->setCurrentIndex(m_widget->comboBox_MaxRFTxPower->findData(pipx_config_settings.max_tx_power)); m_widget->comboBox_SerialPortSpeed->setCurrentIndex(m_widget->comboBox_SerialPortSpeed->findData(pipx_config_settings.serial_baudrate)); + m_widget->spinBox_RTSTime->setValue(pipx_config_settings.rts_time); QString key = ""; for (int i = 0; i < (int)sizeof(pipx_config_settings.aes_key); i++) @@ -1367,6 +1363,7 @@ void PipXtremeGadgetWidget::exportSettings() settings.setValue("settings/max_tx_power", pipx_config_settings.max_tx_power); settings.setValue("settings/serial_baudrate", pipx_config_settings.serial_baudrate); settings.setValue("settings/aes_enable", pipx_config_settings.aes_enable); + settings.setValue("settings/ready_to_send_time", pipx_config_settings.rts_time); for (int i = 0; i < (int)sizeof(pipx_config_settings.aes_key); i++) settings.setValue("settings/aes_key_" + QString::number(i), pipx_config_settings.aes_key[i]); } diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.h b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.h index eedaabe6f..584217eab 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremegadgetwidget.h @@ -98,6 +98,8 @@ typedef struct uint8_t rf_xtal_cap; bool aes_enable; uint8_t aes_key[16]; + uint8_t rts_time; + uint8_t spare[16]; } t_pipx_config_settings; typedef struct diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.cpp b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.cpp index 4b711a7ad..3f8422a7e 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.cpp +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.cpp @@ -23,6 +23,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "pipxtremeplugin.h" #include "pipxtremegadgetfactory.h" #include @@ -31,29 +32,30 @@ PipXtremePlugin::PipXtremePlugin() { + mf = NULL; } PipXtremePlugin::~PipXtremePlugin() { } -bool PipXtremePlugin::initialize(const QStringList& args, QString *errMsg) +bool PipXtremePlugin::initialize(const QStringList &args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); + mf = new PipXtremeGadgetFactory(this); addAutoReleasedObject(mf); + return true; } void PipXtremePlugin::extensionsInitialized() { - // Do nothing } void PipXtremePlugin::shutdown() { - // Do nothing } -Q_EXPORT_PLUGIN(PipXtremePlugin) +Q_EXPORT_PLUGIN(PipXtremePlugin) diff --git a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.h b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.h index b3e783287..f81ef1933 100644 --- a/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.h +++ b/ground/openpilotgcs/src/plugins/pipxtreme/pipxtremeplugin.h @@ -1,45 +1,48 @@ -/** - ****************************************************************************** - * - * @file pipxtremeplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @{ - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PIPXTREMEPLUGIN_H -#define PIPXTREMEPLUGIN_H - -#include - -class PipXtremeGadgetFactory; - -class PipXtremePlugin : public ExtensionSystem::IPlugin -{ -public: - PipXtremePlugin(); - ~PipXtremePlugin(); - - void extensionsInitialized(); - bool initialize(const QStringList & arguments, QString * errorString); - void shutdown(); -private: - PipXtremeGadgetFactory *mf; -}; -#endif +/** + ****************************************************************************** + * + * @file pipxtremeplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @{ + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PIPXTREMEPLUGIN_H +#define PIPXTREMEPLUGIN_H + +#include + +class PipXtremeGadgetFactory; + +class PipXtremePlugin : public ExtensionSystem::IPlugin +{ +public: + PipXtremePlugin(); + ~PipXtremePlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString * errorString); + void shutdown(); + +private: + PipXtremeGadgetFactory *mf; + +}; + +#endif