protocol 2 alex
This commit is contained in:
@@ -2121,23 +2121,29 @@ float DataEngine::getFilterSizeCalibrationOffset() {
|
||||
|
||||
void DataEngine::searchHpsdrNetworkDevices() {
|
||||
|
||||
if (!m_discoverer) createDiscoverer();
|
||||
for (int protocolVersion = 1; protocolVersion <= 2; ++protocolVersion) {
|
||||
|
||||
// HPSDR network IO thread
|
||||
if (!startDiscoverer(QThread::NormalPriority)) {
|
||||
m_discoveryProtocol = protocolVersion;
|
||||
|
||||
DATA_ENGINE_DEBUG << "HPSDR network discovery thread could not be started.";
|
||||
return;
|
||||
if (!m_discoverer)
|
||||
createDiscoverer();
|
||||
|
||||
if (!startDiscoverer(QThread::NormalPriority)) {
|
||||
|
||||
DATA_ENGINE_DEBUG << "HPSDR network discovery thread could not be started.";
|
||||
return;
|
||||
}
|
||||
|
||||
io.networkIOMutex.lock();
|
||||
io.devicefound.wait(&io.networkIOMutex);
|
||||
const int devicesFound = set->getHpsdrNetworkDevices();
|
||||
io.networkIOMutex.unlock();
|
||||
|
||||
stopDiscoverer();
|
||||
|
||||
if (devicesFound > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
io.networkIOMutex.lock();
|
||||
io.devicefound.wait(&io.networkIOMutex);
|
||||
|
||||
//m_discoverer->findHPSDRDevices();
|
||||
|
||||
// stop the discovery thread
|
||||
io.networkIOMutex.unlock();
|
||||
stopDiscoverer();
|
||||
}
|
||||
|
||||
void DataEngine::setHPSDRDeviceNumber(int value) {
|
||||
|
||||
@@ -25,6 +25,74 @@ static const int kProtocol2GeneralPacketSize = 60;
|
||||
static const int kProtocol2HighPriorityPacketSize = 1444;
|
||||
static const int kProtocol2StatusPacketMinSize = 31;
|
||||
|
||||
quint32 alexFilterWordForFrequency(Settings *set, long frequency, int currentBand) {
|
||||
|
||||
if (!set || !set->getAlexPresence())
|
||||
return 0;
|
||||
|
||||
quint32 alexWord = 0;
|
||||
const quint16 alexConfig = set->getAlexConfig();
|
||||
const QList<long> hpfLo = set->getHPFLoFrequencies();
|
||||
const QList<long> hpfHi = set->getHPFHiFrequencies();
|
||||
const QList<long> lpfLo = set->getLPFLoFrequencies();
|
||||
const QList<long> lpfHi = set->getLPFHiFrequencies();
|
||||
const QList<int> alexStates = set->getAlexStates();
|
||||
|
||||
if (currentBand >= 0 && currentBand < alexStates.size()) {
|
||||
|
||||
const int rxAntenna = alexStates.at(currentBand) & 0x03;
|
||||
if (rxAntenna >= 1 && rxAntenna <= 3)
|
||||
alexWord |= (1u << (23 + rxAntenna));
|
||||
}
|
||||
|
||||
if ((alexConfig & 0x02) != 0) {
|
||||
alexWord |= (1u << 12);
|
||||
}
|
||||
else if (hpfLo.size() >= 6 && hpfHi.size() >= 6) {
|
||||
|
||||
if (frequency >= hpfLo.at(0) && frequency <= hpfHi.at(0))
|
||||
alexWord |= (1u << 6);
|
||||
else if (frequency >= hpfLo.at(1) && frequency <= hpfHi.at(1))
|
||||
alexWord |= (1u << 5);
|
||||
else if (frequency >= hpfLo.at(2) && frequency <= hpfHi.at(2))
|
||||
alexWord |= (1u << 4);
|
||||
else if (frequency >= hpfLo.at(3) && frequency <= hpfHi.at(3))
|
||||
alexWord |= (1u << 1);
|
||||
else if (frequency >= hpfLo.at(4) && frequency <= hpfHi.at(4))
|
||||
alexWord |= (1u << 2);
|
||||
else if (frequency >= hpfLo.at(5) && frequency <= hpfHi.at(5)) {
|
||||
|
||||
if ((alexConfig & 0x04) != 0)
|
||||
alexWord |= (1u << 3);
|
||||
else
|
||||
alexWord |= (1u << 12);
|
||||
}
|
||||
else {
|
||||
alexWord |= (1u << 12);
|
||||
}
|
||||
}
|
||||
|
||||
if (lpfLo.size() >= 7 && lpfHi.size() >= 7) {
|
||||
|
||||
if (frequency >= lpfLo.at(0) && frequency <= lpfHi.at(0))
|
||||
alexWord |= (1u << 23);
|
||||
else if (frequency >= lpfLo.at(1) && frequency <= lpfHi.at(1))
|
||||
alexWord |= (1u << 22);
|
||||
else if (frequency >= lpfLo.at(2) && frequency <= lpfHi.at(2))
|
||||
alexWord |= (1u << 21);
|
||||
else if (frequency >= lpfLo.at(3) && frequency <= lpfHi.at(3))
|
||||
alexWord |= (1u << 20);
|
||||
else if (frequency >= lpfLo.at(4) && frequency <= lpfHi.at(4))
|
||||
alexWord |= (1u << 31);
|
||||
else if (frequency >= lpfLo.at(5) && frequency <= lpfHi.at(5))
|
||||
alexWord |= (1u << 30);
|
||||
else
|
||||
alexWord |= (1u << 29);
|
||||
}
|
||||
|
||||
return alexWord;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -275,6 +343,7 @@ void Protocol2DataPath::sendGeneralPacket() {
|
||||
datagram[26] = 0x10;
|
||||
datagram[27] = 20;
|
||||
datagram[28] = 32;
|
||||
datagram[59] = set->getAlexPresence() ? 0x01 : 0x00;
|
||||
|
||||
if (m_commandSocket->writeDatagram(datagram, set->getCurrentMetisCard().ip_address, DEVICE_PORT) >= 0)
|
||||
++m_generalSequence;
|
||||
@@ -319,6 +388,10 @@ void Protocol2DataPath::sendHighPriorityPacket(bool run) {
|
||||
QByteArray datagram(kProtocol2HighPriorityPacketSize, 0x00);
|
||||
const QList<long> frequencies = set->getCtrFrequencies();
|
||||
const int receivers = qMax(1, set->getNumberOfReceivers());
|
||||
const int currentReceiver = set->getCurrentReceiver();
|
||||
const int currentBand = (int)set->getCurrentHamBand(currentReceiver);
|
||||
const long currentVfoFrequency = set->getVfoFrequency(currentReceiver);
|
||||
const quint32 alexWord = alexFilterWordForFrequency(set, currentVfoFrequency, currentBand);
|
||||
|
||||
datagram[0] = (m_highPrioritySequence >> 24) & 0xFF;
|
||||
datagram[1] = (m_highPrioritySequence >> 16) & 0xFF;
|
||||
@@ -337,6 +410,14 @@ void Protocol2DataPath::sendHighPriorityPacket(bool run) {
|
||||
datagram[offset + 3] = encodedFrequency & 0xFF;
|
||||
}
|
||||
|
||||
if (set->getAlexPresence()) {
|
||||
|
||||
datagram[1432] = (alexWord >> 24) & 0xFF;
|
||||
datagram[1433] = (alexWord >> 16) & 0xFF;
|
||||
datagram[1434] = (alexWord >> 8) & 0xFF;
|
||||
datagram[1435] = alexWord & 0xFF;
|
||||
}
|
||||
|
||||
if (m_commandSocket->writeDatagram(datagram, set->getCurrentMetisCard().ip_address, HIGH_PRIORITY_FROM_HOST_PORT) >= 0)
|
||||
++m_highPrioritySequence;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user