fixup log messages; allow special CRC bypass conditions; add roamer reaccess flag to OSP_RFSS_STS_BCAST;

pull/48/head
Bryan Biedenkapp 2 years ago
parent 7513bccf52
commit 1c28bed062

@ -37,6 +37,16 @@ using namespace p25;
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
// ---------------------------------------------------------------------------
// Static Class Members
// ---------------------------------------------------------------------------
#if FORCE_TSBK_CRC_WARN
bool DataHeader::m_warnCRC = true;
#else
bool DataHeader::m_warnCRC = false;
#endif
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Public Class Members // Public Class Members
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -100,8 +110,25 @@ bool DataHeader::decode(const uint8_t* data, bool noTrellis)
else { else {
valid = m_trellis.decode12(data, m_data); valid = m_trellis.decode12(data, m_data);
} }
if (valid)
if (valid) {
valid = edac::CRC::checkCCITT162(m_data, P25_PDU_HEADER_LENGTH_BYTES); valid = edac::CRC::checkCCITT162(m_data, P25_PDU_HEADER_LENGTH_BYTES);
if (!valid) {
if (m_warnCRC) {
// if we're already warning instead of erroring CRC, don't announce invalid CRC in the
// case where no CRC is defined
if ((m_data[P25_PDU_HEADER_LENGTH_BYTES - 2U] != 0x00U) && (m_data[P25_PDU_HEADER_LENGTH_BYTES - 1U] != 0x00U)) {
LogWarning(LOG_P25, "DataHeader::decode(), failed CRC CCITT-162 check");
}
valid = true; // ignore CRC error
}
else {
LogError(LOG_P25, "DataHeader::decode(), failed CRC CCITT-162 check");
}
}
}
if (!valid) { if (!valid) {
return false; return false;
} }
@ -253,6 +280,8 @@ void DataHeader::encode(uint8_t* data, bool noTrellis)
if (!noTrellis) { if (!noTrellis) {
// encode 1/2 rate Trellis // encode 1/2 rate Trellis
m_trellis.encode12(header, data); m_trellis.encode12(header, data);
} else {
::memcpy(data, header, P25_PDU_HEADER_LENGTH_BYTES);
} }
} }

@ -71,6 +71,9 @@ namespace p25
/// <summary>Gets the count of block padding.</summary> /// <summary>Gets the count of block padding.</summary>
uint8_t getPadCount() const; uint8_t getPadCount() const;
/// <summary>Sets the flag indicating CRC-errors should be warnings and not errors.</summary>
static void setWarnCRC(bool warnCRC) { m_warnCRC = warnCRC; }
public: public:
/// <summary>Flag indicating if acknowledgement is needed.</summary> /// <summary>Flag indicating if acknowledgement is needed.</summary>
__PROPERTY(bool, ackNeeded, AckNeeded); __PROPERTY(bool, ackNeeded, AckNeeded);
@ -124,6 +127,8 @@ namespace p25
uint32_t m_dataOctets; uint32_t m_dataOctets;
uint8_t* m_data; uint8_t* m_data;
static bool m_warnCRC;
}; };
} // namespace data } // namespace data
} // namespace p25 } // namespace p25

@ -229,7 +229,12 @@ bool TSBK::decode(const uint8_t* data, uint8_t* payload, bool rawTSBK)
bool ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES); bool ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES);
if (!ret) { if (!ret) {
if (m_warnCRC) { if (m_warnCRC) {
LogWarning(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check"); // if we're already warning instead of erroring CRC, don't announce invalid CRC in the
// case where no CRC is defined
if ((tsbk[P25_TSBK_LENGTH_BYTES - 2U] != 0x00U) && (tsbk[P25_TSBK_LENGTH_BYTES - 1U] != 0x00U)) {
LogWarning(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check");
}
ret = true; // ignore CRC error ret = true; // ignore CRC error
} }
else { else {

@ -42,7 +42,8 @@ using namespace p25;
/// <summary> /// <summary>
/// Initializes a new instance of the OSP_RFSS_STS_BCAST class. /// Initializes a new instance of the OSP_RFSS_STS_BCAST class.
/// </summary> /// </summary>
OSP_RFSS_STS_BCAST::OSP_RFSS_STS_BCAST() : TSBK() OSP_RFSS_STS_BCAST::OSP_RFSS_STS_BCAST() : TSBK(),
m_roamerReaccess(false)
{ {
m_lco = TSBK_OSP_RFSS_STS_BCAST; m_lco = TSBK_OSP_RFSS_STS_BCAST;
} }
@ -76,7 +77,8 @@ void OSP_RFSS_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis)
tsbkValue = m_siteData.lra(); // Location Registration Area tsbkValue = m_siteData.lra(); // Location Registration Area
tsbkValue = (tsbkValue << 4) + tsbkValue = (tsbkValue << 4) +
(m_siteData.netActive()) ? P25_CFVA_NETWORK : 0U; // CFVA (m_roamerReaccess) ? 0x02U : 0x00U + // Roamer Reaccess Method
(m_siteData.netActive()) ? 0x01U : 0x00U; // Network Active
tsbkValue = (tsbkValue << 12) + m_siteData.sysId(); // System ID tsbkValue = (tsbkValue << 12) + m_siteData.sysId(); // System ID
tsbkValue = (tsbkValue << 8) + m_siteData.rfssId(); // RF Sub-System ID tsbkValue = (tsbkValue << 8) + m_siteData.rfssId(); // RF Sub-System ID
tsbkValue = (tsbkValue << 8) + m_siteData.siteId(); // Site ID tsbkValue = (tsbkValue << 8) + m_siteData.siteId(); // Site ID

@ -52,6 +52,10 @@ namespace p25
/// <summary>Returns a string that represents the current TSBK.</summary> /// <summary>Returns a string that represents the current TSBK.</summary>
virtual std::string toString(bool isp = false) override; virtual std::string toString(bool isp = false) override;
public:
/// <summary>Roamer Reaccess Method.</summary>
__PROPERTY(bool, roamerReaccess, RoamerReaccess);
}; };
} // namespace tsbk } // namespace tsbk
} // namespace lc } // namespace lc

@ -86,11 +86,16 @@ std::unique_ptr<TSBK> TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK)
bool ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES); bool ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES);
if (!ret) { if (!ret) {
if (m_warnCRC) { if (m_warnCRC) {
LogWarning(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check"); // if we're already warning instead of erroring CRC, don't announce invalid CRC in the
// case where no CRC is defined
if ((tsbk[P25_TSBK_LENGTH_BYTES - 2U] != 0x00U) && (tsbk[P25_TSBK_LENGTH_BYTES - 1U] != 0x00U)) {
LogWarning(LOG_P25, "TSBKFactory::createTSBK(), failed CRC CCITT-162 check");
}
ret = true; // ignore CRC error ret = true; // ignore CRC error
} }
else { else {
LogError(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check"); LogError(LOG_P25, "TSBKFactory::createTSBK(), failed CRC CCITT-162 check");
} }
} }
} }
@ -103,18 +108,18 @@ std::unique_ptr<TSBK> TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK)
try { try {
bool ret = trellis.decode12(raw, tsbk); bool ret = trellis.decode12(raw, tsbk);
if (!ret) { if (!ret) {
LogError(LOG_P25, "TSBK::decode(), failed to decode Trellis 1/2 rate coding"); LogError(LOG_P25, "TSBKFactory::createTSBK(), failed to decode Trellis 1/2 rate coding");
} }
if (ret) { if (ret) {
ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES); ret = edac::CRC::checkCCITT162(tsbk, P25_TSBK_LENGTH_BYTES);
if (!ret) { if (!ret) {
if (m_warnCRC) { if (m_warnCRC) {
LogWarning(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check"); LogWarning(LOG_P25, "TSBKFactory::createTSBK(), failed CRC CCITT-162 check");
ret = true; // ignore CRC error ret = true; // ignore CRC error
} }
else { else {
LogError(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check"); LogError(LOG_P25, "TSBKFactory::createTSBK(), failed CRC CCITT-162 check");
} }
} }
} }
@ -155,7 +160,7 @@ std::unique_ptr<TSBK> TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK)
mfId = P25_MFG_STANDARD; mfId = P25_MFG_STANDARD;
break; break;
default: default:
LogError(LOG_P25, "TSBK::decode(), unknown TSBK LCO value, mfId = $%02X, lco = $%02X", mfId, lco); LogError(LOG_P25, "TSBKFactory::createTSBK(), unknown TSBK LCO value, mfId = $%02X, lco = $%02X", mfId, lco);
break; break;
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.