kopia lustrzana https://gitlab.com/eliggett/wfview
start to move rigCaps to shared
rodzic
d120f028c2
commit
138a303724
|
@ -61,6 +61,7 @@ signals:
|
||||||
void haveCommand(funcs func, QVariant param, bool sub);
|
void haveCommand(funcs func, QVariant param, bool sub);
|
||||||
void sendValue(cacheItem item);
|
void sendValue(cacheItem item);
|
||||||
void cacheUpdated(cacheItem item);
|
void cacheUpdated(cacheItem item);
|
||||||
|
void rigCapsUpdated(rigCapabilities* caps);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Can be called directly or via emit.
|
// Can be called directly or via emit.
|
||||||
|
@ -87,7 +88,9 @@ private:
|
||||||
bool aborted=false;
|
bool aborted=false;
|
||||||
QWaitCondition waiting;
|
QWaitCondition waiting;
|
||||||
quint64 queueInterval=0; // Don't start the timer!
|
quint64 queueInterval=0; // Don't start the timer!
|
||||||
|
|
||||||
|
rigCapabilities* rigCaps = Q_NULLPTR; // Must be NULL until a radio is connected
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
@ -117,6 +120,8 @@ public:
|
||||||
QMultiMap <queuePriority,queueItem> getQueueItems();
|
QMultiMap <queuePriority,queueItem> getQueueItems();
|
||||||
void lockMutex() {mutex.lock();}
|
void lockMutex() {mutex.lock();}
|
||||||
void unlockMutex() {mutex.unlock();}
|
void unlockMutex() {mutex.unlock();}
|
||||||
|
void setRigCaps(rigCapabilities* caps) { rigCaps = caps; emit rigCapsUpdated(rigCaps);}
|
||||||
|
rigCapabilities* getRigCaps() { return rigCaps; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(queueItemType)
|
Q_DECLARE_METATYPE(queueItemType)
|
||||||
|
|
|
@ -16,3 +16,4 @@ Q_LOGGING_CATEGORY(logTcpServer, "tcpserver")
|
||||||
Q_LOGGING_CATEGORY(logUsbControl, "usbcontrol")
|
Q_LOGGING_CATEGORY(logUsbControl, "usbcontrol")
|
||||||
Q_LOGGING_CATEGORY(logAudioConverter, "audioconverter")
|
Q_LOGGING_CATEGORY(logAudioConverter, "audioconverter")
|
||||||
Q_LOGGING_CATEGORY(logCluster, "cluster")
|
Q_LOGGING_CATEGORY(logCluster, "cluster")
|
||||||
|
Q_LOGGING_CATEGORY(logTCIServer, "tci.server")
|
||||||
|
|
|
@ -19,6 +19,7 @@ Q_DECLARE_LOGGING_CATEGORY(logTcpServer)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(logUsbControl)
|
Q_DECLARE_LOGGING_CATEGORY(logUsbControl)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(logAudioConverter)
|
Q_DECLARE_LOGGING_CATEGORY(logAudioConverter)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(logCluster)
|
Q_DECLARE_LOGGING_CATEGORY(logCluster)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(logTCIServer)
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && !defined(__PRETTY_FUNCTION__)
|
#if defined(Q_OS_WIN) && !defined(__PRETTY_FUNCTION__)
|
||||||
|
|
|
@ -39,6 +39,7 @@ rigCommander::rigCommander(quint8 guid[GUIDLEN], QObject* parent) : QObject(pare
|
||||||
rigCommander::~rigCommander()
|
rigCommander::~rigCommander()
|
||||||
{
|
{
|
||||||
qInfo(logRig()) << "closing instance of rigCommander()";
|
qInfo(logRig()) << "closing instance of rigCommander()";
|
||||||
|
queue->setRigCaps(Q_NULLPTR); // Remove access to rigCaps
|
||||||
closeComm();
|
closeComm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1514,7 +1515,7 @@ void rigCommander::determineRigCaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
haveRigCaps = true;
|
haveRigCaps = true;
|
||||||
|
queue->setRigCaps(&rigCaps);
|
||||||
|
|
||||||
// Copy received guid so we can recognise this radio.
|
// Copy received guid so we can recognise this radio.
|
||||||
memcpy(rigCaps.guid, this->guid, GUIDLEN);
|
memcpy(rigCaps.guid, this->guid, GUIDLEN);
|
||||||
|
@ -2534,7 +2535,7 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub)
|
||||||
else if (!strcmp(value.typeName(),"uchar"))
|
else if (!strcmp(value.typeName(),"uchar"))
|
||||||
{
|
{
|
||||||
payload.append(bcdEncodeChar(value.value<uchar>()));
|
payload.append(bcdEncodeChar(value.value<uchar>()));
|
||||||
//qInfo(logRig()) << "**** setting uchar value" << funcString[func] << "val" << value.value<uchar>();
|
qInfo(logRig()) << "**** setting uchar value" << funcString[func] << "val" << value.value<uchar>();
|
||||||
}
|
}
|
||||||
else if (!strcmp(value.typeName(),"ushort"))
|
else if (!strcmp(value.typeName(),"ushort"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -789,6 +789,7 @@ int rigCtlClient::getCommand(QStringList& response, bool extended, const command
|
||||||
ret = RIG_OK;
|
ret = RIG_OK;
|
||||||
if (cmd.type == 'i') {
|
if (cmd.type == 'i') {
|
||||||
val.setValue(static_cast<uchar>(params[0].toInt()));
|
val.setValue(static_cast<uchar>(params[0].toInt()));
|
||||||
|
qInfo(logRigCtlD()) << "Setting char value" << val << "original" << params[0];
|
||||||
}
|
}
|
||||||
if (cmd.type == 's') {
|
if (cmd.type == 's') {
|
||||||
val.setValue(static_cast<short>(params[0].toInt()));
|
val.setValue(static_cast<short>(params[0].toInt()));
|
||||||
|
@ -986,7 +987,7 @@ int rigCtlClient::getSubCommand(QStringList& response, bool extended, const comm
|
||||||
// We are expecting a second argument to the command
|
// We are expecting a second argument to the command
|
||||||
QVariant val;
|
QVariant val;
|
||||||
if (sub[i].type == 'i') {
|
if (sub[i].type == 'i') {
|
||||||
uchar v = static_cast<uchar>(params[1].toInt(NULL,16));
|
uchar v = static_cast<uchar>(params[1].toInt());
|
||||||
if (params[0] == "FBKIN")
|
if (params[0] == "FBKIN")
|
||||||
v = (v << 1) & 0x02; // BREAKIN is not bool!
|
v = (v << 1) & 0x02; // BREAKIN is not bool!
|
||||||
val.setValue(v);
|
val.setValue(v);
|
||||||
|
@ -1036,7 +1037,7 @@ int rigCtlClient::getSubCommand(QStringList& response, bool extended, const comm
|
||||||
int val = item.value.toInt();
|
int val = item.value.toInt();
|
||||||
if (params[0] == "FBKIN")
|
if (params[0] == "FBKIN")
|
||||||
val = (val >> 1) & 0x01;
|
val = (val >> 1) & 0x01;
|
||||||
resp.append(QString::number(val,16)); // Base 16
|
resp.append(QString::number(val));
|
||||||
}
|
}
|
||||||
else if (sub[i].type == 'f') {
|
else if (sub[i].type == 'f') {
|
||||||
resp.append(QString::number(item.value.toFloat() / 255.0,'F',6));
|
resp.append(QString::number(item.value.toFloat() / 255.0,'F',6));
|
||||||
|
@ -1177,7 +1178,7 @@ int rigCtlClient::dumpState(QStringList &response, bool extended)
|
||||||
{
|
{
|
||||||
if (att == 0)
|
if (att == 0)
|
||||||
continue;
|
continue;
|
||||||
attens.append(QString("%1 ").arg(att,0,16));
|
attens.append(QString("%1 ").arg(att));
|
||||||
}
|
}
|
||||||
if (attens.endsWith(" "))
|
if (attens.endsWith(" "))
|
||||||
attens.chop(1);
|
attens.chop(1);
|
||||||
|
|
|
@ -88,6 +88,8 @@ bool tciAudioHandler::init(audioSetup setup)
|
||||||
connect((tciServer*)setup.tci, SIGNAL(sendTCIAudio(QByteArray)), this, SLOT(receiveTCIAudio(QByteArray)));
|
connect((tciServer*)setup.tci, SIGNAL(sendTCIAudio(QByteArray)), this, SLOT(receiveTCIAudio(QByteArray)));
|
||||||
//connect(this,SIGNAL(setupTxPacket(int)), (tciServer*)setup.tci, SLOT(setupTxPacket(int)));
|
//connect(this,SIGNAL(setupTxPacket(int)), (tciServer*)setup.tci, SLOT(setupTxPacket(int)));
|
||||||
//emit setupTxPacket((nativeFormat.bytesForDuration(setup.blockSize * 1000)*2)/sizeof(float));
|
//emit setupTxPacket((nativeFormat.bytesForDuration(setup.blockSize * 1000)*2)/sizeof(float));
|
||||||
|
} else {
|
||||||
|
qCritical(logAudio()) << "***** TCI NOT FOUND *****";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
118
tciserver.cpp
118
tciserver.cpp
|
@ -4,32 +4,92 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Based on TCI v1.9 commands
|
||||||
static const tciCommandStruct tci_commands[] =
|
static const tciCommandStruct tci_commands[] =
|
||||||
{
|
{
|
||||||
{ "vfo_limits", funcNone, 'l', 'l'},
|
// u=uchar s=short f=float b=bool x=hz m=mode s=string
|
||||||
{ "if_limits", funcNone, 'l', 'l'},
|
{ "vfo_limits", funcNone, 'x', 'x'},
|
||||||
|
{ "if_limits", funcNone, 'x', 'x'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "trx_count", funcNone, 'u'},
|
||||||
{ "channel_count", funcNone, 'u'},
|
{ "channel_count", funcNone, 'u'},
|
||||||
{ "device", funcNone, 't'},
|
{ "device", funcNone, 's'},
|
||||||
{ "receive_only", funcNone, 'u'},
|
{ "receive_only", funcNone, 'b'},
|
||||||
{ "modulations_list", funcNone, 's'},
|
{ "modulations_list", funcNone, 's'},
|
||||||
|
{ "protocol", funcNone, 's'},
|
||||||
|
{ "ready", funcNone },
|
||||||
|
{ "start", funcNone },
|
||||||
|
{ "stop", funcNone },
|
||||||
|
{ "dds", funcNone, 'u','x'},
|
||||||
|
{ "if", funcNone, 'u','u','x'},
|
||||||
|
{ "vfo", funcNone, 'u','u','x'},
|
||||||
|
{ "modulation", funcNone, 'u','s'},
|
||||||
|
{ "trx", funcNone, 'u'},
|
||||||
|
{ "tune", funcNone, 'u'},
|
||||||
|
{ "drive", funcNone, 'u'},
|
||||||
|
{ "tune_drive", funcNone, 'u'},
|
||||||
|
{ "rit_enable", funcNone, 'u'},
|
||||||
|
{ "xit_enable", funcNone, 'u'},
|
||||||
|
{ "split_enable", funcNone, 'u'},
|
||||||
|
{ "rit_offset", funcNone, 'u'},
|
||||||
|
{ "xit_offset", funcNone, 'u'},
|
||||||
|
{ "rx_channel_enable", funcNone, 'u'},
|
||||||
|
{ "rx_filter_band", funcNone, 'u'},
|
||||||
|
{ "cw_macros_speed", funcNone, 'u'},
|
||||||
|
{ "cw_macros_delay", funcNone, 'u'},
|
||||||
|
{ "cw_keyer_speed", funcNone, 'u'},
|
||||||
|
{ "volume", funcNone, 'u'},
|
||||||
|
{ "mute", funcNone, 'u'},
|
||||||
|
{ "rx_mute", funcNone, 'u'},
|
||||||
|
{ "rx_volume", funcNone, 'u'},
|
||||||
|
{ "rx_balance", funcNone, 'u'},
|
||||||
|
{ "mon_volume", funcNone, 'u'},
|
||||||
|
{ "mon_enable", funcNone, 'u'},
|
||||||
|
{ "agc_mode", funcNone, 'u'},
|
||||||
|
{ "agc_gain", funcNone, 'u'},
|
||||||
|
{ "rx_nb_enable", funcNone, 'u'},
|
||||||
|
{ "rx_nb_param", funcNone, 'u'},
|
||||||
|
{ "rx_bin_enable", funcNone, 'u'},
|
||||||
|
{ "rx_nr_enable", funcNone, 'u'},
|
||||||
|
{ "rx_anc_enable", funcNone, 'u'},
|
||||||
|
{ "rx_anf_enable", funcNone, 'u'},
|
||||||
|
{ "rx_apf_enable", funcNone, 'u'},
|
||||||
|
{ "rx_dse_enable", funcNone, 'u'},
|
||||||
|
{ "rx_nf_enable", funcNone, 'u'},
|
||||||
|
{ "lock", funcNone, 'u'},
|
||||||
|
{ "sql_enable", funcNone, 'u'},
|
||||||
|
{ "sql_level", funcNone, 'u'},
|
||||||
{ "tx_enable", funcNone, 'u','u'},
|
{ "tx_enable", funcNone, 'u','u'},
|
||||||
{ "ready", funcNone, },
|
{ "cw_macros_speed_up", funcNone, 'u','u'},
|
||||||
|
{ "cw_macros_speed_down", funcNone, 'u','u'},
|
||||||
|
{ "spot", funcNone, 'u','u'},
|
||||||
|
{ "spot_delete", funcNone, 'u','u'},
|
||||||
|
{ "iq_samplerate", funcNone, 'u'},
|
||||||
|
{ "audio_samplerate", funcNone, 'u'},
|
||||||
|
{ "iq_start", funcNone, 'u'},
|
||||||
|
{ "iq_stop", funcNone, 'u'},
|
||||||
|
{ "audio_start", funcNone, 'u'},
|
||||||
|
{ "audio_stop", funcNone, 'u'},
|
||||||
|
{ "line_out_start", funcNone, 'u'},
|
||||||
|
{ "line_out_stop", funcNone, 'u'},
|
||||||
|
{ "line_out_recorder_start", funcNone, 'u'},
|
||||||
|
{ "line_out_recorder_save", funcNone, 'u'},
|
||||||
|
{ "line_out_recorder_start", funcNone, 'u'},
|
||||||
|
{ "clicked_on_spot", funcNone, 'u'},
|
||||||
|
{ "rx_clicked_on_spot", funcNone, 'u'},
|
||||||
{ "tx_footswitch", funcNone, 'u','b'},
|
{ "tx_footswitch", funcNone, 'u','b'},
|
||||||
{ "start", funcNone },
|
{ "tx_frequency", funcNone, 'u','b'},
|
||||||
{ "stop", funcNone },
|
{ "app_focus", funcNone, 'u','b'},
|
||||||
{ "dds", funcNone, 'u','u'},
|
{ "set_in_focus", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "keyer", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "rx_sensors_enable", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "tx_sensors_enable", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "rx_sensors", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "tx_sensors", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "audio_stream_sample_type", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "audio_stream_channels", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "audio_stream_samples", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "digl_offset", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
{ "digu_offset", funcNone, 'u','b'},
|
||||||
{ "trx_count", funcNone, 'u'},
|
|
||||||
{ "", funcNone, 0x0 },
|
{ "", funcNone, 0x0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,6 +108,8 @@ void tciServer::init(quint16 port) {
|
||||||
connect (server, &QWebSocketServer::newConnection, this, &tciServer::onNewConnection);
|
connect (server, &QWebSocketServer::newConnection, this, &tciServer::onNewConnection);
|
||||||
connect (server, &QWebSocketServer::closed, this, &tciServer::socketDisconnected);
|
connect (server, &QWebSocketServer::closed, this, &tciServer::socketDisconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->setObjectName("TCI Server");
|
||||||
queue = cachingQueue::getInstance(this);
|
queue = cachingQueue::getInstance(this);
|
||||||
|
|
||||||
connect(queue,SIGNAL(cacheUpdated(cacheItem)),this,SLOT(receiveCache(cacheItem)));
|
connect(queue,SIGNAL(cacheUpdated(cacheItem)),this,SLOT(receiveCache(cacheItem)));
|
||||||
|
@ -80,15 +142,25 @@ tciServer::~tciServer()
|
||||||
it.key()->deleteLater();
|
it.key()->deleteLater();
|
||||||
it = clients.erase(it);
|
it = clients.erase(it);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//qDeleteAll(clients.begin(), clients.end());
|
void tciServer::receiveRigCaps(rigCapabilities *caps)
|
||||||
|
{
|
||||||
|
rigCaps = caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tciServer::onNewConnection()
|
void tciServer::onNewConnection()
|
||||||
{
|
{
|
||||||
|
|
||||||
this->setObjectName("TCI Server");
|
|
||||||
QWebSocket *pSocket = server->nextPendingConnection();
|
QWebSocket *pSocket = server->nextPendingConnection();
|
||||||
|
if (rigCaps == Q_NULLPTR)
|
||||||
|
{
|
||||||
|
qWarning(logTCIServer()) << "No current rig connection, denying connection request.";
|
||||||
|
pSocket->abort();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qInfo(logTCIServer()) << "Got rigCaps for" << rigCaps->modelName;
|
||||||
|
|
||||||
connect(pSocket, &QWebSocket::textMessageReceived, this, &tciServer::processIncomingTextMessage);
|
connect(pSocket, &QWebSocket::textMessageReceived, this, &tciServer::processIncomingTextMessage);
|
||||||
connect(pSocket, &QWebSocket::binaryMessageReceived, this, &tciServer::processIncomingBinaryMessage);
|
connect(pSocket, &QWebSocket::binaryMessageReceived, this, &tciServer::processIncomingBinaryMessage);
|
||||||
|
@ -98,7 +170,7 @@ void tciServer::onNewConnection()
|
||||||
clients.insert(pSocket,connStatus());
|
clients.insert(pSocket,connStatus());
|
||||||
pSocket->sendTextMessage(QString("protocol:WFVIEW,1.5;\n"));
|
pSocket->sendTextMessage(QString("protocol:WFVIEW,1.5;\n"));
|
||||||
pSocket->sendTextMessage(QString("device:WFVIEW;\n"));
|
pSocket->sendTextMessage(QString("device:WFVIEW;\n"));
|
||||||
pSocket->sendTextMessage(QString("receive_only:false;\n"));
|
pSocket->sendTextMessage(QString("receive_only:%0;\n").arg(rigCaps->hasTransmit?"false":"true"));
|
||||||
pSocket->sendTextMessage(QString("trx_count:1;\n"));
|
pSocket->sendTextMessage(QString("trx_count:1;\n"));
|
||||||
pSocket->sendTextMessage(QString("channel_count:1;\n"));
|
pSocket->sendTextMessage(QString("channel_count:1;\n"));
|
||||||
pSocket->sendTextMessage(QString("vfo_limits:10000,52000000;\n"));
|
pSocket->sendTextMessage(QString("vfo_limits:10000,52000000;\n"));
|
||||||
|
|
|
@ -80,6 +80,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void receiveTCIAudio(audioPacket audio);
|
void receiveTCIAudio(audioPacket audio);
|
||||||
|
void receiveRigCaps(rigCapabilities* caps);
|
||||||
void init(quint16 port);
|
void init(quint16 port);
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ private:
|
||||||
QByteArray rxAudioData;
|
QByteArray rxAudioData;
|
||||||
QByteArray txAudioData;
|
QByteArray txAudioData;
|
||||||
QByteArray txChrono;
|
QByteArray txChrono;
|
||||||
|
rigCapabilities* rigCaps = Q_NULLPTR;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TCISERVER_H
|
#endif // TCISERVER_H
|
||||||
|
|
|
@ -354,6 +354,13 @@ void wfmain::openRig()
|
||||||
ui->connectBtn->setText("Cancel connection"); // We are attempting to connect
|
ui->connectBtn->setText("Cancel connection"); // We are attempting to connect
|
||||||
connStatus = connConnecting;
|
connStatus = connConnecting;
|
||||||
|
|
||||||
|
// PET: This could be in a better place?
|
||||||
|
if (prefs.audioSystem == tciAudio)
|
||||||
|
{
|
||||||
|
prefs.rxSetup.tci = tci;
|
||||||
|
prefs.txSetup.tci = tci;
|
||||||
|
}
|
||||||
|
|
||||||
makeRig();
|
makeRig();
|
||||||
|
|
||||||
if (prefs.enableLAN)
|
if (prefs.enableLAN)
|
||||||
|
@ -1750,6 +1757,7 @@ void wfmain::loadSettings()
|
||||||
tciThread = new QThread(this);
|
tciThread = new QThread(this);
|
||||||
tciThread->setObjectName("TCIServer()");
|
tciThread->setObjectName("TCIServer()");
|
||||||
tci->moveToThread(tciThread);
|
tci->moveToThread(tciThread);
|
||||||
|
connect(queue,SIGNAL(rigCapsUpdated(rigCapabilities*)),tci, SLOT(receiveRigCaps(rigCapabilities*)));
|
||||||
connect(this,SIGNAL(tciInit(quint16)),tci, SLOT(init(quint16)));
|
connect(this,SIGNAL(tciInit(quint16)),tci, SLOT(init(quint16)));
|
||||||
connect(tciThread, SIGNAL(finished()), tci, SLOT(deleteLater()));
|
connect(tciThread, SIGNAL(finished()), tci, SLOT(deleteLater()));
|
||||||
tciThread->start(QThread::TimeCriticalPriority);
|
tciThread->start(QThread::TimeCriticalPriority);
|
||||||
|
|
Ładowanie…
Reference in New Issue