implement logic to reuse the last properly decoded LC's instead of dropping the entire LDU; add undecodable LC counter;

This commit is contained in:
Bryan Biedenkapp
2018-11-12 13:22:18 -05:00
parent 9444ecad16
commit a06dbf9d55
2 changed files with 47 additions and 24 deletions

View File

@@ -57,6 +57,7 @@ m_networkWatchdog(1000U, 0U, 1500U),
m_rfFrames(0U),
m_rfBits(0U),
m_rfErrs(0U),
m_rfUndecodableLC(0U),
m_netFrames(0U),
m_netLost(0U),
m_rfDataFrames(0U),
@@ -64,6 +65,8 @@ m_nid(nac),
m_lastDUID(P25_DUID_TERM),
m_audio(),
m_rfData(),
m_rfLastLDU1(),
m_rfLastLDU2(),
m_netData(),
m_rfLSD(),
m_netLSD(),
@@ -123,6 +126,8 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
else
LogMessage("P25, transmission lost, %.1f seconds, BER: %.1f%%", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
LogMessage("P25, total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%", m_rfFrames, m_rfBits, m_rfUndecodableLC, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits));
if (m_netState == RS_NET_IDLE)
m_display->clearP25();
@@ -208,24 +213,24 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
m_rssiCount++;
}
if (duid == P25_DUID_HEADER) {
if (m_rfState == RS_RF_LISTENING) {
if (duid == P25_DUID_HEADER) {
if (m_rfState == RS_RF_LISTENING) {
m_rfData.reset();
bool ret = m_rfData.decodeHeader(data + 2U);
if (!ret) {
m_lastDUID = duid;
return false;
}
LogMessage("P25, received RF header");
m_lastDUID = duid;
return true;
}
}
else if (duid == P25_DUID_LDU1) {
if (m_rfState == RS_RF_LISTENING) {
m_rfData.reset();
bool ret = m_rfData.decodeHeader(data + 2U);
if (!ret) {
m_lastDUID = duid;
return false;
}
LogMessage("P25, received RF header");
m_lastDUID = duid;
return true;
}
}
else if (duid == P25_DUID_LDU1) {
if (m_rfState == RS_RF_LISTENING) {
//m_rfData.reset();
bool ret = m_rfData.decodeLDU1(data + 2U);
if (!ret) {
m_lastDUID = duid;
@@ -278,9 +283,14 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
if (m_rfState == RS_RF_AUDIO) {
bool ret = m_rfData.decodeLDU1(data + 2U);
if (!ret) {
return false;
}
if (!ret) {
LogWarning("P25, LDU1 undecodable LC, using last LDU1 LC");
m_rfData = m_rfLastLDU1;
m_rfUndecodableLC++;
}
else {
m_rfLastLDU1 = m_rfData;
}
// Regenerate Sync
CSync::addP25Sync(data + 2U);
@@ -327,9 +337,14 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
} else if (duid == P25_DUID_LDU2) {
if (m_rfState == RS_RF_AUDIO) {
bool ret = m_rfData.decodeLDU2(data + 2U);
if (!ret) {
return false;
}
if (!ret) {
LogWarning("P25, LDU2 undecodable LC, using last LDU2 LC");
m_rfData = m_rfLastLDU2;
m_rfUndecodableLC++;
}
else {
m_rfLastLDU2 = m_rfData;
}
writeNetwork(m_rfLDU, m_lastDUID, false);
@@ -479,6 +494,8 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
else
LogMessage("P25, received RF end of voice transmission, %.1f seconds, BER: %.1f%%", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
LogMessage("P25, total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%", m_rfFrames, m_rfBits, m_rfUndecodableLC, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits));
m_display->clearP25();
#if defined(DUMP_P25)
@@ -936,6 +953,9 @@ void CP25Control::createRFHeader()
m_rfFrames = 0U;
m_rfErrs = 0U;
m_rfUndecodableLC = 0U;
m_rfLastLDU1.reset();
m_rfLastLDU2.reset();
m_rfBits = 1U;
m_rfTimeout.start();
m_lastDUID = P25_DUID_HEADER;