From 2ceeeb82afbf488d35a44aa47bd76955e519f413 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 12 Dec 2024 05:18:33 -0500 Subject: [PATCH] Add Text Debug PDU Code for P25 and DMR PDUs; --- src/dmr_block.c | 63 ++++++++++++++++++++++++++++++------------ src/p25p1_mdpu.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 18 deletions(-) diff --git a/src/dmr_block.c b/src/dmr_block.c index 80e72e6..78ba267 100644 --- a/src/dmr_block.c +++ b/src/dmr_block.c @@ -798,26 +798,55 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte //debug print // fprintf (stderr, " CRC - EXT %X CMP %X", CRCExtracted, CRCComputed); - if (state->data_header_format[slot] == 13 || state->data_header_format[slot] == 14 || state->data_header_sap[slot] == 10) - { - fprintf (stderr, "%s", KCYN); - fprintf (stderr, "\n Short Data: ASCII \n" ); - for (i = 0; i < ((blocks+1)*block_len); i++) - { - if (state->dmr_pdu_sf[slot][i] <= 0x7E && state->dmr_pdu_sf[slot][i] >=0x20) - { - fprintf (stderr, "%c", state->dmr_pdu_sf[slot][i]); - } - else fprintf (stderr, " "); - - if (i == 47 || i == 95) fprintf (stderr, "\n "); - } - - } - fprintf (stderr, "%s ", KNRM); } + // #define DMR_ASCII_TEST + #ifdef DMR_ASCII_TEST + // if (state->data_header_format[slot] == 13 || state->data_header_format[slot] == 14 || state->data_header_sap[slot] == 10) + { + fprintf (stderr, "%s", KCYN); + fprintf (stderr, "\n DMR PDU ASCII: \n" ); + for (i = 0; i < ((blocks+1)*block_len); i++) + { + if (state->dmr_pdu_sf[slot][i] <= 0x7E && state->dmr_pdu_sf[slot][i] >=0x20) + { + fprintf (stderr, "%c", state->dmr_pdu_sf[slot][i]); + } + else fprintf (stderr, " "); + + if (i == 47 || i == 95) fprintf (stderr, "\n "); + } + + } + #endif + + // #define DMR_UTF16_TEST + #ifdef DMR_UTF16_TEST + //utf-16 text messaging (debug) + // if (utf-16) + { + fprintf (stderr, "%s", KCYN); + fprintf (stderr, "\n DMR PDU UTF16: "); + uint16_t ch16 = 0; + for (i = 25; i < ((blocks+1)*block_len)-4;) //at least one system seems to put out utf-16 at the offset of 25 from testing + { + ch16 = (uint16_t)state->dmr_pdu_sf[slot][i+0]; + ch16 <<= 8; + ch16 |= (uint16_t)state->dmr_pdu_sf[slot][i+1]; + // fprintf (stderr, " %04X; ", ch16); //debug for raw values to check grouping for offset + + if (ch16 >= 0x20) //if not a linebreak or terminal commmands + fprintf (stderr, "%lc", ch16); + else if (ch16 == 0) //if padding + fprintf (stderr, ""); + else fprintf (stderr, " "); + + i += 2; + } + } + #endif + //reset data header format storage state->data_header_format[slot] = 7; //flag off data header validity diff --git a/src/p25p1_mdpu.c b/src/p25p1_mdpu.c index 30fa455..b486fb6 100644 --- a/src/p25p1_mdpu.c +++ b/src/p25p1_mdpu.c @@ -1028,17 +1028,46 @@ void processMPDU(dsd_opts * opts, dsd_state * state) // else // TODO: decode PDU function + #define P25_ASCII_TEST34 + #ifdef P25_ASCII_TEST34 // if (sap == 0) //user data { fprintf (stderr, "%s",KCYN); fprintf (stderr, "\n P25 MPDU ASCII: "); - for (i = 0; i < (16*blks)-4; i++) + for (i = 24; i < (16*blks)-4-pad; i++) { if (mpdu_byte[i] <= 0x7E && mpdu_byte[i] >=0x20) fprintf (stderr, "%c", mpdu_byte[i]); else fprintf (stderr, " "); } } + #endif + + // #define P25_UTF16_TEST + #ifdef P25_UTF16_TEST + //utf-16 text messaging (debug) + // if (utf-16) + { + fprintf (stderr, "%s", KCYN); + fprintf (stderr, "\n P25 MPDU UTF16: "); + uint16_t ch16 = 0; + for (i = 24; i < (16*blks)-4-pad;) + { + ch16 = (uint16_t)mpdu_byte[i+0]; + ch16 <<= 8; + ch16 |= (uint16_t)mpdu_byte[i+1]; + // fprintf (stderr, " %04X; ", ch16); //debug for raw values to check grouping for offset + + if (ch16 >= 0x20) //if not a linebreak or terminal commmands + fprintf (stderr, "%lc", ch16); + else if (ch16 == 0) //if padding + fprintf (stderr, ""); + else fprintf (stderr, " "); + + i += 2; + } + } + #endif fprintf (stderr, "%s ", KNRM); fprintf (stderr, "\n"); @@ -1079,6 +1108,47 @@ void processMPDU(dsd_opts * opts, dsd_state * state) // else if (blks != 0) // TODO: decode PDU function + #define P25_ASCII_TEST12 + #ifdef P25_ASCII_TEST12 + // if (opts->payload == 1) + { + fprintf (stderr, "%s",KCYN); + fprintf (stderr, "\n P25 MPDU ASCII: "); + for (i = 24; i < 12*(blks+1)-4-pad; i++) + { + if (mpdu_byte[i] <= 0x7E && mpdu_byte[i] >=0x20) + fprintf (stderr, "%c", mpdu_byte[i]); + else fprintf (stderr, " "); + } + } + #endif + + // #define P25_UTF16_TEST12 + #ifdef P25_UTF16_TEST12 + //utf-16 text messaging (debug) + // if (utf-16) + { + fprintf (stderr, "%s", KCYN); + fprintf (stderr, "\n P25 MPDU UTF16: "); + uint16_t ch16 = 0; + for (i = 12; i < (12*blks)-4-pad;) + { + ch16 = (uint16_t)mpdu_byte[i+0]; + ch16 <<= 8; + ch16 |= (uint16_t)mpdu_byte[i+1]; + // fprintf (stderr, " %04X; ", ch16); //debug for raw values to check grouping for offset + + if (ch16 >= 0x20) //if not a linebreak or terminal commmands + fprintf (stderr, "%lc", ch16); + else if (ch16 == 0) //if padding + fprintf (stderr, ""); + else fprintf (stderr, " "); + + i += 2; + } + } + #endif + fprintf (stderr, "%s",KNRM); fprintf (stderr, "\n");