kopia lustrzana https://github.com/PianetaRadio/CatRadio
rodzic
e642a6f545
commit
724a3dc356
|
@ -22,6 +22,11 @@
|
||||||
|
|
||||||
#include "rig.h"
|
#include "rig.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
DialogCommand::DialogCommand(RIG *rig, QWidget *parent) :
|
DialogCommand::DialogCommand(RIG *rig, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -29,6 +34,10 @@ DialogCommand::DialogCommand(RIG *rig, QWidget *parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
my_rig = rig;
|
my_rig = rig;
|
||||||
|
int backend = RIG_BACKEND_NUM(my_rig->caps->rig_model);
|
||||||
|
|
||||||
|
if (backend == RIG_YAESU || backend == RIG_KENWOOD) ui->radioButton_yaesu->setChecked(true);
|
||||||
|
else if (backend == RIG_ICOM) ui->radioButton_icom->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogCommand::~DialogCommand()
|
DialogCommand::~DialogCommand()
|
||||||
|
@ -38,25 +47,45 @@ DialogCommand::~DialogCommand()
|
||||||
|
|
||||||
void DialogCommand::on_pushButton_send_clicked()
|
void DialogCommand::on_pushButton_send_clicked()
|
||||||
{
|
{
|
||||||
|
bool hex = false; //Flag for Hex command
|
||||||
|
|
||||||
QString sendCmdS = ui->lineEdit_commandSend->text();
|
QString sendCmdS = ui->lineEdit_commandSend->text();
|
||||||
const unsigned char *sendCmd = (unsigned char*)sendCmdS.toLatin1().data();
|
QByteArray sendCmdA;
|
||||||
int sendCmdLen = sendCmdS.size();
|
if (sendCmdS.isEmpty()) return;
|
||||||
unsigned char termCmd[] = ";";
|
if (sendCmdS.contains("0x", Qt::CaseInsensitive)) //Hex input
|
||||||
|
{
|
||||||
|
sendCmdS = sendCmdS.mid(2);
|
||||||
|
sendCmdA = QByteArray::fromHex(sendCmdS.toLatin1());
|
||||||
|
hex = true;
|
||||||
|
}
|
||||||
|
else sendCmdA = sendCmdS.toUtf8(); //Char input
|
||||||
|
|
||||||
unsigned char rcvdCmd[100];
|
QByteArray termCmdA;
|
||||||
|
termCmdA.resize(1);
|
||||||
|
if (ui->radioButton_yaesu->isChecked()) termCmdA[0] = ';';
|
||||||
|
else if (ui->radioButton_icom->isChecked()) termCmdA[0] = 0xfd;
|
||||||
|
else if (ui->radioButton_CR->isChecked()) termCmdA[0] = 0x0d;
|
||||||
|
else if (ui->radioButton_LF->isChecked()) termCmdA[0] = 0x0a;
|
||||||
|
else termCmdA[0] = '\0';
|
||||||
|
unsigned char *termCmd = (unsigned char*)termCmdA.data();
|
||||||
|
|
||||||
|
sendCmdA.append(termCmdA);
|
||||||
|
unsigned char *sendCmd = (unsigned char*)sendCmdA.data();
|
||||||
|
int sendCmdLen = strlen((char*)sendCmd);
|
||||||
|
|
||||||
|
unsigned char rcvdCmd[200];
|
||||||
int rcvdCmdLen = sizeof(rcvdCmd);
|
int rcvdCmdLen = sizeof(rcvdCmd);
|
||||||
|
|
||||||
//qDebug()<<sendCmdS<<(char*)termCmd<<(char*)sendCmd<<sendCmdLen;
|
int retLen = rig_send_raw(my_rig, sendCmd, sendCmdLen, rcvdCmd, rcvdCmdLen, termCmd);
|
||||||
|
|
||||||
rig_send_raw(my_rig, sendCmd, sendCmdLen, rcvdCmd, rcvdCmdLen, termCmd);
|
|
||||||
|
|
||||||
//QString rcvdCmdS = rcvdCmd;
|
|
||||||
|
|
||||||
//qDebug()<<(char *)rcvdCmd;
|
|
||||||
|
|
||||||
|
if (retLen > 0)
|
||||||
|
{
|
||||||
|
QString rcvdCmdS;
|
||||||
|
QByteArray rcvdCmdA(QByteArray::fromRawData((char *)rcvdCmd, retLen));
|
||||||
|
if (hex) rcvdCmdS = rcvdCmdA.toHex();
|
||||||
|
else rcvdCmdS = rcvdCmdA;
|
||||||
|
ui->lineEdit_receive->setText(rcvdCmdS);
|
||||||
|
}
|
||||||
|
|
||||||
//int rig_send_raw(rig, const unsigned char *send, int send_len, unsigned char *reply, int reply_len, unsigned char *term);
|
//int rig_send_raw(rig, const unsigned char *send, int send_len, unsigned char *reply, int reply_len, unsigned char *term);
|
||||||
//send contains the raw command data
|
//send contains the raw command data
|
||||||
|
|
|
@ -13,49 +13,79 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Command</string>
|
<string>Command</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_commandSend">
|
<widget class="QLabel" name="label_commandSend">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Command Send</string>
|
<string>Command Send</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>lineEdit_commandSend</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="2" column="0">
|
||||||
<widget class="QLineEdit" name="lineEdit_commandSend"/>
|
<widget class="QLabel" name="label_received">
|
||||||
|
<property name="text">
|
||||||
|
<string>Received</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>lineEdit_receive</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="pushButton_send">
|
<widget class="QPushButton" name="pushButton_send">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Send</string>
|
<string>Send</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="3">
|
||||||
<widget class="QLabel" name="label_receive">
|
<widget class="QRadioButton" name="radioButton_LF">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Receive</string>
|
<string>LF</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_commandSend"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QPushButton" name="pushButton_close">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QRadioButton" name="radioButton_CR">
|
||||||
|
<property name="text">
|
||||||
|
<string>CR</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="3">
|
||||||
<widget class="QLineEdit" name="lineEdit_receive">
|
<widget class="QLineEdit" name="lineEdit_receive">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox_icom">
|
<widget class="QRadioButton" name="radioButton_icom">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Icom</string>
|
<string>Icom 0xfd</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_close">
|
<widget class="QRadioButton" name="radioButton_yaesu">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Close</string>
|
<string>Yaesu/Kwd ;</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -81,7 +81,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
//* Debug
|
//* Debug
|
||||||
rig_set_debug_level(RIG_DEBUG_WARN); //normal
|
rig_set_debug_level(RIG_DEBUG_WARN); //normal
|
||||||
//rig_set_debug_level(RIG_DEBUG_TRACE); //debug
|
//rig_set_debug_level(RIG_DEBUG_VERBOSE); //debug verbose
|
||||||
|
//rig_set_debug_level(RIG_DEBUG_TRACE); //debug trace
|
||||||
rig_set_debug_time_stamp(true);
|
rig_set_debug_time_stamp(true);
|
||||||
if ((debugFile=fopen("catradio.log","w+")) == NULL) rig_set_debug_level(RIG_DEBUG_NONE);
|
if ((debugFile=fopen("catradio.log","w+")) == NULL) rig_set_debug_level(RIG_DEBUG_NONE);
|
||||||
else rig_set_debug_file(debugFile);
|
else rig_set_debug_file(debugFile);
|
||||||
|
|
Ładowanie…
Reference in New Issue