1、增加调试控制相关指令
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include "LoggerWidget.h"
|
||||
#include "msg.h"
|
||||
#include "spdlog/sinks/qt_sinks.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
|
||||
#include "ui_LoggerWidget.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
LoggerWidget::LoggerWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::LoggerWidget)
|
||||
@@ -25,3 +27,88 @@ void LoggerWidget::on_btnClear_clicked()
|
||||
ui->txtLogger->clear();
|
||||
}
|
||||
|
||||
void LoggerWidget::updateRespStatus(const QString &text)
|
||||
{
|
||||
ui->cmdResp->setText(text);
|
||||
}
|
||||
|
||||
void LoggerWidget::clearRespStatus()
|
||||
{
|
||||
ui->cmdResp->clear();
|
||||
}
|
||||
|
||||
void LoggerWidget::on_btnUCarrierType_clicked()
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_UCattierType(ui->uCarrierType->currentIndex())); // 发射信号
|
||||
}
|
||||
|
||||
|
||||
void LoggerWidget::on_btnURate_clicked()
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_URate(ui->uRate->currentIndex()));
|
||||
}
|
||||
|
||||
int LoggerWidget::checkFreq(const QString& freq){
|
||||
bool result;
|
||||
if (freq.isEmpty()) {
|
||||
QMessageBox::information(this, "错误", "请输入正确信道号");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freqValue = freq.toInt(&result);
|
||||
|
||||
if(result && freqValue >= 1 && freqValue <= 1388)
|
||||
{
|
||||
return freqValue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LoggerWidget::on_btnSFreq_clicked()
|
||||
{
|
||||
uint16_t freq = 0;
|
||||
freq = checkFreq(ui->sFreq->text());
|
||||
if(freq != 0)
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_SFreq(freq));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoggerWidget::on_btnSRate_clicked()
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_SRate(ui->sRate->currentIndex()));
|
||||
}
|
||||
|
||||
|
||||
void LoggerWidget::on_btnPa_clicked()
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_PASwitch(ui->sPa->checkState(), ui->uPa->checkState(), ui->bdPa->checkState()));
|
||||
}
|
||||
|
||||
|
||||
void LoggerWidget::on_btnZTCtrl_clicked()
|
||||
{
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_ZTCtrl(ui->ztCtrlType->currentIndex()));
|
||||
}
|
||||
|
||||
void LoggerWidget::on_btnCmdSend_clicked()
|
||||
{
|
||||
if(ui->cmdContent->text().isEmpty())
|
||||
{
|
||||
QMessageBox::information(this, "错误", "请输入指令内容");
|
||||
return;
|
||||
}
|
||||
clearRespStatus();
|
||||
emit sendUdpRequest(pack_debug_cmd_CmdCtrl(ui->cmdType->currentIndex(), ui->cmdContent->text().toStdString()));
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,13 +17,35 @@ public:
|
||||
explicit LoggerWidget(QWidget *parent = nullptr);
|
||||
~LoggerWidget();
|
||||
|
||||
void updateRespStatus(const QString &text);
|
||||
void clearRespStatus();
|
||||
|
||||
signals:
|
||||
void sendUdpRequest(const QByteArray &message);
|
||||
|
||||
private slots:
|
||||
void on_btnClear_clicked();
|
||||
|
||||
void on_btnUCarrierType_clicked();
|
||||
|
||||
void on_btnURate_clicked();
|
||||
|
||||
void on_btnSFreq_clicked();
|
||||
|
||||
void on_btnSRate_clicked();
|
||||
|
||||
void on_btnPa_clicked();
|
||||
|
||||
void on_btnCmdSend_clicked();
|
||||
|
||||
void on_btnZTCtrl_clicked();
|
||||
|
||||
private:
|
||||
Ui::LoggerWidget *ui;
|
||||
|
||||
std::shared_ptr<spdlog::logger> m_logger;
|
||||
|
||||
int checkFreq(const QString& freq);
|
||||
};
|
||||
|
||||
#endif // LOGGERWIDGET_H
|
||||
|
||||
304
LoggerWidget.ui
304
LoggerWidget.ui
@@ -11,36 +11,310 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>日志</string>
|
||||
<string>调试控制</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtLogger"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtLogger"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClear">
|
||||
<property name="text">
|
||||
<string>清空</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="btnUCarrierType">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="ztCtrlType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>开始转动</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>停止转动</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QTextEdit" name="cmdResp"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string> 指令回复:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="btnSRate">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="uCarrierType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>381MHz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>388.5MHz</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>396MHz</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="btnPa">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string> 功放开关:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="btnURate">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string> U模块速率:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string> 转台控制:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>S模块信道号:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="cmdContent"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string> S模块速率:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string> 指令内容:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="btnZTCtrl">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="sRate">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9.6kbps</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="sPa">
|
||||
<property name="text">
|
||||
<string>天通</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="uPa">
|
||||
<property name="text">
|
||||
<string>U</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="bdPa">
|
||||
<property name="text">
|
||||
<string>北斗</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="cmdType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>U模块指令</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>天通模块指令</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>北斗模块指令</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QPushButton" name="btnCmdSend">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string> 指令类型:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="btnSFreq">
|
||||
<property name="text">
|
||||
<string>设 置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="uRate">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2.4kbps</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="sFreq">
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>1~1388</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string> U模块载波:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClear">
|
||||
<property name="text">
|
||||
<string>清空</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>599</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -38,6 +38,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
//创建logger窗口
|
||||
m_loggerWidget = std::make_shared<LoggerWidget>();//需要在RecordQuery创建前
|
||||
m_loggerWidget->hide();
|
||||
connect(&*m_loggerWidget, &LoggerWidget::sendUdpRequest,
|
||||
this, &MainWindow::handleUdpRequest);
|
||||
//创建记录查询窗口
|
||||
m_recordQueryWidget = std::make_shared<RecordQuery>();
|
||||
m_recordQueryWidget->hide();
|
||||
@@ -204,6 +206,12 @@ void MainWindow::onTimerTimeout1s(){
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::handleUdpRequest(const QByteArray &message)
|
||||
{
|
||||
sendUdpMessage(message); // 调用实际的发送方法
|
||||
//m_loggerWidget->updateRespStatus(message);
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent* event){
|
||||
if(event->key() == Qt::Key_L && event->modifiers() & Qt::ControlModifier){
|
||||
m_loggerWidget->show();
|
||||
@@ -804,6 +812,9 @@ void MainWindow::processCommand(QByteArray& cmd){
|
||||
case uint8_t(CommandType::kSearchSatelliteStatusReport):
|
||||
processSearchSatelliteStatusReport(cmd);
|
||||
break;
|
||||
case uint8_t(CommandType::kDebugCmd):
|
||||
processDebugCmd(cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void MainWindow::processTianTongVoiceCmd(const QByteArray& cmd){
|
||||
@@ -1152,6 +1163,31 @@ void MainWindow::processSearchSatelliteStatusReport(const QByteArray& cmd){
|
||||
// 设置方位俯仰角
|
||||
setAzimuthValues(azimuth_pitch_values);
|
||||
}
|
||||
|
||||
void MainWindow::processDebugCmd(const QByteArray& cmd){
|
||||
switch(uint8_t(cmd[SUB_COMMAND_TYPE_INDEX])){
|
||||
case uint8_t(DebugCommandType::kUCattierType):
|
||||
case uint8_t(DebugCommandType::kURate):
|
||||
case uint8_t(DebugCommandType::kSFreq):
|
||||
case uint8_t(DebugCommandType::kSRate):
|
||||
case uint8_t(DebugCommandType::kPASwitch):
|
||||
case uint8_t(DebugCommandType::kZTCtrl):
|
||||
if(cmd[COMMAND_DATA_BEGIN_INDEX] == int(VoiceAndShortMessageReponse::kSucess)){//设置成功
|
||||
//this->m_logger->info("设置成功");
|
||||
m_loggerWidget->updateRespStatus("设置成功");
|
||||
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == int(VoiceAndShortMessageReponse::kFailure)){//设置失败
|
||||
//this->m_logger->info("设置失败");
|
||||
m_loggerWidget->updateRespStatus("设置失败");
|
||||
}
|
||||
break;
|
||||
case uint8_t(DebugCommandType::kCmdCtrl):
|
||||
int data_index = COMMAND_DATA_BEGIN_INDEX;
|
||||
std::string resp = std::string((cmd.data()+data_index), (cmd.length() - 5)); //去除信息长度2/命令1/命令子类型1/校验1
|
||||
m_loggerWidget->updateRespStatus(resp.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
// 处理模块状态
|
||||
@@ -1212,6 +1248,7 @@ void MainWindow::processBeiDouModuleStatus(uint8_t status){
|
||||
m_logger->error("BeiDou: module status status illegal value, status = {}",status);
|
||||
return;
|
||||
}
|
||||
|
||||
m_beidouModuleStatus = ModuleStatus(status);
|
||||
switch(m_beidouModuleStatus){
|
||||
case ModuleStatus::kChecking:
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
void test1();
|
||||
bool sendUdpMessage(const QByteArray &udpMessage);
|
||||
private slots:
|
||||
|
||||
void on_btnCallAnswer_clicked();
|
||||
@@ -55,6 +56,8 @@ private slots:
|
||||
void handleHovered(bool status, int index, QBarSet *barset);
|
||||
|
||||
void onTimerTimeout1s();
|
||||
|
||||
void handleUdpRequest(const QByteArray &message);
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
private:
|
||||
@@ -69,7 +72,7 @@ private:
|
||||
//-------------------------------------------------
|
||||
// 与底层消息交互
|
||||
//-------------------------------------------------
|
||||
bool sendUdpMessage(const QByteArray &udpMessage);
|
||||
//bool sendUdpMessage(const QByteArray &udpMessage);
|
||||
bool sendShortMessage(const QString &number,const QString& message);
|
||||
void processCommand(QByteArray& cmd);
|
||||
void processTianTongVoiceCmd(const QByteArray& cmd);
|
||||
@@ -79,7 +82,7 @@ private:
|
||||
void processBeiDouShortMessageCmd(const QByteArray& cmd);
|
||||
void processStatusReportCmd(const QByteArray& cmd);
|
||||
void processSearchSatelliteStatusReport(const QByteArray& cmd);
|
||||
|
||||
void processDebugCmd(const QByteArray& cmd);
|
||||
// 处理模块状态
|
||||
void processUhfModuleStatus(uint8_t status);
|
||||
void processTianTongModuleStatus(uint8_t status);
|
||||
|
||||
74
msg.cpp
74
msg.cpp
@@ -106,6 +106,80 @@ QByteArray pack_uhf_answer(){
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_UCattierType(uint8_t type){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
|
||||
pack_len(cmd,2 + 1);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kUCattierType);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_URate(uint8_t type){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
|
||||
pack_len(cmd,2 + 1);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kURate);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_SFreq(uint16_t freq){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 2, '\0');
|
||||
pack_len(cmd,2 + 2);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kSFreq);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = (freq >> 8) & 0xFF;
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX + 1] = freq & 0xFF;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_SRate(uint8_t type){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
|
||||
pack_len(cmd,2 + 1);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kSRate);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_PASwitch(uint8_t s_switch, uint8_t u_switch, uint8_t bd_switch){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 3, '\0');
|
||||
pack_len(cmd,2 + 3);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kPASwitch);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = s_switch;
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX + 1] = u_switch;
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX + 2] = bd_switch;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_ZTCtrl(uint8_t type){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
|
||||
pack_len(cmd,2 + 1);
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kZTCtrl);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_debug_cmd_CmdCtrl(uint8_t type, const std::string& cmd_content){
|
||||
QByteArray cmd(FRAME_MIN_LEN + 1 + cmd_content.size(), '\0');
|
||||
pack_len(cmd,2 + 1 + cmd_content.size());
|
||||
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kDebugCmd);
|
||||
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(DebugCommandType::kCmdCtrl);
|
||||
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
|
||||
memcpy(&cmd[COMMAND_DATA_BEGIN_INDEX + 1],cmd_content.c_str(),cmd_content.size());
|
||||
calc_checksum(cmd);
|
||||
return pack_slip(cmd);
|
||||
}
|
||||
|
||||
QByteArray pack_short_message_cmd(CommandType cmd_type,const std::string& number, const std::u16string& message){
|
||||
assert(number.size() <= 20);
|
||||
QByteArray cmd(FRAME_MIN_LEN+20+message.size()*sizeof(char16_t), '\0');
|
||||
|
||||
23
msg.h
23
msg.h
@@ -15,7 +15,7 @@
|
||||
#define FRAME_MIN_LEN 5
|
||||
#define FRAME_LEN_STATUSREPORT (FRAME_MIN_LEN + 81)
|
||||
|
||||
enum class CommandType : uint8_t{
|
||||
enum class CommandType : uint8_t{
|
||||
kTianTongVoice = 0xA0,
|
||||
kUhfVoice = 0xA1,
|
||||
kTianTongShortMessage = 0xB0,
|
||||
@@ -23,6 +23,7 @@ enum class CommandType : uint8_t{
|
||||
kBeiDouShortMessage = 0xB2,
|
||||
kStatusReport = 0x80,
|
||||
kSearchSatelliteStatusReport = 0x90,
|
||||
kDebugCmd = 0xE0,
|
||||
};
|
||||
enum class TianTongVoiceSubCommandType: uint8_t{
|
||||
kDial = 0x01, //拨号
|
||||
@@ -87,6 +88,16 @@ enum class PhaseLockedLoopStatus{
|
||||
kLocked = 0x01, //锁定
|
||||
};
|
||||
|
||||
enum class DebugCommandType: uint8_t{
|
||||
kUCattierType = 0x00,
|
||||
kURate = 0x01,
|
||||
kSFreq = 0x02,
|
||||
kSRate = 0x03,
|
||||
kPASwitch = 0x04,
|
||||
kZTCtrl = 0x05,
|
||||
kCmdCtrl = 0x06,
|
||||
};
|
||||
|
||||
struct SatelliteStatus{
|
||||
uint8_t number;
|
||||
uint8_t locate_flag;
|
||||
@@ -94,6 +105,7 @@ struct SatelliteStatus{
|
||||
uint16_t azimuth;
|
||||
uint8_t pitch;
|
||||
};
|
||||
|
||||
void calc_checksum(QByteArray&cmd);
|
||||
QByteArray pack_tiantong_dial_cmd(const std::string& number);
|
||||
QByteArray pack_tiantong_hang_up_cmd();
|
||||
@@ -103,6 +115,15 @@ QByteArray pack_tiantong_send_keys_when_on_line_cmd(const std::string& keys);
|
||||
QByteArray pack_uhf_dial_cmd(const std::string& number);
|
||||
QByteArray pack_uhf_hang_up_cmd();
|
||||
QByteArray pack_uhf_answer();
|
||||
|
||||
QByteArray pack_debug_cmd_UCattierType(uint8_t type);
|
||||
QByteArray pack_debug_cmd_URate(uint8_t type);
|
||||
QByteArray pack_debug_cmd_SFreq(uint16_t freq);
|
||||
QByteArray pack_debug_cmd_SRate(uint8_t type);
|
||||
QByteArray pack_debug_cmd_PASwitch(uint8_t s_switch, uint8_t u_switch, uint8_t bd_switch);
|
||||
QByteArray pack_debug_cmd_ZTCtrl(uint8_t type);
|
||||
QByteArray pack_debug_cmd_CmdCtrl(uint8_t type, const std::string& cmd_content);
|
||||
|
||||
QByteArray pack_slip(QByteArray &message);
|
||||
int pack_deslip(QByteArray &message);
|
||||
QByteArray pack_tiantong_short_message_cmd(const std::string& number,const std::u16string& message);
|
||||
|
||||
Reference in New Issue
Block a user