alter how CRC values are returned from non-table based CRC calculators; fix CRC source for transmitted NXDN CAC frames;

3.0-rcon_maint 2023-03-07
Bryan Biedenkapp 3 years ago
parent 1ecbcdddc1
commit cb259cdc73

@ -513,8 +513,8 @@ bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength)
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
void CRC::addCRC6(uint8_t* in, uint32_t bitLength)
/// <returns>6-bit CRC.</returns>
uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -530,6 +530,7 @@ void CRC::addCRC6(uint8_t* in, uint32_t bitLength)
#if DEBUG_CRC
LogDebug(LOG_HOST, "CRC::addCRC6(), crc = $%04X, bitlen = %u", crc[0U], bitLength);
#endif
return crc[0U];
}
/// <summary>
@ -569,8 +570,8 @@ bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength)
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
void CRC::addCRC12(uint8_t* in, uint32_t bitLength)
/// <returns>12-bit CRC.</returns>
uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -589,6 +590,7 @@ void CRC::addCRC12(uint8_t* in, uint32_t bitLength)
#if DEBUG_CRC
LogDebug(LOG_HOST, "CRC::addCRC12(), crc = $%04X, bitlen = %u", crc, bitLength);
#endif
return crc;
}
/// <summary>
@ -628,8 +630,8 @@ bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength)
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
void CRC::addCRC15(uint8_t* in, uint32_t bitLength)
/// <returns>15-bit CRC.</returns>
uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -648,6 +650,7 @@ void CRC::addCRC15(uint8_t* in, uint32_t bitLength)
#if DEBUG_CRC
LogDebug(LOG_HOST, "CRC::addCRC15(), crc = $%04X, bitlen = %u", crc, bitLength);
#endif
return crc;
}
/// <summary>
@ -687,8 +690,8 @@ bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength)
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
void CRC::addCRC16(uint8_t* in, uint32_t bitLength)
/// <returns>16-bit CRC.</returns>
uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -707,6 +710,7 @@ void CRC::addCRC16(uint8_t* in, uint32_t bitLength)
#if DEBUG_CRC
LogDebug(LOG_HOST, "CRC::addCRC16(), crc = $%04X, bitlen = %u", crc, bitLength);
#endif
return crc;
}
// ---------------------------------------------------------------------------

@ -71,22 +71,22 @@ namespace edac
/// <summary>Check 6-bit CRC.</summary>
static bool checkCRC6(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 6-bit CRC.</summary>
static void addCRC6(uint8_t* in, uint32_t bitLength);
static uint8_t addCRC6(uint8_t* in, uint32_t bitLength);
/// <summary>Check 12-bit CRC.</summary>
static bool checkCRC12(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 12-bit CRC.</summary>
static void addCRC12(uint8_t* in, uint32_t bitLength);
static uint16_t addCRC12(uint8_t* in, uint32_t bitLength);
/// <summary>Check 15-bit CRC.</summary>
static bool checkCRC15(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 15-bit CRC.</summary>
static void addCRC15(uint8_t* in, uint32_t bitLength);
static uint16_t addCRC15(uint8_t* in, uint32_t bitLength);
/// <summary>Check 16-bit CRC-CCITT.</summary>
static bool checkCRC16(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 15-bit CRC.</summary>
static void addCRC16(uint8_t* in, uint32_t bitLength);
static uint16_t addCRC16(uint8_t* in, uint32_t bitLength);
private:
/// <summary></summary>

@ -275,7 +275,7 @@ void CAC::encode(uint8_t* data) const
WRITE_BIT(buffer, i, b);
}
CRC::addCRC16(buffer, NXDN_CAC_LENGTH_BITS);
uint16_t crc = CRC::addCRC16(buffer, NXDN_CAC_LENGTH_BITS);
#if DEBUG_NXDN_CAC
Utils::dump(2U, "Encoded CAC", buffer, NXDN_CAC_FEC_LENGTH_BYTES);
@ -324,8 +324,8 @@ void CAC::encode(uint8_t* data) const
control[0U] = ((m_idleBusy ? 0x03U : 0x01U) << 6) + ((m_txContinuous ? 0x03U : 0x01U) << 4) +
(parity << 2) + ((m_receive ? 0x03U : 0x01U));
control[1U] = (m_rxCRC >> 8U) & 0xFFU;
control[2U] = (m_rxCRC >> 0U) & 0xFFU;
control[1U] = (crc >> 8U) & 0xFFU;
control[2U] = (crc >> 0U) & 0xFFU;
for (uint32_t i = 0U; i < NXDN_CAC_E_POST_FIELD_BITS; i++) {
uint32_t n = i + NXDN_FSW_LENGTH_BITS + NXDN_LICH_LENGTH_BITS + NXDN_CAC_FEC_LENGTH_BITS;

Loading…
Cancel
Save

Powered by TurnKey Linux.