DSTAR - Fix some SD Format Issues; Lose My Mind;

This commit is contained in:
lwvmobile
2023-10-25 10:49:36 -04:00
parent 9cbb4ec36b
commit 76309399b0

View File

@@ -187,6 +187,14 @@ void processDSTAR_SD(dsd_opts * opts, dsd_state * state, uint8_t * sd)
strf[59] = '\0';
strt[59] = '\0';
char type[7]; char temp[8]; char tempa[8]; char chungus[80]; UNUSED(chungus);
memset (chungus, 0, sizeof(chungus));
memset (temp, 0, sizeof(temp));
memset (tempa, 0, sizeof(tempa));
memset (type, 0, sizeof(type));
memcpy (type, sd_bytes+1, 5);
type[6] = '\0';
if (sd_bytes[0] == 0x55) //header format
{
@@ -213,55 +221,133 @@ void processDSTAR_SD(dsd_opts * opts, dsd_state * state, uint8_t * sd)
}
//I'm tired of trying to work out all the nuances here, so if its wrong, it is what it is
//I really doubt anybody who likes DSTAR uses this anyways.
else //any other format (text, nmea gps, etc)
else //any other format (text, aprs, etc)
{
//I'd have to rewrite the upper loading portion for a consistent good crc when the header
//indicator bytes have different len values, so these will most likely always fail a crc,
//but I am going to leave them active since I have the 'safety' check in place to prevent
//rouge non-ascii values doing odd things in the terminal and in ncurses
//sure would be a lot easier if there was seperate and uniform opcodes for all the data types,
//instead of having to over analyze everyhign to figure out what is text, and GPS, and APRS
if (1 == 1) //crc_cmp == crc_ext
//fixed-form at 5 bytes, evaluate
if (sd_bytes[0] == 0x35)
{
//fixed-form at 5 bytes, use the truncated (Some Interleaved APRS/GPS TEXT combos may display incorrectly)
if (sd_bytes[0] == 0x35)
//TODO: Check type for $$CRC, etc (may really be API51 label "circle-2d"?)
// if (strcmp(type, "$$CRC") == 0) //APRS
// {
// fprintf (stderr, " APRS - ");
// sprintf (state->dstar_gps, "APRS - ");
// //LAT
// memcpy (temp, sd_bytes+38, 2);
// fprintf (stderr, "Lat: %sd ", temp);
// strcat (state->dstar_gps, "Lat: ");
// strcat (state->dstar_gps, temp);
// strcat (state->dstar_gps, "d ");
// memcpy (temp, sd_bytes+40, 2);
// fprintf (stderr, "%sm ", temp);
// strcat (state->dstar_gps, temp);
// strcat (state->dstar_gps, "m ");
// memcpy (temp, sd_bytes+44, 2);
// fprintf (stderr, "%ss ", temp);
// strcat (state->dstar_gps, temp);
// strcat (state->dstar_gps, "s ");
// if (sd_bytes[46] > 0x19 && sd_bytes[46] < 0x7F)
// fprintf (stderr, "%c", sd_bytes[46]);
// if (sd_bytes[46] > 0x19 && sd_bytes[46] < 0x7F)
// {
// if (sd_bytes[46] == 0x4E)
// strcat (state->dstar_gps, "N ");
// else if (sd_bytes[46] == 0x53)
// strcat (state->dstar_gps, "S ");
// }
// fprintf (stderr, "; ");
// //LON
// memcpy (tempa, sd_bytes+49, 3);
// fprintf (stderr, "Lon: %sd ", tempa);
// strcat (state->dstar_gps, "Lon: ");
// strcat (state->dstar_gps, tempa);
// strcat (state->dstar_gps, "d ");
// memcpy (temp, sd_bytes+52, 2);
// fprintf (stderr, "%sm ", temp);
// strcat (state->dstar_gps, temp);
// strcat (state->dstar_gps, "m ");
// memcpy (temp, sd_bytes+56, 2);
// fprintf (stderr, "%ss ", temp);
// strcat (state->dstar_gps, temp);
// strcat (state->dstar_gps, "s ");
// if (sd_bytes[58] > 0x19 && sd_bytes[58] < 0x7F)
// fprintf (stderr, "%c", sd_bytes[58]);
// if (sd_bytes[46] > 0x19 && sd_bytes[46] < 0x7F)
// {
// if (sd_bytes[46] == 0x45)
// strcat (state->dstar_gps, "E ");
// else if (sd_bytes[46] == 0x57)
// strcat (state->dstar_gps, "W ");
// }
// fprintf (stderr, "; ");
// //sample now working and showing Borsigstraße Ratingen, Germany
// //but still unsure if this is truly DMS, or Decimal (decimal conversion doesn't line up with FL)
// //another sample shows this data off by one octet, so this seems to be a variable len deal
// //which kind of sucks and makes it a true pain to work with.
// }
if (strcmp(type, "$$CRC") == 0) //APRS
{
fprintf (stderr, " DATA:");
fprintf (stderr, " %s", strt);
memset (strt, 0x20, sizeof(strt)); //space fill
fprintf (stderr, " DATA: ");
for (i = 1; i < 59; i++)
{
if (i%6==0) i++;
if ( (sd_bytes[i] > 0x19) && (sd_bytes[i] < 0x7F) )
{
fprintf (stderr, "%c", sd_bytes[i]);
strt[i] = sd_bytes[i];
}
}
strt[59] = '\0';
memcpy (state->dstar_gps, strt, sizeof(strt));
}
//free-form text at 5 bytes, use the truncated
else if (sd_bytes[0] == 0x40)
else
{
fprintf (stderr, " TEXT:");
fprintf (stderr, " %s", strt);
// fprintf (stderr, " %s: ", type);
memset (strt, 0x20, sizeof(strt)); //space fill
fprintf (stderr, " TEXT: ");
for (i = 1; i < 59; i++)
{
if (i%6==0) i++;
if ( (sd_bytes[i] > 0x19) && (sd_bytes[i] < 0x7F) )
{
fprintf (stderr, "%c", sd_bytes[i]);
strt[i] = sd_bytes[i];
}
}
strt[59] = '\0';
memcpy (state->dstar_txt, strt, sizeof(strt));
}
//any other 5 byte block value
else if (sd_bytes[0] & 0x05)
{
fprintf (stderr, " _UNK:");
fprintf (stderr, " %s", strt);
memcpy (state->dstar_txt, strt, sizeof(strt));
}
//coded squelch data
else if (sd_bytes[0] == 0xC2)
{
fprintf (stderr, " SQL: %02X (%03d)", payload[1], payload[1]);
sprintf (state->dstar_gps, " SQL: %02X (%03d) ", payload[1], payload[1]);
}
//any variable len block values
else //print entire thing
{
fprintf (stderr, " _UNK:");
fprintf (stderr, " %s", strf);
memcpy (state->dstar_gps, strf, sizeof(strf));
}
}
// if (crc_cmp != crc_ext) fprintf (stderr, " (CRC ERR)");
//free-form text at 5 bytes, truncate every 6th position
else if (sd_bytes[0] == 0x40)
{
memset (strt, 0x20, sizeof(strt)); //space fill
fprintf (stderr, " TEXT: ");
for (i = 1; i < 59; i++)
{
if (i%6==0) i++;
if ( (sd_bytes[i] > 0x19) && (sd_bytes[i] < 0x7F) )
{
fprintf (stderr, "%c", sd_bytes[i]);
strt[i] = sd_bytes[i];
}
}
strt[59] = '\0';
memcpy (state->dstar_txt, strt, sizeof(strt));
}
//anything else
else //print entire thing
{
fprintf (stderr, " _UNK:");
fprintf (stderr, " %s", strf);
// memcpy (state->dstar_txt, strf, sizeof(strf)); //don't copy the unknown garbo strings
}
}
if (opts->payload == 1)