mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
PipX plugin now connects/disconnects from communications port. Have yet to write the comms stream routine/thread and packet protocol.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2627 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1ae14c5682
commit
89df836c23
@ -17,7 +17,6 @@ HEADERS += pipxtremegadget.h \
|
|||||||
pipxtremegadgetwidget.h \
|
pipxtremegadgetwidget.h \
|
||||||
pipxtremeplugin.h \
|
pipxtremeplugin.h \
|
||||||
delay.h \
|
delay.h \
|
||||||
devicewidget.h \
|
|
||||||
SSP/port.h \
|
SSP/port.h \
|
||||||
SSP/qssp.h \
|
SSP/qssp.h \
|
||||||
SSP/qsspt.h \
|
SSP/qsspt.h \
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>570</width>
|
<width>570</width>
|
||||||
<height>381</height>
|
<height>407</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -15,8 +15,67 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item>
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="text">
|
||||||
|
<string>Serial Baudrate</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QComboBox" name="comboBox_SerialBaudrate">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QComboBox" name="comboBox_Ports">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the PC port the modem is connected too</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="connectButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Connect to the modem (when normal telemetry is not used)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string> Connect </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QToolButton" name="refreshPorts">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Refresh the list of serial and USB ports available</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -29,70 +88,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="connectButton">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="enabled">
|
<property name="orientation">
|
||||||
<bool>true</bool>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="mouseTracking">
|
<property name="sizeHint" stdset="0">
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Tells the mainboard to go down
|
|
||||||
to bootloader mode.
|
|
||||||
(Only enabled if telemetry link is established, either
|
|
||||||
through serial or USB)</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string> Connect </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_Ports">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>40</width>
|
||||||
<height>0</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
</spacer>
|
||||||
<string>When telemetry is not connected, select the communication
|
|
||||||
method using this combo box.
|
|
||||||
|
|
||||||
You can use this to force a communication channel when doing
|
|
||||||
a "Boot" (button on the left). It is updated automatically when
|
|
||||||
halting a running board.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="refreshPorts">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Refresh the list of serial ports</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
</widget>
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>8</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@ -175,6 +191,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Serial number of the remote modem you want to pair with</string>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
@ -431,6 +450,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the modems serial port speed</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="3">
|
<item row="5" column="3">
|
||||||
@ -441,6 +463,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the maximum TX output power the modem will use</string>
|
||||||
|
</property>
|
||||||
<property name="layoutDirection">
|
<property name="layoutDirection">
|
||||||
<enum>Qt::LeftToRight</enum>
|
<enum>Qt::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -457,6 +482,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the maximum RF datarate/channel bandwidth the modem will use</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
@ -473,6 +501,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the modems RF carrier frequency</string>
|
||||||
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
@ -507,6 +538,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Calibrate the modems RF carrier frequency</string>
|
||||||
|
</property>
|
||||||
<property name="accelerated">
|
<property name="accelerated">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -583,6 +617,9 @@ halting a running board.</string>
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set the modems operating mode</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -602,7 +639,7 @@ halting a running board.</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_AESKey">
|
<widget class="QLineEdit" name="lineEdit_AESKey">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The AES encryption key</string>
|
<string>The AES encryption key - has to be the same key on the remote modem as well)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
@ -633,6 +670,9 @@ halting a running board.</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_AESEnable">
|
<widget class="QCheckBox" name="checkBox_AESEnable">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enable/Disable AES encryption</string>
|
||||||
|
</property>
|
||||||
<property name="layoutDirection">
|
<property name="layoutDirection">
|
||||||
<enum>Qt::RightToLeft</enum>
|
<enum>Qt::RightToLeft</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -644,27 +684,18 @@ halting a running board.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_3">
|
<widget class="Line" name="line_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
</widget>
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>8</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_ScanSpectrum">
|
<widget class="QPushButton" name="pushButton_ScanSpectrum">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Scan whole band</string>
|
<string>Scan whole band to see where their is interference and/or used channels</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string> Scan Spectrum </string>
|
<string> Scan Spectrum </string>
|
||||||
|
@ -47,18 +47,33 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
m_config->comboBox_Mode->addItem("Tx Carrier Calibrate", 2);
|
m_config->comboBox_Mode->addItem("Tx Carrier Calibrate", 2);
|
||||||
m_config->comboBox_Mode->addItem("Tx Spectrum Test", 3);
|
m_config->comboBox_Mode->addItem("Tx Spectrum Test", 3);
|
||||||
|
|
||||||
|
m_config->comboBox_SerialBaudrate->clear();
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("1200", 1200);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("2400", 2400);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("4800", 4800);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("9600", 9600);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("19200", 19200);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("38400", 38400);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("57600", 57600);
|
||||||
|
m_config->comboBox_SerialBaudrate->addItem("115200", 115200);
|
||||||
|
// m_config->comboBox_SerialBaudrate->addItem("230400", 230400);
|
||||||
|
// m_config->comboBox_SerialBaudrate->addItem("460800", 460800);
|
||||||
|
// m_config->comboBox_SerialBaudrate->addItem("921600", 921600);
|
||||||
|
m_config->comboBox_SerialBaudrate->setCurrentIndex(m_config->comboBox_SerialBaudrate->findText("57600"));
|
||||||
|
|
||||||
m_config->comboBox_SerialPortSpeed->clear();
|
m_config->comboBox_SerialPortSpeed->clear();
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("1200", 1200);
|
m_config->comboBox_SerialPortSpeed->addItem("1200", 1200);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("2400", 2400);
|
m_config->comboBox_SerialPortSpeed->addItem("2400", 2400);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("4800", 4800);
|
m_config->comboBox_SerialPortSpeed->addItem("4800", 4800);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("9600", 9600);
|
m_config->comboBox_SerialPortSpeed->addItem("9600", 9600);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("19200", 19200);
|
m_config->comboBox_SerialPortSpeed->addItem("19200", 19200);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("38400", 38400);
|
m_config->comboBox_SerialPortSpeed->addItem("38400", 38400);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("57600", 57600);
|
m_config->comboBox_SerialPortSpeed->addItem("57600", 57600);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("115200", 115200);
|
m_config->comboBox_SerialPortSpeed->addItem("115200", 115200);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("230400", 230400);
|
// m_config->comboBox_SerialPortSpeed->addItem("230400", 230400);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("460800", 460800);
|
// m_config->comboBox_SerialPortSpeed->addItem("460800", 460800);
|
||||||
m_config->comboBox_SerialPortSpeed->addItem("921600", 921600);
|
// m_config->comboBox_SerialPortSpeed->addItem("921600", 921600);
|
||||||
|
m_config->comboBox_SerialPortSpeed->setCurrentIndex(m_config->comboBox_SerialPortSpeed->findText("57600"));
|
||||||
|
|
||||||
m_config->doubleSpinBox_Frequency->setSingleStep(0.00015625);
|
m_config->doubleSpinBox_Frequency->setSingleStep(0.00015625);
|
||||||
|
|
||||||
@ -93,7 +108,7 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
// int opened = rawHidHandle.open(10, 0x20A0, 0x4117, 0xFF9C, 0x0001);
|
// int opened = rawHidHandle.open(10, 0x20A0, 0x4117, 0xFF9C, 0x0001);
|
||||||
// rawHidPlugin = new RawHIDPlugin();
|
// rawHidPlugin = new RawHIDPlugin();
|
||||||
|
|
||||||
connect(m_config->connectButton, SIGNAL(clicked()), this, SLOT(goToAPIMode()));
|
connect(m_config->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect()));
|
||||||
|
|
||||||
getPorts();
|
getPorts();
|
||||||
|
|
||||||
@ -109,9 +124,10 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
// delay::msleep(600); // just for pips reference
|
// delay::msleep(600); // just for pips reference
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
// destructor .. this never gets called :(
|
||||||
PipXtremeGadgetWidget::~PipXtremeGadgetWidget()
|
PipXtremeGadgetWidget::~PipXtremeGadgetWidget()
|
||||||
{
|
{
|
||||||
|
disconnect(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *event)
|
void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||||
@ -158,7 +174,10 @@ void PipXtremeGadgetWidget::getPorts()
|
|||||||
foreach (QextPortInfo port, ports)
|
foreach (QextPortInfo port, ports)
|
||||||
list.append(port.friendName);
|
list.append(port.friendName);
|
||||||
|
|
||||||
m_config->comboBox_Ports->addItems(list);
|
for (int i = 0; i < list.count(); i++)
|
||||||
|
m_config->comboBox_Ports->addItem(list.at(i), 0);
|
||||||
|
|
||||||
|
// m_config->comboBox_Ports->addItems(list);
|
||||||
|
|
||||||
// ********************************
|
// ********************************
|
||||||
// Populate the telemetry combo box with usb ports
|
// Populate the telemetry combo box with usb ports
|
||||||
@ -174,7 +193,10 @@ void PipXtremeGadgetWidget::getPorts()
|
|||||||
for (int i = 0; i < opened; i++)
|
for (int i = 0; i < opened; i++)
|
||||||
usb_ports.append(rawHidHandle->getserial(i));
|
usb_ports.append(rawHidHandle->getserial(i));
|
||||||
|
|
||||||
m_config->comboBox_Ports->addItems(usb_ports);
|
for (int i = 0; i < usb_ports.count(); i++)
|
||||||
|
m_config->comboBox_Ports->addItem(usb_ports.at(i), 1);
|
||||||
|
|
||||||
|
// m_config->comboBox_Ports->addItems(usb_ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete rawHidHandle;
|
delete rawHidHandle;
|
||||||
@ -204,6 +226,8 @@ QString PipXtremeGadgetWidget::getPortDevice(const QString &friendName)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::onTelemetryStart()
|
void PipXtremeGadgetWidget::onTelemetryStart()
|
||||||
{
|
{
|
||||||
m_config->connectButton->setEnabled(false);
|
m_config->connectButton->setEnabled(false);
|
||||||
@ -216,6 +240,8 @@ void PipXtremeGadgetWidget::onTelemetryStop()
|
|||||||
m_config->comboBox_Ports->setEnabled(true);
|
m_config->comboBox_Ports->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::onTelemetryConnect()
|
void PipXtremeGadgetWidget::onTelemetryConnect()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -224,6 +250,8 @@ void PipXtremeGadgetWidget::onTelemetryDisconnect()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::onModemConnect()
|
void PipXtremeGadgetWidget::onModemConnect()
|
||||||
{
|
{
|
||||||
m_config->connectButton->setText(tr(" Disconnect "));
|
m_config->connectButton->setText(tr(" Disconnect "));
|
||||||
@ -238,21 +266,37 @@ void PipXtremeGadgetWidget::onModemDisconnect()
|
|||||||
m_config->pushButton_ScanSpectrum->setEnabled(false);
|
m_config->pushButton_ScanSpectrum->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::suspendTelemetry()
|
void PipXtremeGadgetWidget::suspendTelemetry()
|
||||||
{
|
{
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
if (!cm) return;
|
if (!cm) return;
|
||||||
|
|
||||||
// Suspend telemety & polling
|
// Suspend telemety & polling
|
||||||
cm->disconnectDevice();
|
cm->disconnectDevice();
|
||||||
cm->suspendPolling();
|
cm->suspendPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PipXtremeGadgetWidget::restartTelemetryPolling()
|
||||||
|
{
|
||||||
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
|
if (!cm) return;
|
||||||
|
|
||||||
|
// Restart the polling thread
|
||||||
|
cm->resumePolling();
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::processOutputStream()
|
void PipXtremeGadgetWidget::processOutputStream()
|
||||||
{
|
{
|
||||||
if (!m_ioDevice)
|
if (!m_ioDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!m_ioDevice->isOpen())
|
||||||
|
return;
|
||||||
|
|
||||||
// if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE )
|
// if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE )
|
||||||
{
|
{
|
||||||
// m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
|
// m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
|
||||||
@ -270,15 +314,139 @@ void PipXtremeGadgetWidget::processInputStream()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipXtremeGadgetWidget::restartTelemetryPolling()
|
// *************************************************************************
|
||||||
{
|
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
|
||||||
if (!cm) return;
|
|
||||||
|
|
||||||
// Restart the polling thread
|
void PipXtremeGadgetWidget::disconnect(bool resume_polling)
|
||||||
cm->resumePolling();
|
{ // disconnect the comms port
|
||||||
|
|
||||||
|
if (!m_ioDevice)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ioDevice->close();
|
||||||
|
|
||||||
|
delete m_ioDevice;
|
||||||
|
m_ioDevice = NULL;
|
||||||
|
|
||||||
|
m_config->connectButton->setText("Connect");
|
||||||
|
m_config->comboBox_SerialBaudrate->setEnabled(true);
|
||||||
|
m_config->comboBox_Ports->setEnabled(true);
|
||||||
|
m_config->refreshPorts->setEnabled(true);
|
||||||
|
|
||||||
|
restartTelemetryPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PipXtremeGadgetWidget::connectDisconnect()
|
||||||
|
{
|
||||||
|
if (m_ioDevice)
|
||||||
|
{ // disconnect
|
||||||
|
disconnect(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****************
|
||||||
|
// connect
|
||||||
|
|
||||||
|
int device_idx = m_config->comboBox_Ports->currentIndex();
|
||||||
|
if (device_idx < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString device_str = m_config->comboBox_Ports->currentText().trimmed();
|
||||||
|
if (device_str.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int type = m_config->comboBox_Ports->itemData(device_idx).toInt();
|
||||||
|
|
||||||
|
// qDebug() << QString::number(type) << ": " << device_str;
|
||||||
|
|
||||||
|
// Suspend telemety & polling in case it is not done yet
|
||||||
|
suspendTelemetry();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0: // serial port
|
||||||
|
{
|
||||||
|
QString str = getPortDevice(device_str);
|
||||||
|
if (str.isEmpty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
int br_idx = m_config->comboBox_SerialBaudrate->currentIndex();
|
||||||
|
if (br_idx < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int baudrate = m_config->comboBox_SerialBaudrate->itemData(br_idx).toInt();
|
||||||
|
|
||||||
|
BaudRateType bdt = BAUD57600;
|
||||||
|
switch (baudrate)
|
||||||
|
{
|
||||||
|
case 1200: bdt = BAUD1200; break;
|
||||||
|
case 2400: bdt = BAUD2400; break;
|
||||||
|
case 4800: bdt = BAUD4800; break;
|
||||||
|
case 9600: bdt = BAUD9600; break;
|
||||||
|
case 19200: bdt = BAUD19200; break;
|
||||||
|
case 38400: bdt = BAUD38400; break;
|
||||||
|
case 57600: bdt = BAUD57600; break;
|
||||||
|
case 115200: bdt = BAUD115200; break;
|
||||||
|
case 128000: bdt = BAUD128000; break;
|
||||||
|
case 256000: bdt = BAUD256000; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortSettings settings;
|
||||||
|
settings.BaudRate = bdt;
|
||||||
|
settings.DataBits = DATA_8;
|
||||||
|
settings.Parity = PAR_NONE;
|
||||||
|
settings.StopBits = STOP_1;
|
||||||
|
settings.FlowControl = FLOW_OFF;
|
||||||
|
settings.Timeout_Millisec = 500;
|
||||||
|
|
||||||
|
QextSerialPort *serial_dev = new QextSerialPort(str, settings, QextSerialPort::Polling);
|
||||||
|
if (!serial_dev)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!serial_dev->open(QIODevice::ReadWrite | QIODevice::Unbuffered))
|
||||||
|
{
|
||||||
|
delete serial_dev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ioDevice = serial_dev;
|
||||||
|
|
||||||
|
m_config->connectButton->setText("Disconnect");
|
||||||
|
m_config->comboBox_SerialBaudrate->setEnabled(false);
|
||||||
|
m_config->comboBox_Ports->setEnabled(false);
|
||||||
|
m_config->refreshPorts->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: // USB port
|
||||||
|
{
|
||||||
|
RawHID *usb_dev = new RawHID(device_str);
|
||||||
|
if (!usb_dev)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!usb_dev->open(QIODevice::ReadWrite | QIODevice::Unbuffered))
|
||||||
|
{
|
||||||
|
delete usb_dev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ioDevice = usb_dev;
|
||||||
|
|
||||||
|
m_config->connectButton->setText("Disconnect");
|
||||||
|
m_config->comboBox_SerialBaudrate->setEnabled(false);
|
||||||
|
m_config->comboBox_Ports->setEnabled(false);
|
||||||
|
m_config->refreshPorts->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: // unknown
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
restartTelemetryPolling();
|
||||||
|
}
|
||||||
|
|
||||||
|
// *************************************************************************
|
||||||
|
|
||||||
// Ask the modem to go into API mode
|
// Ask the modem to go into API mode
|
||||||
void PipXtremeGadgetWidget::goToAPIMode(UAVObject* callerObj, bool success)
|
void PipXtremeGadgetWidget::goToAPIMode(UAVObject* callerObj, bool success)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +143,6 @@ private:
|
|||||||
// currently connected QIODevice
|
// currently connected QIODevice
|
||||||
QIODevice *m_ioDevice;
|
QIODevice *m_ioDevice;
|
||||||
|
|
||||||
|
|
||||||
QString getPortDevice(const QString &friendName);
|
QString getPortDevice(const QString &friendName);
|
||||||
|
|
||||||
void suspendTelemetry();
|
void suspendTelemetry();
|
||||||
@ -152,8 +151,11 @@ private:
|
|||||||
void processOutputStream();
|
void processOutputStream();
|
||||||
void processInputStream();
|
void processInputStream();
|
||||||
|
|
||||||
|
void disconnect(bool resume_polling);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void error(QString errorString,int errorNumber);
|
void connectDisconnect();
|
||||||
|
void error(QString errorString,int errorNumber);
|
||||||
void goToAPIMode(UAVObject* = NULL, bool = false);
|
void goToAPIMode(UAVObject* = NULL, bool = false);
|
||||||
void systemBoot();
|
void systemBoot();
|
||||||
void getPorts();
|
void getPorts();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user