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

Added "Ready-To-Send-Time" parameter adjustment

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2795 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-15 12:57:46 +00:00 committed by pip
parent 0abec1908d
commit ac7cfcc358
16 changed files with 131 additions and 83 deletions

View File

@ -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));
saved_settings.rts_time = settings->rts_time;
saved_settings_save(); // save the new settings

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
/**
******************************************************************************
/******************************************************************************
*
* @file packet_handler.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
@ -1353,7 +1352,7 @@ void ph_processLinks(int connection_index)
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;

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ SOURCES += pipxtremegadget.cpp \
pipxtremegadgetwidget.cpp \
pipxtremeplugin.cpp \
OTHER_FILES += PipXtreme.pluginspec
OTHER_FILES += pipxtreme.pluginspec
FORMS += \
pipxtreme.ui \

View File

@ -798,6 +798,23 @@
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QLabel" name="label_16">
<property name="text">
<string>RTS time (ms)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QSpinBox" name="spinBox_RTSTime">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -54,4 +54,3 @@ IOptionsPage * PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration
{
return new PipXtremeGadgetOptionsPage(qobject_cast<PipXtremeGadgetConfiguration *>(config));
}

View File

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

View File

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

View File

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

View File

@ -39,7 +39,10 @@ public:
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
PipXtremeGadgetFactory *mf;
};
#endif