Merge branch 'audio-enhance'

lv2
Roeland Jansen 2021-08-06 09:32:09 +02:00
commit e9df69f156
3 zmienionych plików z 234 dodań i 97 usunięć

Wyświetl plik

@ -80,10 +80,12 @@ void rigCtlClient::socketReadyRead()
{
QByteArray data = socket->readAll();
commandBuffer.append(data);
static QString sep = " ";
QString sep = "\n";
static int num = 0;
bool longReply = false;
unsigned char responseCode = 0;
char responseCode = 0;
QStringList response;
bool setCommand = false;
if (commandBuffer.endsWith('\n'))
{
qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer;
@ -108,6 +110,7 @@ void rigCtlClient::socketReadyRead()
}
else if (commandBuffer[num] == "+")
{
longReply = true;
sep = "\n";
num++;
}
@ -123,94 +126,167 @@ void rigCtlClient::socketReadyRead()
if (commandBuffer[num] == "\\")
{
num++;
longReply = true;
}
QStringList command = commandBuffer.mid(num).split(" ");
if (command[0] == 0xf0 || command[0]=="chk_vfo")
if (command[0] == 0xf0 || command[0] == "chk_vfo")
{
sendData(QString("%1\n").arg(rigState->currentVfo));
response.append(QString("%1").arg(rigState->currentVfo));
}
else if (command[0] == "dump_state")
{
{
// Currently send "fake" state information until I can work out what is required!
sendData(QString("1\n1\n0\n150000.000000 1500000000.000000 0x1ff -1 -1 0x16000003 0xf\n0 0 0 0 0 0 0\n0 0 0 0 0 0 0\n0x1ff 1\n0x1ff 0\n0 0\n0x1e 2400\n0x2 500\n0x1 8000\n0x1 2400\n0x20 15000\n0x20 8000\n0x40 230000\n0 0\n9990\n9990\n10000\n0\n10\n10 20 30\n0x3effffff\n0x3effffff\n0x7fffffff\n0x7fffffff\n0x7fffffff\n0x7fffffff\ndone\n"));
response.append("1");
response.append("1");
response.append("0");
response.append("150000.000000 1500000000.000000 0x1ff -1 -1 0x16000003 0xf");
response.append("0 0 0 0 0 0 0");
response.append("0 0 0 0 0 0 0");
response.append("0x1ff 1");
response.append("0x1ff 0");
response.append("0 0");
response.append("0x1e 2400");
response.append("0x2 500");
response.append("0x1 8000");
response.append("0x1 2400");
response.append("0x20 15000");
response.append("0x20 8000");
response.append("0x40 230000");
response.append("0 0");
response.append("9900");
response.append("9900");
response.append("10000");
response.append("0");
response.append("10");
response.append("10 20 30");
response.append("0x3effffff");
response.append("0x3effffff");
response.append("0x7fffffff");
response.append("0x7fffffff");
response.append("0x7fffffff");
response.append("0x7fffffff");
response.append("done");
}
else if (command[0] == "f" || command[0] == "get_freq")
{
if (rigState->currentVfo == 0) {
sendData(QString("%1\n").arg(rigState->vfoAFreq.Hz));
response.append(QString("%1").arg(rigState->vfoAFreq.Hz));
}
else {
sendData(QString("%1\n").arg(rigState->vfoBFreq.Hz));
response.append(QString("%1").arg(rigState->vfoBFreq.Hz));
}
}
else if (command[0] == "F" || command[0] == "set_freq")
{
if (command.length()>1)
setCommand = true;
freqt freq;
bool ok=false;
double newFreq;
QString vfo = "VFOA";
if (command.length() == 2)
{
freqt freq;
bool ok;
double newFreq = command[1].toDouble(&ok);
if (ok) {
freq.Hz = static_cast<int>(newFreq);
}
qInfo(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]);
newFreq = command[1].toDouble(&ok);
}
else if (command.length() == 3) // Includes VFO
{
newFreq = command[2].toDouble(&ok);
vfo = command[1];
}
if (ok) {
freq.Hz = static_cast<int>(newFreq);
qDebug(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]);
emit parent->setFrequency(freq);
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "1" || command[0] == "dump_caps")
{
dumpCaps(sep);
}
else if (command[0] == "t" || command[0] == "get_ptt")
{
sendData(QString("%1\n").arg(rigState->ptt));
}
else if (command[0] == "T" || command[0] == "set_ptt")
{
if (command.length()>1 && command[1] == "0") {
emit parent->setPTT(false);
response.append(QString("Caps dump for model: %1").arg(rigCaps.modelID));
response.append(QString("Model Name:\t%1").arg(rigCaps.modelName));
response.append(QString("Mfg Name:\tIcom"));
response.append(QString("Backend version:\t0.1"));
response.append(QString("Backend copyright:\t2021"));
if (rigCaps.hasTransmit) {
response.append(QString("Rig type:\tTransceiver"));
}
else {
emit parent->setPTT(true);
else
{
response.append(QString("Rig type:\tReceiver"));
}
if (rigCaps.hasPTTCommand) {
response.append(QString("PTT type:\tRig capable"));
}
response.append(QString("DCD type:\tRig capable"));
response.append(QString("Port type:\tNetwork link"));
}
else if (command[0] == "t" || command[0] == "get_ptt")
{
if (rigCaps.hasPTTCommand) {
response.append(QString("%1").arg(rigState->ptt));
}
else
{
responseCode = -1;
}
}
else if (command[0] == "T" || command[0] == "set_ptt")
{
setCommand = true;
if (rigCaps.hasPTTCommand) {
if (command.length() > 1 && command[1] == "0") {
emit parent->setPTT(false);
}
else {
emit parent->setPTT(true);
}
}
else
{
responseCode = -1;
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "v" || command[0] == "get_vfo")
{
if (rigState->currentVfo == 0) {
sendData(QString("%1\n").arg("VFOA"));
response.append("VFOA");
}
else {
sendData(QString("%1\n").arg("VFOB"));
response.append("VFOB");
}
}
else if (command[0] == "V" || command[0] == "set_vfo")
{
qDebug(logRigCtlD()) << QString("Got VFO command: %1").arg(command[1]);
if (command.length() > 1 && command[1] == "VFOB") {
setCommand = true;
if (command.length() > 1 && command[1] == "?") {
response.append("set_vfo: ?");
response.append("VFOA");
response.append("VFOB");
response.append("Sub");
response.append("Main");
response.append("MEM");
}
else if (command.length() > 1 && (command[1] == "VFOB" || command[1] == "Sub")) {
emit parent->setVFO(1);
}
else {
emit parent->setVFO(0);
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "s" || command[0] == "get_split_vfo")
{
sendData(QString("%1\n").arg(rigState->splitEnabled));
response.append(QString("%1").arg(rigState->splitEnabled));
if (rigState->currentVfo == 0)
{
sendData(QString("%1\n").arg("VFOB"));
response.append(QString("%1").arg("VFOB"));
}
else {
sendData(QString("%1\n").arg("VFOA"));
response.append(QString("%1").arg("VFOA"));
}
}
else if (command[0] == "S" || command[0] == "set_split_vfo")
{
setCommand = true;
if (command.length() > 1 && command[1] == "1")
{
emit parent->setSplit(1);
@ -218,7 +294,33 @@ void rigCtlClient::socketReadyRead()
else {
emit parent->setSplit(0);
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "\xf3" || command[0] == "get_vfo_info")
{
if (longReply) {
//response.append(QString("set_vfo: %1").arg(command[1]));
if (command[1] == "VFOB") {
response.append(QString("Freq: %1").arg(rigState->vfoBFreq.Hz));
}
else {
response.append(QString("Freq: %1").arg(rigState->vfoAFreq.Hz));
}
response.append(QString("Mode: %1").arg(getMode(rigState->mode, rigState->datamode)));
response.append(QString("Width: %1").arg(getFilter(rigState->mode, rigState->filter)));
response.append(QString("Split: %1").arg(rigState->splitEnabled));
response.append(QString("SatMode: %1").arg(0)); // Need to get satmode
}
else {
if (command[1] == "VFOB") {
response.append(QString("%1").arg(rigState->vfoBFreq.Hz));
}
else {
response.append(QString("%1").arg(rigState->vfoAFreq.Hz));
}
response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode)));
response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter)));
}
}
else if (command[0] == "i" || command[0] == "get_split_freq")
{
@ -231,7 +333,7 @@ void rigCtlClient::socketReadyRead()
}
else if (command[0] == "I" || command[0] == "set_split_freq")
{
sendData(QString("RPRT %1\n").arg(responseCode));
setCommand = true;
}
else if (command[0] == "m" || command[0] == "get_mode")
{
@ -241,35 +343,71 @@ void rigCtlClient::socketReadyRead()
else {
sendData(QString("%1\n%2\n").arg(getMode(rigState->mode, rigState->datamode)).arg(getFilter(rigState->mode, rigState->filter)));
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "M" || command[0] == "set_mode")
{
// Set mode
if (command.length() > 2) {
qInfo(logRigCtlD()) << "setting mode: " << getMode(command[1]) << command[1] << "width" << command[2];
int width = command[2].toInt();
if (width != -1 && width <= 1800)
width = 2;
else
width = 1;
emit parent->setMode(getMode(command[1]), width);
if (command[1].mid(0, 3) == "PKT") {
emit parent->setDataMode(true, width);
}
else {
emit parent->setDataMode(false, 0x01);
}
setCommand = true;
int width = -1;
QString vfo = "VFOA";
QString mode = "USB";
if (command.length() == 3) {
width = command[2].toInt();
mode = command[1];
}
else if (command.length() == 4) {
width = command[3].toInt();
mode = command[2];
vfo = command[1];
}
qDebug(logRigCtlD()) << "setting mode: VFO:" << vfo << getMode(mode) << mode << "width" << width;
if (width != -1 && width <= 1800)
width = 2;
else
width = 1;
emit parent->setMode(getMode(mode), width);
if (mode.mid(0, 3) == "PKT") {
emit parent->setDataMode(true, width);
}
else {
emit parent->setDataMode(false, width);
}
sendData(QString("RPRT %1\n").arg(responseCode));
}
else if (command[0] == "s" || command[0] == "get_split_vfo")
else if (command[0] == "s" || command[0] == "get_split_vfo")
{
sendData(QString("0\nVFOA\n"));
response.append(QString("0"));
response.append(QString("VFOA"));
}
if (longReply) {
if (command.length() == 2)
sendData(QString("%1: %2%3").arg(command[0]).arg(command[1]).arg(sep));
if (command.length() == 3)
sendData(QString("%1: %2 %3%4").arg(command[0]).arg(command[1]).arg(command[2]).arg(sep));
if (command.length() == 4)
sendData(QString("%1: %2 %3 %4%5").arg(command[0]).arg(command[1]).arg(command[2]).arg(command[3]).arg(sep));
}
if (setCommand || responseCode != 0 || longReply) {
if (responseCode == 0) {
response.append(QString("RPRT 0"));
}
else {
response.append(QString("RPRT %1").arg(responseCode));
}
}
for (QString str : response)
{
sendData(QString("%1%2").arg(str).arg(sep));
}
if (sep != "\n") {
sendData(QString("\n"));
}
commandBuffer.clear();
sep = " ";
num = 0;
@ -301,19 +439,6 @@ void rigCtlClient::sendData(QString data)
}
}
void rigCtlClient::dumpCaps(QString sep)
{
sendData(QString("Caps dump for model: %1%2").arg(rigCaps.modelID).arg(sep));
sendData(QString("Model Name:\t%1%2").arg(rigCaps.modelName).arg(sep));
sendData(QString("Mfg Name:\tIcom%1").arg(sep));
sendData(QString("Backend version:\t0.1%1").arg(sep));
sendData(QString("Backend copyright:\t2021%1").arg(sep));
sendData(QString("Rig type:\tTransceiver%1").arg(sep));
sendData(QString("PTT type:\tRig capable%1").arg(sep));
sendData(QString("DCD type:\tRig capable%1").arg(sep));
sendData(QString("Port type:\tNetwork link%1").arg(sep));
sendData(QString("\n"));
}
QString rigCtlClient::getFilter(unsigned char mode, unsigned char filter) {
@ -377,7 +502,7 @@ QString rigCtlClient::getMode(unsigned char mode, bool datamode) {
QString ret;
if (datamode) {
return ret="PKT";
ret="PKT";
}
switch (mode) {

Wyświetl plik

@ -70,7 +70,6 @@ protected:
QString commandBuffer;
private:
void dumpCaps(QString sep);
rigCapabilities rigCaps;
rigStateStruct* rigState = Q_NULLPTR;
rigCtlD* parent;

Wyświetl plik

@ -2244,26 +2244,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="enableRigctldChk">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Enable RigCtld</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rigctldPortTxt"/>
</item>
</layout>
</item>
<item>
@ -2430,6 +2410,39 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="enableRigctldChk">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Enable RigCtld</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rigctldPortTxt"/>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="vspLabel">
<property name="text">