Added ability to read RIT status. Added RIT to initial rig query. Added

variables to handle delayed command timing values. Fixed bug in
frequency parsing code that had existed for some time. Changed tic marks
on RIT knob because I wanted more of them. Bumped startup initial rig
state queries to 100ms. May consider faster queries on startup since we
are going to need more things queried on startup.
merge-requests/2/head
Elliott Liggett 2021-04-25 00:23:52 -07:00
rodzic f619e9eca1
commit 80cc3e6dc0
5 zmienionych plików z 110 dodań i 26 usunięć

Wyświetl plik

@ -1175,6 +1175,10 @@ void rigCommander::parseCommand()
qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model;
break;
case '\x21':
// RIT and Delta TX:
parseRegister21();
break;
case '\x26':
if((int)payloadIn[1] == 0)
@ -1957,6 +1961,45 @@ void rigCommander::parseRegisters1C()
}
}
void rigCommander::parseRegister21()
{
// Register 21 is RIT and Delta TX
int ritHz = 0;
freqt f;
QByteArray longfreq;
// Example RIT value reply:
// Index: 00 01 02 03 04 05
// DATA: 21 00 32 03 00 fd
switch(payloadIn[01])
{
case '\x00':
// RIT frequency
//
longfreq = payloadIn.mid(2,2);
longfreq.append(QByteArray(3,'\x00'));
f = parseFrequency(longfreq, 3);
ritHz = f.Hz*((payloadIn.at(4)=='\x01')?-1:1);
emit haveRitFrequency(ritHz);
break;
case '\x01':
// RIT on/off
if(payloadIn.at(02) == '\x01')
{
emit haveRitEnabled(true);
} else {
emit haveRitEnabled(false);
}
break;
case '\x02':
// Delta TX setting on/off
break;
default:
break;
}
}
void rigCommander::parseATU()
{
// qDebug(logRig()) << "Have ATU status from radio. Emitting.";
@ -2916,6 +2959,9 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
// TODO: Check length of data array prior to reading +/- position
// NOTE: This function was written on the IC-7300, which has no need for 100 MHz and 1 GHz.
// Therefore, this function has to go to position +1 to retrieve those numbers for the IC-9700.
// TODO: 64-bit value is incorrect, multiplying by wrong numbers.
float freq = 0.0;
@ -2932,9 +2978,13 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
freq += 10*((data[lastPosition] & 0xf0) >> 4);
freqs.Hz += (data[lastPosition] & 0x0f) * 1E6;
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10;
freqs.Hz += (data[lastPosition+1] & 0x0f) * 1E6 * 100;
freqs.Hz += ((data[lastPosition+1] & 0xf0) >> 4) * 1E6 * 1000;
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10; // 10 MHz
if(data.length() >= lastPosition+1)
{
freqs.Hz += (data[lastPosition+1] & 0x0f) * 1E6 * 100; // 100 MHz
freqs.Hz += ((data[lastPosition+1] & 0xf0) >> 4) * 1E6 * 1000; // 1000 MHz
}
// Hz:
@ -2947,14 +2997,14 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
freq += ((data[lastPosition-3] & 0xf0) >> 4) / 100000.0;
freq += (data[lastPosition-3] & 0x0f) / 1000000.0;
freqs.Hz += (data[lastPosition-1] & 0x0f);
freqs.Hz += ((data[lastPosition-1] & 0xf0) >> 4) * 10;
freqs.Hz += (data[lastPosition-1] & 0x0f) * 10E3; // 10 KHz
freqs.Hz += ((data[lastPosition-1] & 0xf0) >> 4) * 100E3; // 100 KHz
freqs.Hz += (data[lastPosition-2] & 0x0f) * 100;
freqs.Hz += ((data[lastPosition-2] & 0xf0) >> 4) * 1000;
freqs.Hz += (data[lastPosition-2] & 0x0f) * 100; // 100 Hz
freqs.Hz += ((data[lastPosition-2] & 0xf0) >> 4) * 1000; // 1 KHz
freqs.Hz += (data[lastPosition-3] & 0x0f) * 10000;
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 100000;
freqs.Hz += (data[lastPosition-3] & 0x0f) * 1; // 1 Hz
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 10; // 10 Hz
freqs.MHzDouble = (double)freq;
return freqs;

Wyświetl plik

@ -247,6 +247,8 @@ signals:
void haveMode(unsigned char mode, unsigned char filter);
void haveDataMode(bool dataModeEnabled);
void haveBandStackReg(float freq, char mode, bool dataOn);
void haveRitEnabled(bool ritEnabled);
void haveRitFrequency(int ritHz);
// Repeater:
void haveDuplexMode(duplexMode);
@ -328,6 +330,7 @@ private:
void parseRegister1B();
void parseRegisters1C();
void parseRegister16();
void parseRegister21();
void parseBandStackReg();
void parsePTT();
void parseATU();

Wyświetl plik

@ -305,8 +305,10 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
rigName->setText("NONE");
rigName->setFixedWidth(50);
delayedCmdInterval_ms = 100; // interval for regular delayed commands
delayedCmdStartupInterval_ms = 100; // interval for initial rig state polling
delayedCommand = new QTimer(this);
delayedCommand->setInterval(250); // 250ms until we find rig civ and id, then 100ms.
delayedCommand->setInterval(delayedCmdStartupInterval_ms); // 250ms until we find rig civ and id, then 100ms.
delayedCommand->setSingleShot(true);
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
@ -355,6 +357,11 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
connect(rig, SIGNAL(haveBandStackReg(float,char,bool)), this, SLOT(receiveBandStackReg(float,char,bool)));
connect(this, SIGNAL(setRitEnable(bool)), rig, SLOT(setRitEnable(bool)));
connect(this, SIGNAL(setRitValue(int)), rig, SLOT(setRitValue(int)));
connect(rig, SIGNAL(haveRitEnabled(bool)), this, SLOT(receiveRITStatus(bool)));
connect(rig, SIGNAL(haveRitFrequency(int)), this, SLOT(receiveRITValue(int)));
connect(this, SIGNAL(getRitEnabled()), rig, SLOT(getRitEnabled()));
connect(this, SIGNAL(getRitValue()), rig, SLOT(getRitValue()));
connect(this, SIGNAL(getDebug()), rig, SLOT(getDebug()));
connect(this, SIGNAL(spectOutputDisable()), rig, SLOT(disableSpectOutput()));
@ -739,7 +746,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
//now we know what the rig ID is:
//qDebug(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
delayedCommand->setInterval(100); // faster polling is ok now.
delayedCommand->setInterval(delayedCmdInterval_ms); // faster polling is ok now.
receiveRigID(rigCaps);
getInitialRigState();
@ -1521,6 +1528,9 @@ void wfmain:: getInitialRigState()
cmdOutQue.append(cmdGetPreamp);
}
cmdOutQue.append(cmdGetRitEnabled);
cmdOutQue.append(cmdGetRitValue);
cmdOutQue.append(cmdGetSpectrumMode);
cmdOutQue.append(cmdGetSpectrumSpan);
@ -1842,6 +1852,12 @@ void wfmain::runDelayedCommand()
case cmdSetDataModeOn:
emit setDataMode(true);
break;
case cmdGetRitEnabled:
emit getRitEnabled();
break;
case cmdGetRitValue:
emit getRitValue();
break;
case cmdGetModInput:
emit getModInput(false);
break;
@ -1931,7 +1947,7 @@ void wfmain::runDelayedCommand()
periodicPollingTimer->stop();
break;
case cmdQueNormalSpeed:
delayedCommand->setInterval(100);
delayedCommand->setInterval(delayedCmdInterval_ms);
break;
default:
break;
@ -3802,15 +3818,30 @@ void wfmain::on_ritEnableChk_clicked(bool checked)
emit setRitEnable(checked);
}
void wfmain::receiveRITStatus(bool ritEnabled)
{
ui->ritEnableChk->blockSignals(true);
ui->ritEnableChk->setChecked(ritEnabled);
ui->ritEnableChk->blockSignals(false);
}
void wfmain::receiveRITValue(int ritValHz)
{
if((ritValHz > -500) and (ritValHz < 500))
{
ui->ritTuneDial->blockSignals(true);
ui->ritTuneDial->setValue(ritValHz);
ui->ritTuneDial->blockSignals(false);
} else {
qDebug(logSystem()) << "Warning: out of range RIT value received: " << ritValHz << " Hz";
}
}
// --- DEBUG FUNCTION ---
void wfmain::on_debugBtn_clicked()
{
qDebug(logSystem()) << "Debug button pressed.";
// emit getLevels();
// emit getMeters(amTransmitting);
// emit getTSQL();
qDebug(logSystem()) << "Getting scope mode";
emit getScopeMode(); // center or fixed
qDebug(logSystem()) << "Getting RIT enabled status: ";
emit getRitValue();
}

Wyświetl plik

@ -185,6 +185,8 @@ private slots:
void receivePTTstatus(bool pttOn);
void receiveDataModeStatus(bool dataOn);
void receiveBandStackReg(float freq, char mode, bool dataOn); // freq, mode, (filter,) datamode
void receiveRITStatus(bool ritEnabled);
void receiveRITValue(int ritValHz);
void receiveModInput(rigInput input, bool dataOn);
//void receiveDuplexMode(duplexMode dm);
@ -517,19 +519,21 @@ private:
freqt freq;
float tsKnobMHz;
enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetMode, cmdGetDataMode, cmdSetDataModeOn, cmdSetDataModeOff,
enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetMode, cmdGetDataMode,
cmdSetDataModeOn, cmdSetDataModeOff, cmdGetRitEnabled, cmdGetRitValue,
cmdSpecOn, cmdSpecOff, cmdDispEnable, cmdDispDisable, cmdGetRxGain, cmdGetAfGain,
cmdGetSql, cmdGetATUStatus, cmdGetSpectrumMode, cmdGetSpectrumSpan, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT,
cmdGetTxPower, cmdGetMicGain, cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput,
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed,
cmdGetVdMeter, cmdGetIdMeter,
cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter,
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter,
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna};
cmds cmdOut;
QVector <cmds> cmdOutQue;
QVector <cmds> periodicCmdQueue;
int pCmdNum = 0;
int delayedCmdInterval_ms = 100;
int delayedCmdStartupInterval_ms = 100;
freqMemory mem;
struct colors {
@ -579,10 +583,6 @@ private:
void useColors(); // set the plot up
void setDefPrefs(); // populate default values to default prefs
void setTuningSteps();
//double roundFrequency(double frequency);
//double roundFrequency(double frequency, unsigned int tsHz);
//double roundFrequencyWithStep(double oldFreq, int steps,
// unsigned int tsHz);
quint64 roundFrequency(quint64 frequency, unsigned int tsHz);
quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\

Wyświetl plik

@ -306,7 +306,7 @@
<bool>false</bool>
</property>
<property name="notchTarget">
<double>50.000000000000000</double>
<double>10.000000000000000</double>
</property>
<property name="notchesVisible">
<bool>true</bool>