1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-07 22:54:14 +01:00

158 lines
3.5 KiB
C
Raw Normal View History

/**
******************************************************************************
*
* @file pipxtremegadgetwidget.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 PIPXTREMEGADGETWIDGET_H
#define PIPXTREMEGADGETWIDGET_H
#include "ui_pipxtreme.h"
#include "delay.h"
#include <qextserialport.h>
#include <qextserialenumerator.h>
#include "uavtalk/telemetrymanager.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include "rawhid/rawhidplugin.h"
#include <QtGui/QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QThread>
#include <QMessageBox>
#include <QTimer>
#include <QtCore/QVector>
#include <QtCore/QIODevice>
#include <QtCore/QLinkedList>
// *************************
// pipx config comms packets
#pragma pack(push, 1)
typedef struct
{
uint32_t marker;
uint32_t serial_number;
uint8_t type;
uint8_t spare;
uint16_t data_size;
uint32_t crc;
uint8_t data[0];
} t_pipx_header;
typedef struct
{
uint8_t mode;
uint8_t state;
} t_pipx_data_mode_state;
typedef struct
{
uint32_t serial_baudrate; // serial uart baudrate
uint32_t destination_id;
uint32_t min_frequency_Hz;
uint32_t max_frequency_Hz;
uint32_t frequency_Hz;
uint32_t max_rf_bandwidth;
uint8_t max_tx_power;
uint8_t frequency_band;
uint8_t rf_xtal_cap;
bool aes_enable;
uint8_t aes_key[16];
uint16_t frequency_step_size;
} t_pipx_data_settings;
typedef struct
{
uint32_t start_frequency;
uint16_t frequency_step_size;
uint16_t magnitudes;
int8_t magnitude[0];
} t_pipx_data_spectrum;
#pragma pack(pop)
// *************************
class PipXtremeGadgetWidget : public QWidget
{
Q_OBJECT
public:
PipXtremeGadgetWidget(QWidget *parent = 0);
~PipXtremeGadgetWidget();
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1} IAPStep;
public slots:
void onTelemetryStart();
void onTelemetryStop();
void onTelemetryConnect();
void onTelemetryDisconnect();
void onComboBoxPorts_currentIndexChanged(int index);
protected:
void resizeEvent(QResizeEvent *event);
private:
Ui_PipXtremeWidget *m_widget;
QIODevice *m_ioDevice;
QString getSerialPortDevice(const QString &friendName);
void disableTelemetry();
void enableTelemetry();
void processOutputStream();
void processInputStream();
void disconnectPort(bool enable_telemetry);
void connectPort();
void processInputBytes(quint8 *buf, int count);
private slots:
void connectDisconnect();
void error(QString errorString, int errorNumber);
void getPorts();
};
#endif