fix newlines being injected for symbole dumps; fix issue initializing and deleting the MI buffer for the PI header; fix the CRC-CCITT calculations for the PI header;

pull/1/head
Bryan Biedenkapp 5 years ago
parent 30513bb1d2
commit a91fde54be

@ -177,7 +177,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng
microslotHeader += temp; microslotHeader += temp;
} }
::Log(2U, "SYMBOLS", "MCR: % s\r\n", microslotHeader.c_str()); ::Log(2U, "SYMBOLS", "MCR: % s", microslotHeader.c_str());
uint32_t bufLen = length; uint32_t bufLen = length;
while (bufLen > 0U) { while (bufLen > 0U) {
@ -207,7 +207,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng
symOffset += 9; symOffset += 9;
} }
::Log(2U, "SYMBOLS", "%03u: %s\r\n", count, output.c_str()); ::Log(2U, "SYMBOLS", "%03u: %s", count, output.c_str());
offset += 18U; offset += 18U;
count += 2U; count += 2U;

@ -206,24 +206,23 @@ bool VoicePacket::process(uint8_t* data, uint32_t len)
lc::FullLC fullLC; lc::FullLC fullLC;
lc::PrivacyLC* lc = fullLC.decodePI(data + 2U); lc::PrivacyLC* lc = fullLC.decodePI(data + 2U);
/* if (lc == NULL) {
if (lc == NULL) LogWarning(LOG_RF, "DMR Slot %u, DT_VOICE_PI_HEADER, bad LC received, replacing", m_slot->m_slotNo);
return false; lc = new lc::PrivacyLC();
*/ lc->setDstId(m_slot->m_rfLC->getDstId());
}
m_slot->m_rfPrivacyLC = lc; m_slot->m_rfPrivacyLC = lc;
// Regenerate the LC data
fullLC.encodePI(*m_slot->m_rfPrivacyLC, data + 2U);
// Regenerate the Slot Type // Regenerate the Slot Type
slotType.encode(data + 2U); slotType.encode(data + 2U);
// Convert the Data Sync to be from the BS or MS as needed // Convert the Data Sync to be from the BS or MS as needed
Sync::addDMRDataSync(data + 2U, m_slot->m_duplex); Sync::addDMRDataSync(data + 2U, m_slot->m_duplex);
// Regenerate the payload and the BPTC (196,96) FEC
edac::BPTC19696 bptc;
uint8_t payload[12U];
bptc.decode(data + 2U, payload);
bptc.encode(payload, data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -739,15 +738,17 @@ void VoicePacket::processNetwork(const data::Data& dmrData)
lc::FullLC fullLC; lc::FullLC fullLC;
lc::PrivacyLC* lc = fullLC.decodePI(data + 2U); lc::PrivacyLC* lc = fullLC.decodePI(data + 2U);
/*
if (lc == NULL) { if (lc == NULL) {
LogWarning(LOG_NET, "DMR Slot %u, DT_VOICE_PI_HEADER, bad LC received from the network, replacing", m_slot->m_slotNo); LogWarning(LOG_NET, "DMR Slot %u, DT_VOICE_PI_HEADER, bad LC received, replacing", m_slot->m_slotNo);
lc = new lc::PrivacyLC(); lc = new lc::PrivacyLC();
lc->setDstId(dmrData.getDstId()); lc->setDstId(dmrData.getDstId());
} }
*/
m_slot->m_netPrivacyLC = lc; m_slot->m_netPrivacyLC = lc;
// Regenerate the LC data
fullLC.encodePI(*m_slot->m_netPrivacyLC, data + 2U);
// Regenerate the Slot Type // Regenerate the Slot Type
SlotType slotType; SlotType slotType;
slotType.setColorCode(m_slot->m_colorCode); slotType.setColorCode(m_slot->m_colorCode);
@ -757,12 +758,6 @@ void VoicePacket::processNetwork(const data::Data& dmrData)
// Convert the Data Sync to be from the BS or MS as needed // Convert the Data Sync to be from the BS or MS as needed
Sync::addDMRDataSync(data + 2U, m_slot->m_duplex); Sync::addDMRDataSync(data + 2U, m_slot->m_duplex);
// Regenerate the payload and the BPTC (196,96) FEC
edac::BPTC19696 bptc;
uint8_t payload[12U];
bptc.decode(data + 2U, payload);
bptc.encode(payload, data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;

@ -155,9 +155,19 @@ PrivacyLC* FullLC::decodePI(const uint8_t* data)
uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES];
m_bptc.decode(data, lcData); m_bptc.decode(data, lcData);
// check CRC-CCITT 16,2 // make sure the CRC-CCITT 16 was actually included (the network tends to zero the CRC)
// if (!edac::CRC::checkCCITT162(lcData, DMR_LC_HEADER_LENGTH_BYTES)) if (lcData[10U] != 0x00U && lcData[11U] != 0x00U) {
// return NULL; // validate the CRC-CCITT 16
lcData[10U] ^= PI_HEADER_CRC_MASK[0U];
lcData[11U] ^= PI_HEADER_CRC_MASK[1U];
if (!edac::CRC::checkCCITT162(lcData, DMR_LC_HEADER_LENGTH_BYTES))
return NULL;
// restore the checksum
lcData[10U] ^= PI_HEADER_CRC_MASK[0U];
lcData[11U] ^= PI_HEADER_CRC_MASK[1U];
}
return new PrivacyLC(lcData); return new PrivacyLC(lcData);
} }
@ -175,9 +185,15 @@ void FullLC::encodePI(const PrivacyLC& lc, uint8_t* data)
uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES];
lc.getData(lcData); lc.getData(lcData);
// encode CRC-CCITT 16,2 // compute CRC-CCITT 16
// uint8_t parity[2U]; lcData[10U] ^= PI_HEADER_CRC_MASK[0U];
// edac::CRC::addCCITT162(lcData, 9U); lcData[11U] ^= PI_HEADER_CRC_MASK[1U];
edac::CRC::addCCITT162(lcData, DMR_LC_HEADER_LENGTH_BYTES);
// restore the checksum
lcData[10U] ^= PI_HEADER_CRC_MASK[0U];
lcData[11U] ^= PI_HEADER_CRC_MASK[1U];
// encode BPTC (196,96) FEC // encode BPTC (196,96) FEC
m_bptc.encode(lcData, data); m_bptc.encode(lcData, data);

@ -127,7 +127,7 @@ PrivacyLC::PrivacyLC() :
m_kId(0U), m_kId(0U),
m_mi(NULL) m_mi(NULL)
{ {
/* stub */ m_mi = new uint8_t[DMR_MI_LENGTH_BYTES];
} }
/// <summary> /// <summary>
@ -135,7 +135,7 @@ PrivacyLC::PrivacyLC() :
/// </summary> /// </summary>
PrivacyLC::~PrivacyLC() PrivacyLC::~PrivacyLC()
{ {
/* stub */ delete m_mi;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save

Powered by TurnKey Linux.