add support to selectively enable Trellis debug messages; fix issue where P25 Trellis checkCode12 was not appropriately traversing the entire trellis;

pull/22/head
Bryan Biedenkapp 3 years ago
parent 4f5f35ef94
commit 01c7b38a36

@ -209,6 +209,7 @@ option(FORCE_TSBK_CRC_WARN "" off)
option(DEBUG_P25_DFSI "" off) option(DEBUG_P25_DFSI "" off)
option(DEBUG_RINGBUFFER "" off) option(DEBUG_RINGBUFFER "" off)
option(DEBUG_HTTP_PAYLOAD "" off) option(DEBUG_HTTP_PAYLOAD "" off)
option(DEBUG_TRELLIS "" off)
if (DEBUG_DMR_PDU_DATA) if (DEBUG_DMR_PDU_DATA)
add_definitions(-DDEBUG_DMR_PDU_DATA) add_definitions(-DDEBUG_DMR_PDU_DATA)
@ -273,6 +274,9 @@ endif (DEBUG_RINGBUFFER)
if (DEBUG_HTTP_PAYLOAD) if (DEBUG_HTTP_PAYLOAD)
add_definitions(-DDEBUG_HTTP_PAYLOAD) add_definitions(-DDEBUG_HTTP_PAYLOAD)
endif (DEBUG_HTTP_PAYLOAD) endif (DEBUG_HTTP_PAYLOAD)
if (DEBUG_TRELLIS)
add_definitions(-DDEBUG_TRELLIS)
endif (DEBUG_TRELLIS)
# cross-compile options # cross-compile options
option(CROSS_COMPILE_ARM "Cross-compile for 32-bit ARM" off) option(CROSS_COMPILE_ARM "Cross-compile for 32-bit ARM" off)

@ -395,6 +395,9 @@ void Trellis::tribitsToBits(const uint8_t* tribits, uint8_t* payload) const
/// <returns>True, if error corrected, otherwise false.</returns> /// <returns>True, if error corrected, otherwise false.</returns>
bool Trellis::fixCode(uint8_t* points, uint32_t failPos, uint8_t* payload) const bool Trellis::fixCode(uint8_t* points, uint32_t failPos, uint8_t* payload) const
{ {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode() failPos = %u, val = %01X", failPos, points[failPos]);
#endif
for (unsigned j = 0U; j < 20U; j++) { for (unsigned j = 0U; j < 20U; j++) {
uint32_t bestPos = 0U; uint32_t bestPos = 0U;
uint32_t bestVal = 0U; uint32_t bestVal = 0U;
@ -405,6 +408,9 @@ bool Trellis::fixCode(uint8_t* points, uint32_t failPos, uint8_t* payload) const
uint8_t tribits[49U]; uint8_t tribits[49U];
uint32_t pos = checkCode(points, tribits); uint32_t pos = checkCode(points, tribits);
if (pos == 999U) { if (pos == 999U) {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode34() fixed, failPos = %u, pos = %u, val = %01X", failPos, bestPos, bestVal);
#endif
tribitsToBits(tribits, payload); tribitsToBits(tribits, payload);
return true; return true;
} }

@ -24,6 +24,7 @@
*/ */
#include "Defines.h" #include "Defines.h"
#include "p25/edac/Trellis.h" #include "p25/edac/Trellis.h"
#include "Log.h"
using namespace p25::edac; using namespace p25::edac;
@ -512,6 +513,9 @@ void Trellis::dibitsToBits(const uint8_t* dibits, uint8_t* payload) const
/// <returns>True, if error corrected, otherwise false.</returns> /// <returns>True, if error corrected, otherwise false.</returns>
bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) const bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) const
{ {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode34() failPos = %u, val = %01X", failPos, points[failPos]);
#endif
for (unsigned j = 0U; j < 20U; j++) { for (unsigned j = 0U; j < 20U; j++) {
uint32_t bestPos = 0U; uint32_t bestPos = 0U;
uint32_t bestVal = 0U; uint32_t bestVal = 0U;
@ -522,6 +526,9 @@ bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) con
uint8_t tribits[49U]; uint8_t tribits[49U];
uint32_t pos = checkCode34(points, tribits); uint32_t pos = checkCode34(points, tribits);
if (pos == 999U) { if (pos == 999U) {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode34() fixed, failPos = %u, pos = %u, val = %01X", failPos, bestPos, bestVal);
#endif
tribitsToBits(tribits, payload); tribitsToBits(tribits, payload);
return true; return true;
} }
@ -581,16 +588,22 @@ uint32_t Trellis::checkCode34(const uint8_t* points, uint8_t* tribits) const
/// <returns>True, if error corrected, otherwise false.</returns> /// <returns>True, if error corrected, otherwise false.</returns>
bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) const bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) const
{ {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode12() failPos = %u, val = %01X", failPos, points[failPos]);
#endif
for (unsigned j = 0U; j < 20U; j++) { for (unsigned j = 0U; j < 20U; j++) {
uint32_t bestPos = 0U; uint32_t bestPos = 0U;
uint32_t bestVal = 0U; uint32_t bestVal = 0U;
for (uint32_t i = 0U; i < 4U; i++) { for (uint32_t i = 0U; i < 16U; i++) {
points[failPos] = i; points[failPos] = i;
uint8_t dibits[49U]; uint8_t dibits[49U];
uint32_t pos = checkCode12(points, dibits); uint32_t pos = checkCode12(points, dibits);
if (pos == 999U) { if (pos == 999U) {
#if DEBUG_TRELLIS
::LogDebug(LOG_HOST, "Trellis::fixCode12() fixed, failPos = %u, pos = %u, val = %01X", failPos, bestPos, bestVal);
#endif
dibitsToBits(dibits, payload); dibitsToBits(dibits, payload);
return true; return true;
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.