From 53024ad4c5c6b18fc9a78448a05465a58912ab4e Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Tue, 2 Apr 2024 22:39:44 +0200 Subject: [PATCH] CW sending from rigctl Implement sending CW from rigctl. We add two pseudo states SENDCW and STOPCW. SENDCW is accompanied by a new rigState field cwmsg (as QString doesn't fit into qint64) that is set by setCwMsg. STOPCW sets a qint32 state that is always incremented to force a new state. On the rigCommander side, the two states are forwarded to the existing sendCW() and sendStopCW() methods. Close #126. --- rigcommander.cpp | 6 ++++++ rigctld.cpp | 13 +++++++++++-- rigstate.h | 23 ++++++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 881a3ed..cea1679 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -5644,6 +5644,12 @@ void rigCommander::stateUpdated() case KEYLIGHT: break; + case SENDCW: + sendCW(state.getCwMsg()); + break; + case STOPCW: + sendStopCW(); + break; } } ++i; diff --git a/rigctld.cpp b/rigctld.cpp index a693fa4..1e1557f 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -1163,9 +1163,18 @@ void rigCtlClient::socketReadyRead() { responseCode = -11; //Unimplemented } - else if (command.length() > 0 && (command[0] == "b" || command[0] == "send_morse")) + else if (command.length() > 1 && (command[0] == "b" || command[0] == "send_morse")) { - responseCode = -11; //Unimplemented + setCommand = true; + QStringList args = command; + args.removeFirst(); + QString cwmsg = args.join(" ").trimmed(); // join remaining arguments together + rigState->setCwMsg(SENDCW, cwmsg, true); + } + else if (command.length() > 0 && command[0] == "stop_morse") + { + setCommand = true; + rigState->set(STOPCW, rigState->getInt32(STOPCW) + 1, true); // increment counter force change } else if (command.length() > 1 && (command[0] == '\x87' || command[0] == "set_powerstat")) { diff --git a/rigstate.h b/rigstate.h index 6ed0657..7dbca5b 100644 --- a/rigstate.h +++ b/rigstate.h @@ -18,6 +18,7 @@ enum stateTypes { VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, PASSBAND, D FAGCFUNC, NBFUNC, COMPFUNC, VOXFUNC, TONEFUNC, TSQLFUNC, SBKINFUNC, FBKINFUNC, ANFFUNC, NRFUNC, AIPFUNC, APFFUNC, MONFUNC, MNFUNC,RFFUNC, AROFUNC, MUTEFUNC, VSCFUNC, REVFUNC, SQLFUNC, ABMFUNC, BCFUNC, MBCFUNC, RITFUNC, AFCFUNC, SATMODEFUNC, SCOPEFUNC, ANN, APO, BACKLIGHT, BEEP, TIME, BAT, KEYLIGHT, + SENDCW, STOPCW, RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER, }; @@ -120,6 +121,26 @@ public: } } + void setCwMsg(stateTypes s, QString x, bool u) { + if (((!u && !map[s]._updated) || (u))) { + _mutex.lock(); + //map[s]._value = quint64(x); + cwmsg = x; + map[s]._valid = true; + map[s]._updated = u; + map[s]._dateUpdated = QDateTime::currentDateTime(); + _mutex.unlock(); + } + } + + QString getCwMsg() { + _mutex.lock(); + QString msg = QString(cwmsg); // copy string + _mutex.unlock(); + + return msg; + } + bool getBool(stateTypes s) { return map[s]._value != 0; } quint8 getChar(stateTypes s) { return quint8(map[s]._value); } qint16 getInt16(stateTypes s) { return qint16(map[s]._value); } @@ -130,7 +151,7 @@ public: duplexMode getDuplex(stateTypes s) { return duplexMode(map[s]._value); } rigInput getInput(stateTypes s) { return rigInput(map[s]._value); } QMap map; - + QString cwmsg; private: //std::map > values;