2018-06-19 19:58:52 +00:00
|
|
|
#ifndef RIGCOMMANDER_H
|
|
|
|
#define RIGCOMMANDER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-02-10 17:32:56 +00:00
|
|
|
#include <QDebug>
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
#include "commhandler.h"
|
2021-03-04 20:19:05 +00:00
|
|
|
#include "pttyhandler.h"
|
2021-02-10 17:32:56 +00:00
|
|
|
#include "udphandler.h"
|
2018-11-24 08:10:05 +00:00
|
|
|
#include "rigidentities.h"
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
// This file figures out what to send to the comm and also
|
|
|
|
// parses returns into useful things.
|
|
|
|
|
2018-11-16 22:08:21 +00:00
|
|
|
// 0xE1 is new default, 0xE0 was before.
|
|
|
|
// note: using a define because switch case doesn't even work with const unsigned char. Surprised me.
|
|
|
|
#define compCivAddr 0xE1
|
|
|
|
|
2021-02-21 04:41:19 +00:00
|
|
|
enum duplexMode {
|
2021-02-18 07:26:10 +00:00
|
|
|
dmSplitOff=0x00,
|
|
|
|
dmSplitOn=0x01,
|
|
|
|
dmSimplex=0x10,
|
|
|
|
dmDupMinus=0x11,
|
2021-02-18 07:41:01 +00:00
|
|
|
dmDupPlus=0x12,
|
2021-02-19 05:47:19 +00:00
|
|
|
dmDupRPS=0x13,
|
|
|
|
dmDupAutoOn=0x26,
|
|
|
|
dmDupAutoOff=0x36
|
2021-02-18 07:26:10 +00:00
|
|
|
};
|
2018-11-16 22:08:21 +00:00
|
|
|
|
2021-02-21 04:41:19 +00:00
|
|
|
enum meterKind {
|
|
|
|
meterS,
|
|
|
|
meterSWR,
|
|
|
|
meterPower,
|
|
|
|
meterALC,
|
|
|
|
meterComp,
|
|
|
|
meterVoltage,
|
|
|
|
meterCurrent
|
|
|
|
};
|
|
|
|
|
2021-03-01 05:41:27 +00:00
|
|
|
enum spectrumMode {
|
|
|
|
spectModeCenter=0x00,
|
|
|
|
spectModeFixed=0x01,
|
|
|
|
spectModeScrollC=0x02,
|
|
|
|
spectModeScrollF=0x03,
|
|
|
|
spectModeUnknown=0xff
|
|
|
|
};
|
|
|
|
|
2018-06-19 19:58:52 +00:00
|
|
|
class rigCommander : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-02-10 17:32:56 +00:00
|
|
|
rigCommander();
|
2018-06-19 19:58:52 +00:00
|
|
|
~rigCommander();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void process();
|
2021-02-10 17:32:56 +00:00
|
|
|
void commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate);
|
2021-03-01 19:53:12 +00:00
|
|
|
void commSetup(unsigned char rigCivAddr, udpPreferences prefs);
|
2021-02-10 17:32:56 +00:00
|
|
|
void closeComm();
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
void enableSpectOutput();
|
|
|
|
void disableSpectOutput();
|
|
|
|
void enableSpectrumDisplay();
|
|
|
|
void disableSpectrumDisplay();
|
2021-02-10 17:32:56 +00:00
|
|
|
void setSpectrumBounds(double startFreq, double endFreq, unsigned char edgeNumber);
|
2021-03-01 05:41:27 +00:00
|
|
|
void setSpectrumMode(spectrumMode spectMode);
|
2018-12-18 22:34:04 +00:00
|
|
|
void getSpectrumCenterMode();
|
2021-03-01 05:41:27 +00:00
|
|
|
void getSpectrumMode();
|
2021-02-16 05:40:31 +00:00
|
|
|
void setSpectrumRefLevel(int level);
|
2021-02-16 06:33:21 +00:00
|
|
|
void getSpectrumRefLevel();
|
|
|
|
void getSpectrumRefLevel(unsigned char mainSub);
|
2018-06-19 19:58:52 +00:00
|
|
|
void setScopeSpan(char span);
|
2018-12-18 22:34:04 +00:00
|
|
|
void getScopeSpan();
|
2018-06-19 19:58:52 +00:00
|
|
|
void setScopeEdge(char edge);
|
2018-12-18 22:34:04 +00:00
|
|
|
void getScopeEdge();
|
|
|
|
void getScopeMode();
|
2018-06-19 19:58:52 +00:00
|
|
|
void setFrequency(double freq);
|
2021-02-13 18:02:45 +00:00
|
|
|
void setMode(unsigned char mode, unsigned char modeFilter);
|
2018-06-19 19:58:52 +00:00
|
|
|
void getFrequency();
|
2018-11-16 22:08:21 +00:00
|
|
|
void getBandStackReg(char band, char regCode);
|
2018-06-19 19:58:52 +00:00
|
|
|
void getMode();
|
2018-11-07 23:54:03 +00:00
|
|
|
void getPTT();
|
|
|
|
void setPTT(bool pttOn);
|
|
|
|
void setDataMode(bool dataOn);
|
2018-06-19 19:58:52 +00:00
|
|
|
void getDataMode();
|
2021-02-18 07:26:10 +00:00
|
|
|
void setDuplexMode(duplexMode dm);
|
|
|
|
void getDuplexMode();
|
2021-02-15 23:17:48 +00:00
|
|
|
|
|
|
|
void getLevels(); // all supported levels
|
|
|
|
|
2018-11-16 22:08:21 +00:00
|
|
|
void getRfGain();
|
2018-11-17 06:19:44 +00:00
|
|
|
void getAfGain();
|
2018-11-18 08:01:20 +00:00
|
|
|
void getSql();
|
2021-02-15 23:17:48 +00:00
|
|
|
void getTxLevel();
|
|
|
|
void getMicGain();
|
|
|
|
void getCompLevel();
|
|
|
|
void getMonitorLevel();
|
|
|
|
void getVoxGain();
|
|
|
|
void getAntiVoxGain();
|
2021-02-18 07:26:10 +00:00
|
|
|
void getUSBGain();
|
|
|
|
void getLANGain();
|
|
|
|
void getACCGain();
|
2021-02-20 08:05:23 +00:00
|
|
|
void getACCGain(unsigned char ab);
|
|
|
|
|
2021-02-15 23:17:48 +00:00
|
|
|
|
|
|
|
void getSMeter();
|
|
|
|
void getRFPowerMeter();
|
|
|
|
void getSWRMeter();
|
|
|
|
void getALCMeter();
|
|
|
|
void getCompReductionMeter();
|
|
|
|
void getVdMeter();
|
|
|
|
void getIDMeter();
|
|
|
|
|
2021-02-26 07:57:37 +00:00
|
|
|
void getMeters(meterKind meter); // all supported meters per transmit or receive
|
2021-02-15 23:17:48 +00:00
|
|
|
|
2021-02-11 05:22:38 +00:00
|
|
|
void setSquelch(unsigned char level);
|
2018-11-17 06:19:44 +00:00
|
|
|
void setRfGain(unsigned char level);
|
|
|
|
void setAfGain(unsigned char level);
|
2021-02-16 04:32:14 +00:00
|
|
|
void setTxPower(unsigned char power);
|
|
|
|
void setMicGain(unsigned char gain);
|
2021-02-16 07:52:14 +00:00
|
|
|
void setUSBGain(unsigned char gain);
|
|
|
|
void setLANGain(unsigned char gain);
|
|
|
|
void setACCGain(unsigned char gain);
|
2021-02-20 08:05:23 +00:00
|
|
|
void setACCGain(unsigned char gain, unsigned char ab);
|
|
|
|
|
2021-02-16 04:32:14 +00:00
|
|
|
void setCompLevel(unsigned char compLevel);
|
|
|
|
void setMonitorLevel(unsigned char monitorLevel);
|
|
|
|
void setVoxGain(unsigned char gain);
|
|
|
|
void setAntiVoxGain(unsigned char gain);
|
2021-02-15 23:17:48 +00:00
|
|
|
|
2021-02-18 07:26:10 +00:00
|
|
|
void getModInput(bool dataOn);
|
|
|
|
void setModInput(rigInput input, bool dataOn);
|
2021-02-17 08:00:28 +00:00
|
|
|
|
2021-02-20 08:05:23 +00:00
|
|
|
void setModInputLevel(rigInput input, unsigned char level);
|
|
|
|
void getModInputLevel(rigInput input);
|
|
|
|
|
2018-11-17 06:19:44 +00:00
|
|
|
void startATU();
|
2018-11-17 07:13:59 +00:00
|
|
|
void setATU(bool enabled);
|
|
|
|
void getATUStatus();
|
2018-11-20 07:42:34 +00:00
|
|
|
void getRigID();
|
2021-02-10 17:32:56 +00:00
|
|
|
void findRigs();
|
2018-06-19 19:58:52 +00:00
|
|
|
void setCIVAddr(unsigned char civAddr);
|
2021-02-11 08:33:25 +00:00
|
|
|
void getRefAdjustCourse();
|
|
|
|
void getRefAdjustFine();
|
|
|
|
void setRefAdjustCourse(unsigned char level);
|
|
|
|
void setRefAdjustFine(unsigned char level);
|
2021-02-28 20:10:07 +00:00
|
|
|
void handleNewData(const QByteArray& data);
|
2021-03-01 19:53:12 +00:00
|
|
|
void receiveAudioData(const audioPacket& data);
|
2021-02-10 17:32:56 +00:00
|
|
|
void handleSerialPortError(const QString port, const QString errorText);
|
|
|
|
void handleStatusUpdate(const QString text);
|
2021-02-27 00:37:00 +00:00
|
|
|
void changeLatency(const quint16 value);
|
2019-02-01 20:21:54 +00:00
|
|
|
void sayFrequency();
|
|
|
|
void sayMode();
|
|
|
|
void sayAll();
|
2018-06-19 19:58:52 +00:00
|
|
|
void getDebug();
|
2021-02-18 09:14:41 +00:00
|
|
|
void dataFromServer(QByteArray data);
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
signals:
|
2021-02-10 17:32:56 +00:00
|
|
|
void commReady();
|
2018-06-19 19:58:52 +00:00
|
|
|
void haveSpectrumData(QByteArray spectrum, double startFreq, double endFreq); // pass along data to UI
|
2021-02-10 17:32:56 +00:00
|
|
|
void haveRigID(rigCapabilities rigCaps);
|
|
|
|
void discoveredRigID(rigCapabilities rigCaps);
|
|
|
|
void haveSerialPortError(const QString port, const QString errorText);
|
|
|
|
void haveStatusUpdate(const QString text);
|
2018-06-19 19:58:52 +00:00
|
|
|
void haveFrequency(double frequencyMhz);
|
2021-02-14 07:42:51 +00:00
|
|
|
void haveMode(unsigned char mode, unsigned char filter);
|
2018-06-25 07:34:33 +00:00
|
|
|
void haveDataMode(bool dataModeEnabled);
|
2021-02-18 07:26:10 +00:00
|
|
|
void haveDuplexMode(duplexMode);
|
2018-11-16 22:08:21 +00:00
|
|
|
void haveBandStackReg(float freq, char mode, bool dataOn);
|
2018-06-19 19:58:52 +00:00
|
|
|
void haveSpectrumBounds();
|
2018-12-18 22:34:04 +00:00
|
|
|
void haveScopeSpan(char span);
|
2021-03-01 05:41:27 +00:00
|
|
|
void haveSpectrumMode(spectrumMode spectmode);
|
2018-12-18 22:34:04 +00:00
|
|
|
void haveScopeEdge(char edge);
|
2021-02-16 06:33:21 +00:00
|
|
|
void haveSpectrumRefLevel(int level);
|
2021-02-15 23:17:48 +00:00
|
|
|
|
2018-11-17 06:19:44 +00:00
|
|
|
void haveRfGain(unsigned char level);
|
|
|
|
void haveAfGain(unsigned char level);
|
2018-11-18 08:01:20 +00:00
|
|
|
void haveSql(unsigned char level);
|
2018-11-17 06:19:44 +00:00
|
|
|
void haveTxPower(unsigned char level);
|
2021-02-15 23:17:48 +00:00
|
|
|
void haveMicGain(unsigned char level);
|
|
|
|
void haveCompLevel(unsigned char level);
|
|
|
|
void haveMonitorLevel(unsigned char level);
|
|
|
|
void haveVoxGain(unsigned char gain);
|
|
|
|
void haveAntiVoxGain(unsigned char gain);
|
|
|
|
|
2021-02-18 07:26:10 +00:00
|
|
|
void haveModInput(rigInput input, bool isData);
|
|
|
|
void haveLANGain(unsigned char gain);
|
|
|
|
void haveUSBGain(unsigned char gain);
|
|
|
|
void haveACCGain(unsigned char gain, unsigned char ab);
|
2021-02-20 08:05:23 +00:00
|
|
|
void haveModSrcGain(rigInput input, unsigned char gain);
|
2021-02-18 07:26:10 +00:00
|
|
|
|
2021-02-21 04:41:19 +00:00
|
|
|
void haveMeter(meterKind meter, unsigned char level);
|
2021-02-15 23:17:48 +00:00
|
|
|
void haveSMeter(unsigned char level);
|
|
|
|
void haveRFMeter(unsigned char level);
|
|
|
|
void haveSWRMeter(unsigned char);
|
|
|
|
void haveALCMeter(unsigned char);
|
|
|
|
void haveCompMeter(unsigned char dbreduction);
|
|
|
|
void haveVdMeter(unsigned char voltage);
|
|
|
|
void haveIdMeter(unsigned char current);
|
|
|
|
|
2021-02-11 08:33:25 +00:00
|
|
|
void thing();
|
|
|
|
void haveRefAdjustCourse(unsigned char level);
|
|
|
|
void haveRefAdjustFine(unsigned char level);
|
2018-06-19 19:58:52 +00:00
|
|
|
void dataForComm(const QByteArray &outData);
|
|
|
|
void getMoreDebug();
|
|
|
|
void finished();
|
2018-11-07 23:54:03 +00:00
|
|
|
void havePTTStatus(bool pttOn);
|
2018-11-17 07:13:59 +00:00
|
|
|
void haveATUStatus(unsigned char status);
|
2021-02-27 00:37:00 +00:00
|
|
|
void haveChangeLatency(quint16 value);
|
2021-02-18 09:14:41 +00:00
|
|
|
void haveDataForServer(QByteArray outData);
|
2021-03-01 19:53:12 +00:00
|
|
|
void haveAudioData(audioPacket data);
|
2021-02-21 14:53:42 +00:00
|
|
|
void initUdpHandler();
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
private:
|
2021-02-10 17:32:56 +00:00
|
|
|
void setup();
|
2018-06-19 19:58:52 +00:00
|
|
|
QByteArray stripData(const QByteArray &data, unsigned char cutPosition);
|
|
|
|
void parseData(QByteArray data); // new data come here
|
|
|
|
void parseCommand();
|
2021-02-16 06:33:21 +00:00
|
|
|
unsigned char bcdHexToUChar(unsigned char in);
|
|
|
|
unsigned char bcdHexToUChar(unsigned char hundreds, unsigned char tensunits);
|
|
|
|
unsigned int bcdHexToUInt(unsigned char hundreds, unsigned char tensunits);
|
2021-02-11 08:33:25 +00:00
|
|
|
QByteArray bcdEncodeInt(unsigned int);
|
2018-06-19 19:58:52 +00:00
|
|
|
void parseFrequency();
|
|
|
|
float parseFrequency(QByteArray data, unsigned char lastPosition); // supply index where Mhz is found
|
|
|
|
QByteArray makeFreqPayload(double frequency);
|
|
|
|
void parseMode();
|
|
|
|
void parseSpectrum();
|
2018-12-18 22:34:04 +00:00
|
|
|
void parseWFData();
|
2021-02-16 06:33:21 +00:00
|
|
|
void parseSpectrumRefLevel();
|
2018-06-25 07:34:33 +00:00
|
|
|
void parseDetailedRegisters1A05();
|
|
|
|
void parseRegisters1A();
|
2018-11-16 22:08:21 +00:00
|
|
|
void parseBandStackReg();
|
2018-11-07 23:54:03 +00:00
|
|
|
void parseRegisters1C();
|
|
|
|
void parsePTT();
|
2018-11-17 07:13:59 +00:00
|
|
|
void parseATU();
|
2018-11-16 22:08:21 +00:00
|
|
|
void parseLevels(); // register 0x14
|
2018-11-17 06:19:44 +00:00
|
|
|
void sendLevelCmd(unsigned char levAddr, unsigned char level);
|
2021-02-17 08:00:28 +00:00
|
|
|
QByteArray getLANAddr();
|
|
|
|
QByteArray getUSBAddr();
|
2021-02-20 08:05:23 +00:00
|
|
|
QByteArray getACCAddr(unsigned char ab);
|
2021-02-18 07:26:10 +00:00
|
|
|
void setModInput(rigInput input, bool dataOn, bool isQuery);
|
2018-06-19 19:58:52 +00:00
|
|
|
void sendDataOut();
|
|
|
|
void prepDataAndSend(QByteArray data);
|
|
|
|
void debugMe();
|
2021-02-17 08:00:28 +00:00
|
|
|
void printHex(const QByteArray &pdata);
|
2018-06-19 19:58:52 +00:00
|
|
|
void printHex(const QByteArray &pdata, bool printVert, bool printHoriz);
|
2021-02-17 08:00:28 +00:00
|
|
|
|
2021-03-04 20:19:05 +00:00
|
|
|
commHandler* comm = Q_NULLPTR;
|
|
|
|
pttyHandler* ptty = Q_NULLPTR;
|
2021-02-10 17:32:56 +00:00
|
|
|
udpHandler* udp=Q_NULLPTR;
|
2021-02-21 14:53:42 +00:00
|
|
|
QThread* udpHandlerThread = Q_NULLPTR;
|
|
|
|
|
2021-02-10 17:32:56 +00:00
|
|
|
void determineRigCaps();
|
2018-06-19 19:58:52 +00:00
|
|
|
QByteArray payloadIn;
|
|
|
|
QByteArray echoPerfix;
|
|
|
|
QByteArray replyPrefix;
|
|
|
|
QByteArray genericReplyPrefix;
|
|
|
|
|
|
|
|
QByteArray payloadPrefix;
|
|
|
|
QByteArray payloadSuffix;
|
|
|
|
|
|
|
|
QByteArray rigData;
|
|
|
|
|
|
|
|
QByteArray spectrumLine;
|
|
|
|
double spectrumStartFreq;
|
|
|
|
double spectrumEndFreq;
|
|
|
|
|
2021-02-10 17:32:56 +00:00
|
|
|
struct rigCapabilities rigCaps;
|
|
|
|
bool haveRigCaps;
|
2018-11-24 08:10:05 +00:00
|
|
|
model_kind model;
|
2021-02-10 17:32:56 +00:00
|
|
|
quint8 spectSeqMax;
|
|
|
|
quint16 spectAmpMax;
|
|
|
|
quint16 spectLenMax;
|
2021-03-01 05:41:27 +00:00
|
|
|
spectrumMode oldScopeMode;
|
2021-02-10 17:32:56 +00:00
|
|
|
|
|
|
|
bool usingNativeLAN; // indicates using OEM LAN connection (705,7610,9700,7850)
|
|
|
|
bool lookingForRig;
|
|
|
|
bool foundRig;
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
double frequencyMhz;
|
2021-02-10 17:32:56 +00:00
|
|
|
unsigned char civAddr; // IC-7300: 0x94 is default = 148decimal
|
|
|
|
unsigned char incomingCIVAddr; // place to store the incoming CIV.
|
2018-11-16 22:08:21 +00:00
|
|
|
//const unsigned char compCivAddr = 0xE1; // 0xE1 is new default, 0xE0 was before.
|
2018-11-07 23:54:03 +00:00
|
|
|
bool pttAllowed;
|
2018-06-19 19:58:52 +00:00
|
|
|
|
2021-02-10 17:32:56 +00:00
|
|
|
QString rigSerialPort;
|
|
|
|
quint32 rigBaudRate;
|
|
|
|
|
|
|
|
QString ip;
|
|
|
|
int cport;
|
|
|
|
int sport;
|
|
|
|
int aport;
|
|
|
|
QString username;
|
|
|
|
QString password;
|
|
|
|
|
|
|
|
QString serialPortError;
|
2018-06-19 19:58:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RIGCOMMANDER_H
|