mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-09 15:27:22 -05:00
Event History Setup: #287
Fix Some GPS formats not writing to the event history gps_s string due to mismatching src values (UDT NMEA and LIP); Fix bug in ComputeCrcCCITT16d where the len value cannot exceed 255 by recasting len as uint32_t instead of uint8_t; #288 Clarify when UDT Data Blocks (R12) is Confirmed or Unconfirmed Data;
This commit is contained in:
@@ -1329,7 +1329,7 @@ rs_12_9_checksum_t *rs_12_9_calc_checksum(rs_12_9_codeword_t *codeword);
|
||||
|
||||
//DMR CRC Functions
|
||||
uint16_t ComputeCrcCCITT(uint8_t * DMRData);
|
||||
uint16_t ComputeCrcCCITT16d(const uint8_t buf[], uint8_t len);
|
||||
uint16_t ComputeCrcCCITT16d(const uint8_t * buf, uint32_t len);
|
||||
uint32_t ComputeAndCorrectFullLinkControlCrc(uint8_t * FullLinkControlDataBytes, uint32_t * CRCComputed, uint32_t CRCMask);
|
||||
uint8_t ComputeCrc5Bit(uint8_t * DMRData);
|
||||
uint16_t ComputeCrc9Bit(uint8_t * DMRData, uint32_t NbData);
|
||||
|
||||
@@ -693,7 +693,6 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes,
|
||||
if (utf16c >= 0x20 && utf16c != 0x7F) //avoid control chars
|
||||
{
|
||||
fprintf (stderr, "%lc", utf16c); //will using lc work here? May depend on console locale settings?
|
||||
// strcat (udt_string, u16);
|
||||
if (utf16c >= 0x20 && utf16c < 0x7F)
|
||||
strcat (state->event_history_s[slot].Event_History_Items[0].text_message, u16);
|
||||
}
|
||||
@@ -744,7 +743,6 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes,
|
||||
if (utf16c >= 0x20 && utf16c != 0x7F) //avoid control chars
|
||||
{
|
||||
fprintf (stderr, "%lc", utf16c);
|
||||
// strcat (udt_string, u16);
|
||||
if (utf16c >= 0x20 && utf16c < 0x7F)
|
||||
strcat (state->event_history_s[slot].Event_History_Items[0].text_message, u16);
|
||||
}
|
||||
@@ -756,7 +754,7 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes,
|
||||
{
|
||||
//Would be nice to be able to test these all out to make sure the conditions are okay, etc
|
||||
fprintf (stderr, "NMEA" );
|
||||
// strcat (udt_string, "NMEA; ");
|
||||
strcat (udt_string, "NMEA; ");
|
||||
if (cs_bits[96] == 1) //check if its encrypted first
|
||||
fprintf (stderr, " Encrypted Format :(" ); //sad face
|
||||
else if (udt_uab == 1)
|
||||
@@ -774,9 +772,9 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes,
|
||||
//unsure of how this is structured for UDT Blocks, would assume one appended block of same format
|
||||
//but could also be full blown LIP protocol that is also found in tetra that would require the PDU
|
||||
//type bit to be read and then to decode accordingly, this assumes its the modified Short PDU that USBD uses
|
||||
strcat (udt_string, "LIP; ");
|
||||
fprintf (stderr, "\n");
|
||||
lip_protocol_decoder (opts, state, cs_bits+96); //start on first appended block, and not header
|
||||
// strcat (udt_string, "LIP; ");
|
||||
|
||||
}
|
||||
else if (udt_format2 == 0x08 || udt_format2 == 0x09)
|
||||
@@ -1364,7 +1362,7 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
|
||||
mbc_block_bits[i] = dmr_pdu_sf_bits[i+96]; //skip udt header
|
||||
}
|
||||
}
|
||||
|
||||
//there was a bug built into ComputeCrcCCITT16d where len was uint8_t, so len could never exceed 255
|
||||
CRCComputed = ComputeCrcCCITT16d (mbc_block_bits, ((blocks+0)*96)-16 );
|
||||
|
||||
if (CRCComputed == CRCExtracted) mbc_crc_good[1] = 1;
|
||||
@@ -1385,7 +1383,7 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
|
||||
|
||||
//debug print
|
||||
fprintf (stderr, " %X - %X", CRCExtracted, CRCComputed);
|
||||
|
||||
// fprintf (stderr, " Len: %d", ((blocks+0)*96)-16);
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,9 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
||||
if (state->data_header_format[slot] == 0) //UDT 1/2 Encoded Blocks
|
||||
{
|
||||
is_udt = 1;
|
||||
sprintf(state->fsubtype, " UDTC ");
|
||||
if (state->data_conf_data[slot] == 1)
|
||||
sprintf(state->fsubtype, " UDTC "); //confirmed data
|
||||
else sprintf(state->fsubtype, " UDTU "); //unconfirmed data
|
||||
}
|
||||
break;
|
||||
case 0x08: //3/4 Rate Data
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "dsd.h"
|
||||
|
||||
//modified to accept variable payload size and len
|
||||
uint16_t ComputeCrcCCITT16d(const uint8_t buf[], uint8_t len)
|
||||
uint16_t ComputeCrcCCITT16d(const uint8_t * buf, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
uint16_t CRC = 0x0000; /* Initialization value = 0x0000 */
|
||||
|
||||
@@ -16,10 +16,10 @@ void lip_protocol_decoder (dsd_opts * opts, dsd_state * state, uint8_t * input)
|
||||
int slot = state->currentslot;
|
||||
|
||||
//May need to set this in the UDT header, or pass it into this function to be sure
|
||||
uint32_t src = 0;
|
||||
if (slot == 0)
|
||||
src = state->lastsrc;
|
||||
else src = state->lastsrcR;
|
||||
// uint32_t src = 0;
|
||||
// if (slot == 0)
|
||||
// src = state->lastsrc;
|
||||
// else src = state->lastsrcR;
|
||||
|
||||
//NOTE: This format is pretty much the same as DMR EMB GPS, but has a few extra elements,
|
||||
//so I got lazy and just lifted most of the code from there, also assuming same lat/lon calcs
|
||||
@@ -122,8 +122,7 @@ void lip_protocol_decoder (dsd_opts * opts, dsd_state * state, uint8_t * input)
|
||||
else sprintf (state->dmr_embedded_gps[slot], "%03d; LIP: %.5lf%s%s %.5lf%s%s Unknown Pos Err; Spd: %d km/h; Dir %d%s", add_hash, latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, vt, dt, deg_glyph);
|
||||
|
||||
//save to event history string
|
||||
if (state->event_history_s[slot].Event_History_Items[0].source_id == src)
|
||||
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
|
||||
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
|
||||
|
||||
//save to LRRP report for mapping/logging
|
||||
FILE * pFile; //file pointer
|
||||
@@ -241,8 +240,7 @@ void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint
|
||||
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
|
||||
|
||||
//save to event history string
|
||||
if (state->event_history_s[slot].Event_History_Items[0].source_id == src)
|
||||
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
|
||||
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "(%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
|
||||
|
||||
//save to LRRP report for mapping/logging
|
||||
FILE * pFile; //file pointer
|
||||
|
||||
Reference in New Issue
Block a user