mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-20 20:55:40 -05:00
Fix Misc Format/Tab Issues on dsd_gps.c;
This commit is contained in:
389
src/dsd_gps.c
389
src/dsd_gps.c
@@ -175,7 +175,7 @@ void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint
|
|||||||
|
|
||||||
//lat and lon conversion
|
//lat and lon conversion
|
||||||
char deg_glyph[4];
|
char deg_glyph[4];
|
||||||
sprintf (deg_glyph, "%s", "°");
|
sprintf (deg_glyph, "%s", "°");
|
||||||
float latitude = 0.0f;
|
float latitude = 0.0f;
|
||||||
float longitude = 0.0f;
|
float longitude = 0.0f;
|
||||||
// float m_unit = 1.0f / 60.0f; //unit to convert min into decimal value - (1/60)*60 minutes = 1 degree
|
// float m_unit = 1.0f / 60.0f; //unit to convert min into decimal value - (1/60)*60 minutes = 1 degree
|
||||||
@@ -192,8 +192,8 @@ void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint
|
|||||||
fkph = (float)nmea_speed * 1.852f;
|
fkph = (float)nmea_speed * 1.852f;
|
||||||
|
|
||||||
//calculate decimal representation of latidude and longitude (need some samples to test)
|
//calculate decimal representation of latidude and longitude (need some samples to test)
|
||||||
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
|
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
|
||||||
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
|
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
|
||||||
|
|
||||||
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
|
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
|
||||||
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
|
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
|
||||||
@@ -243,125 +243,125 @@ void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint
|
|||||||
void nmea_harris (dsd_opts * opts, dsd_state * state, uint8_t * input, uint32_t src, int slot)
|
void nmea_harris (dsd_opts * opts, dsd_state * state, uint8_t * input, uint32_t src, int slot)
|
||||||
{
|
{
|
||||||
|
|
||||||
//GPS working, Time Working (old method), COG and Speed are logical on due west sample
|
//GPS working, Time Working (old method), COG and Speed are logical on due west sample
|
||||||
//TODO: Fiddle/Test various ns and ew bits for proper signs in case its located elsewhere
|
//TODO: Fiddle/Test various ns and ew bits for proper signs in case its located elsewhere
|
||||||
//UPDATE: Found two contiguous bits that always work on all my accumulated samples
|
//UPDATE: Found two contiguous bits that always work on all my accumulated samples
|
||||||
//the bits also place it with the 'lone' flagged bit observed prior
|
//the bits also place it with the 'lone' flagged bit observed prior
|
||||||
|
|
||||||
uint8_t nmea_ns = input[88]; //north/south (lat sign) //72 previously used bit
|
uint8_t nmea_ns = input[88]; //north/south (lat sign) //72 previously used bit
|
||||||
uint8_t nmea_ew = input[89]; //east/west (lon sign) //88 previously used bit
|
uint8_t nmea_ew = input[89]; //east/west (lon sign) //88 previously used bit
|
||||||
uint8_t nmea_q = input[147]; //Quality Indicator (last fix or current fix)
|
uint8_t nmea_q = input[147]; //Quality Indicator (last fix or current fix)
|
||||||
// uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 7); //129,7
|
// uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 7); //129,7
|
||||||
uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 6); //this is one bit shorter than called for, but I believe it works
|
uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 6); //this is one bit shorter than called for, but I believe it works
|
||||||
|
|
||||||
//Latitude Bits
|
//Latitude Bits
|
||||||
uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //Latitude Degrees
|
uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //Latitude Degrees
|
||||||
uint8_t nmea_nmin = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //Latitude Minutes
|
uint8_t nmea_nmin = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //Latitude Minutes
|
||||||
uint16_t nmea_nminf = (uint16_t)ConvertBitIntoBytes(&input[42], 14); //Latitude Fractions of Minutes
|
uint16_t nmea_nminf = (uint16_t)ConvertBitIntoBytes(&input[42], 14); //Latitude Fractions of Minutes
|
||||||
|
|
||||||
//Longitude Bits
|
//Longitude Bits
|
||||||
uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //Longitude Degrees
|
uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //Longitude Degrees
|
||||||
uint8_t nmea_emin = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //Longitude Minutes
|
uint8_t nmea_emin = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //Longitude Minutes
|
||||||
uint16_t nmea_eminf = (uint16_t)ConvertBitIntoBytes(&input[74], 14); //Longitude Fractions of Minutes
|
uint16_t nmea_eminf = (uint16_t)ConvertBitIntoBytes(&input[74], 14); //Longitude Fractions of Minutes
|
||||||
|
|
||||||
//NOTE: Removed UTC hh.mm.ss6 format found in DMR UDT, could not make it work
|
//NOTE: Removed UTC hh.mm.ss6 format found in DMR UDT, could not make it work
|
||||||
//with bits already established for time and it works extremely well as is
|
//with bits already established for time and it works extremely well as is
|
||||||
|
|
||||||
//Course Over Ground in Degrees (0-360)
|
//Course Over Ground in Degrees (0-360)
|
||||||
uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[135], 9) % 360; //course over ground in degrees //working on due west sample without %360
|
uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[135], 9) % 360; //course over ground in degrees //working on due west sample without %360
|
||||||
|
|
||||||
//timestamp (16-bit value w/ appended 17th bit to MSB)
|
//timestamp (16-bit value w/ appended 17th bit to MSB)
|
||||||
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16);
|
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16);
|
||||||
rtime |= input[144] << 16; //this bit is flagged on after 0xFFFF rollover in the late afternoon
|
rtime |= input[144] << 16; //this bit is flagged on after 0xFFFF rollover in the late afternoon
|
||||||
uint32_t thour = rtime / 3600;
|
uint32_t thour = rtime / 3600;
|
||||||
uint32_t tmin = (rtime % 3600) / 60;
|
uint32_t tmin = (rtime % 3600) / 60;
|
||||||
uint32_t tsec = (rtime % 3600) % 60;
|
uint32_t tsec = (rtime % 3600) % 60;
|
||||||
|
|
||||||
//lat and lon conversion
|
//lat and lon conversion
|
||||||
char deg_glyph[4];
|
char deg_glyph[4];
|
||||||
sprintf (deg_glyph, "%s", "°");
|
sprintf (deg_glyph, "%s", "°");
|
||||||
float latitude = 0.0f;
|
float latitude = 0.0f;
|
||||||
float longitude = 0.0f;
|
float longitude = 0.0f;
|
||||||
float m_unit = 1.0f / 60.0f;
|
float m_unit = 1.0f / 60.0f;
|
||||||
float mm_unit = 1.0f / 600000.0f;
|
float mm_unit = 1.0f / 600000.0f;
|
||||||
|
|
||||||
//speed conversion
|
//speed conversion
|
||||||
float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values
|
float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values
|
||||||
fmps = (float)nmea_speed * 0.514444; UNUSED(fmps);
|
fmps = (float)nmea_speed * 0.514444; UNUSED(fmps);
|
||||||
fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph);
|
fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph);
|
||||||
fkph = (float)nmea_speed * 1.852f; UNUSED(fkph);
|
fkph = (float)nmea_speed * 1.852f; UNUSED(fkph);
|
||||||
|
|
||||||
//calculate decimal representation of latidude and longitude (need some samples to test)
|
//calculate decimal representation of latidude and longitude (need some samples to test)
|
||||||
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
|
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
|
||||||
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
|
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
|
||||||
|
|
||||||
//This is opposite (seemingly) compared to the version specified by DMR UDT NMEA, could still be different bits involved (to be tested)
|
//This is opposite (seemingly) compared to the version specified by DMR UDT NMEA, could still be different bits involved (to be tested)
|
||||||
// if (nmea_ns) latitude *= -1.0f; //1 is South, 0 is North
|
// if (nmea_ns) latitude *= -1.0f; //1 is South, 0 is North
|
||||||
// if (nmea_ew) longitude *= -1.0f; //1 is West, 0 is East
|
// if (nmea_ew) longitude *= -1.0f; //1 is West, 0 is East
|
||||||
|
|
||||||
//DMR UDT NMEA original version (working now with new bit selection 88 and 89 like how DMR UDT NMEA format specifies)
|
//DMR UDT NMEA original version (working now with new bit selection 88 and 89 like how DMR UDT NMEA format specifies)
|
||||||
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
|
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
|
||||||
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
|
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
|
||||||
|
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
fprintf (stderr, " VCH: %d - SRC: %08d;", slot, src);
|
fprintf (stderr, " VCH: %d - SRC: %08d;", slot, src);
|
||||||
fprintf (stderr, " GPS: %f%s, %f%s;", latitude, deg_glyph, longitude, deg_glyph);
|
fprintf (stderr, " GPS: %f%s, %f%s;", latitude, deg_glyph, longitude, deg_glyph);
|
||||||
|
|
||||||
//Speed in Knots (assuming in knots, and not in mps, or kph)
|
//Speed in Knots (assuming in knots, and not in mps, or kph)
|
||||||
if (nmea_speed > 126)
|
if (nmea_speed > 126)
|
||||||
fprintf (stderr, " SPD > 126 knots or %f MPH;", fmph); //using MPH here, its Harris, they're in the U.S.
|
fprintf (stderr, " SPD > 126 knots or %f MPH;", fmph); //using MPH here, its Harris, they're in the U.S.
|
||||||
else
|
else
|
||||||
fprintf (stderr, " SPD: %d knots; %f MPH;", nmea_speed, fmph);
|
fprintf (stderr, " SPD: %d knots; %f MPH;", nmea_speed, fmph);
|
||||||
|
|
||||||
//Course Over Ground (COG)
|
//Course Over Ground (COG)
|
||||||
fprintf (stderr, " COG: %03d%s;", nmea_cog, deg_glyph); //%360
|
fprintf (stderr, " COG: %03d%s;", nmea_cog, deg_glyph); //%360
|
||||||
|
|
||||||
//debug speed
|
//debug speed
|
||||||
// fprintf (stderr, " RSPD: %02X;", nmea_speed);
|
// fprintf (stderr, " RSPD: %02X;", nmea_speed);
|
||||||
|
|
||||||
//debug cog
|
//debug cog
|
||||||
// fprintf (stderr, " RCOG: %03X;", nmea_cog >> 0);
|
// fprintf (stderr, " RCOG: %03X;", nmea_cog >> 0);
|
||||||
|
|
||||||
//UTC Time
|
//UTC Time
|
||||||
fprintf (stderr, " T: %02d:%02d:%02d UTC;", thour, tmin, tsec);
|
fprintf (stderr, " T: %02d:%02d:%02d UTC;", thour, tmin, tsec);
|
||||||
|
|
||||||
//Fix Indicator
|
//Fix Indicator
|
||||||
if (nmea_q) fprintf (stderr, " Current Fix;");
|
if (nmea_q) fprintf (stderr, " Current Fix;");
|
||||||
else fprintf (stderr, " Last Fix;");
|
else fprintf (stderr, " Last Fix;");
|
||||||
|
|
||||||
//save to ncurses string
|
//save to ncurses string
|
||||||
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
|
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
|
||||||
|
|
||||||
//save to LRRP report for mapping/logging
|
//save to LRRP report for mapping/logging
|
||||||
FILE * pFile; //file pointer
|
FILE * pFile; //file pointer
|
||||||
if (opts->lrrp_file_output == 1)
|
if (opts->lrrp_file_output == 1)
|
||||||
{
|
{
|
||||||
//rounded interger formats for the log report
|
//rounded interger formats for the log report
|
||||||
int s = (int)fkph;
|
int s = (int)fkph;
|
||||||
int a = nmea_cog;
|
int a = nmea_cog;
|
||||||
|
|
||||||
//open file by name that is supplied in the ncurses terminal, or cli
|
//open file by name that is supplied in the ncurses terminal, or cli
|
||||||
pFile = fopen (opts->lrrp_out_file, "a");
|
pFile = fopen (opts->lrrp_out_file, "a");
|
||||||
fprintf (pFile, "%s\t", getDateL() );
|
fprintf (pFile, "%s\t", getDateL() );
|
||||||
fprintf (pFile, "%s\t", getTimeL() ); //could switch to UTC time on PDU if desired
|
fprintf (pFile, "%s\t", getTimeL() ); //could switch to UTC time on PDU if desired
|
||||||
fprintf (pFile, "%08d\t", src);
|
fprintf (pFile, "%08d\t", src);
|
||||||
fprintf (pFile, "%.6lf\t", latitude);
|
fprintf (pFile, "%.6lf\t", latitude);
|
||||||
fprintf (pFile, "%.6lf\t", longitude);
|
fprintf (pFile, "%.6lf\t", longitude);
|
||||||
fprintf (pFile, "%d\t ", s);
|
fprintf (pFile, "%d\t ", s);
|
||||||
fprintf (pFile, "%d\t ", a);
|
fprintf (pFile, "%d\t ", a);
|
||||||
fprintf (pFile, "\n");
|
fprintf (pFile, "\n");
|
||||||
fclose (pFile);
|
fclose (pFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: There seems to be a few more octets left undecoded in this PDU
|
//NOTE: There seems to be a few more octets left undecoded in this PDU
|
||||||
//not including the CRC obviously, unsure of their meaning, could relate
|
//not including the CRC obviously, unsure of their meaning, could relate
|
||||||
//to other GPS functions like precision, etc, unknown.
|
//to other GPS functions like precision, etc, unknown.
|
||||||
|
|
||||||
//NOTE2: All these values are just best effort based on observation and
|
//NOTE2: All these values are just best effort based on observation and
|
||||||
//making map points match using logic and distance over time for speed and course
|
//making map points match using logic and distance over time for speed and course
|
||||||
//without any documentation, any of these values may still be wrong
|
//without any documentation, any of these values may still be wrong
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,118 +369,118 @@ void nmea_harris (dsd_opts * opts, dsd_state * state, uint8_t * input, uint32_t
|
|||||||
void harris_gps(dsd_opts * opts, dsd_state * state, int slot, uint8_t * input)
|
void harris_gps(dsd_opts * opts, dsd_state * state, int slot, uint8_t * input)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t lat_sign, lat_deg, lat_min = 0;
|
uint8_t lat_sign, lat_deg, lat_min = 0;
|
||||||
uint8_t lon_sign, lon_deg, lon_min = 0;
|
uint8_t lon_sign, lon_deg, lon_min = 0;
|
||||||
uint16_t lat_mmin = 0;
|
uint16_t lat_mmin = 0;
|
||||||
uint16_t lon_mmin = 0;
|
uint16_t lon_mmin = 0;
|
||||||
|
|
||||||
//potentially in this PDU, but unverifiable without documentation or reasonable
|
//potentially in this PDU, but unverifiable without documentation or reasonable
|
||||||
//mathematical proof vs map points and direction of travel / distance over time (assuming the radio is facing that direction)
|
//mathematical proof vs map points and direction of travel / distance over time (assuming the radio is facing that direction)
|
||||||
uint16_t rspeed = (uint16_t)ConvertBitIntoBytes(&input[136], 8); //MSB //136
|
uint16_t rspeed = (uint16_t)ConvertBitIntoBytes(&input[136], 8); //MSB //136
|
||||||
rspeed = (rspeed << 8) + (uint16_t)ConvertBitIntoBytes(&input[128], 8); //LSB //128
|
rspeed = (rspeed << 8) + (uint16_t)ConvertBitIntoBytes(&input[128], 8); //LSB //128
|
||||||
|
|
||||||
//this works okay for example of driver driving due west at the speed limit of the road (fluke?)
|
//this works okay for example of driver driving due west at the speed limit of the road (fluke?)
|
||||||
uint16_t rangle = (uint16_t)ConvertBitIntoBytes(&input[120], 8); //120,8
|
uint16_t rangle = (uint16_t)ConvertBitIntoBytes(&input[120], 8); //120,8
|
||||||
float fspeed = (float)rspeed;
|
float fspeed = (float)rspeed;
|
||||||
float fangle = (float)rangle;
|
float fangle = (float)rangle;
|
||||||
|
|
||||||
fspeed /= 255.0f; //unit value of 1 bit
|
|
||||||
fspeed *= 1.56f; //this is based on an observation of a driver moving approx 210 meters in about 8 seconds and this makes it just under the speed limit on the road there
|
|
||||||
// fangle *= 360.0f/255.0f; //unit value of 1 bit
|
|
||||||
fangle *= 2.0f; //may exceed 360 degrees as is (use %)
|
|
||||||
|
|
||||||
int s, a = 0;
|
fspeed /= 255.0f; //unit value of 1 bit
|
||||||
s = (int)fspeed * 3.6;
|
fspeed *= 1.56f; //this is based on an observation of a driver moving approx 210 meters in about 8 seconds and this makes it just under the speed limit on the road there
|
||||||
a = (int)fangle % 360;
|
// fangle *= 360.0f/255.0f; //unit value of 1 bit
|
||||||
|
fangle *= 2.0f; //may exceed 360 degrees as is (use %)
|
||||||
|
|
||||||
//fix and quality indicators?
|
int s, a = 0;
|
||||||
uint8_t fix = input[147]; UNUSED(fix);
|
s = (int)fspeed * 3.6;
|
||||||
uint8_t quality = (uint16_t)ConvertBitIntoBytes(&input[148], 3); UNUSED(quality);
|
a = (int)fangle % 360;
|
||||||
|
|
||||||
//timestamp (16-bit value w/ appended 17th bit to MSB)
|
//fix and quality indicators?
|
||||||
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16); //seconds since midnight since last GPS fix (whatever the radio has as internal time)
|
uint8_t fix = input[147]; UNUSED(fix);
|
||||||
rtime |= input[144] << 16; //test appending this as bit 17 (observed this bit set after the afternoon 0xFFFF rollover)
|
uint8_t quality = (uint16_t)ConvertBitIntoBytes(&input[148], 3); UNUSED(quality);
|
||||||
uint32_t thour = rtime / 3600;
|
|
||||||
uint32_t tmin = (rtime % 3600) / 60;
|
|
||||||
uint32_t tsec = (rtime % 3600) % 60;
|
|
||||||
|
|
||||||
float lat_dec = 0.0f;
|
//timestamp (16-bit value w/ appended 17th bit to MSB)
|
||||||
float lon_dec = 0.0f;
|
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16); //seconds since midnight since last GPS fix (whatever the radio has as internal time)
|
||||||
|
rtime |= input[144] << 16; //test appending this as bit 17 (observed this bit set after the afternoon 0xFFFF rollover)
|
||||||
|
uint32_t thour = rtime / 3600;
|
||||||
|
uint32_t tmin = (rtime % 3600) / 60;
|
||||||
|
uint32_t tsec = (rtime % 3600) % 60;
|
||||||
|
|
||||||
char deg_glyph[4];
|
float lat_dec = 0.0f;
|
||||||
sprintf (deg_glyph, "%s", "°");
|
float lon_dec = 0.0f;
|
||||||
|
|
||||||
//This appears to be similar to the NMEA GPGGA format (DDmm.mm) but
|
char deg_glyph[4];
|
||||||
//octets are ordered in least significant to most significant value
|
sprintf (deg_glyph, "%s", "°");
|
||||||
lat_mmin = (uint16_t)ConvertBitIntoBytes(&input[40], 16); //? bits required, but grabbing two octets
|
|
||||||
lat_min = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //6 bits required to get 60
|
|
||||||
lat_deg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //7 bits required to get 90
|
|
||||||
lat_sign = input[72]; //64
|
|
||||||
|
|
||||||
lon_mmin = (uint16_t)ConvertBitIntoBytes(&input[72], 16); //? bits required, but grabbing two octets
|
//This appears to be similar to the NMEA GPGGA format (DDmm.mm) but
|
||||||
lon_min = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //6 bits required to get 60
|
//octets are ordered in least significant to most significant value
|
||||||
lon_deg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //8 bits required to get 180
|
lat_mmin = (uint16_t)ConvertBitIntoBytes(&input[40], 16); //? bits required, but grabbing two octets
|
||||||
lon_sign = input[88]; //88, unsure of a correct location, but on the sample with 0 minutes, this lonely bit was flagged on
|
lat_min = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //6 bits required to get 60
|
||||||
|
lat_deg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //7 bits required to get 90
|
||||||
|
lat_sign = input[72]; //64
|
||||||
|
|
||||||
int src = 0;
|
lon_mmin = (uint16_t)ConvertBitIntoBytes(&input[72], 16); //? bits required, but grabbing two octets
|
||||||
if (slot == 0) src = state->lastsrc;
|
lon_min = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //6 bits required to get 60
|
||||||
if (slot == 1) src = state->lastsrcR;
|
lon_deg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //8 bits required to get 180
|
||||||
|
lon_sign = input[88]; //88, unsure of a correct location, but on the sample with 0 minutes, this lonely bit was flagged on
|
||||||
|
|
||||||
//calculate decimal representation (was a pain to figure out the sub minute values)
|
int src = 0;
|
||||||
lat_dec = ( (float)lat_deg + ((float)lat_min/60.0f) + ((float)lat_mmin/600000.0f) );
|
if (slot == 0) src = state->lastsrc;
|
||||||
lon_dec = ( (float)lon_deg + ((float)lon_min/60.0f) + ((float)lon_mmin/600000.0f) );
|
if (slot == 1) src = state->lastsrcR;
|
||||||
|
|
||||||
if (lat_sign)
|
//calculate decimal representation (was a pain to figure out the sub minute values)
|
||||||
lat_dec *= -1.0f;
|
lat_dec = ( (float)lat_deg + ((float)lat_min/60.0f) + ((float)lat_mmin/600000.0f) );
|
||||||
|
lon_dec = ( (float)lon_deg + ((float)lon_min/60.0f) + ((float)lon_mmin/600000.0f) );
|
||||||
|
|
||||||
if (lon_sign)
|
if (lat_sign)
|
||||||
lon_dec *= -1.0f;
|
lat_dec *= -1.0f;
|
||||||
|
|
||||||
//line break
|
if (lon_sign)
|
||||||
fprintf (stderr, "\n");
|
lon_dec *= -1.0f;
|
||||||
fprintf (stderr, " GPS: %f%s, %f%s;", lat_dec, deg_glyph, lon_dec, deg_glyph);
|
|
||||||
|
|
||||||
//gps fix time
|
//line break
|
||||||
// fprintf (stderr, " RT: %05X;", rtime); //debug
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " LTS: %02d:%02d:%02d UTC;", thour, tmin, tsec); //last time synced to GPS
|
fprintf (stderr, " GPS: %f%s, %f%s;", lat_dec, deg_glyph, lon_dec, deg_glyph);
|
||||||
|
|
||||||
//speed and direction
|
|
||||||
// fprintf (stderr, " RSPD: %04X;", rspeed); //debug
|
|
||||||
// fprintf (stderr, " RANG: %02X;", rangle); //debug
|
|
||||||
// fprintf (stderr, " MPS: %06.02f;", fspeed);
|
|
||||||
// fprintf (stderr, " KPH: %06.02f;", fspeed * 3.6f);
|
|
||||||
// fprintf (stderr, " MPH: %06.02f;", fspeed * 2.2369f);
|
|
||||||
fprintf (stderr, " DIR: %03d%s;", a, deg_glyph);
|
|
||||||
|
|
||||||
// fprintf (stderr, " FIX: %d", fix);
|
//gps fix time
|
||||||
// fprintf (stderr, " QLT: %02d", quality);
|
// fprintf (stderr, " RT: %05X;", rtime); //debug
|
||||||
|
fprintf (stderr, " LTS: %02d:%02d:%02d UTC;", thour, tmin, tsec); //last time synced to GPS
|
||||||
|
|
||||||
// fprintf (stderr, " SRC: %08d;", src);
|
//speed and direction
|
||||||
|
// fprintf (stderr, " RSPD: %04X;", rspeed); //debug
|
||||||
|
// fprintf (stderr, " RANG: %02X;", rangle); //debug
|
||||||
|
// fprintf (stderr, " MPS: %06.02f;", fspeed);
|
||||||
|
// fprintf (stderr, " KPH: %06.02f;", fspeed * 3.6f);
|
||||||
|
// fprintf (stderr, " MPH: %06.02f;", fspeed * 2.2369f);
|
||||||
|
fprintf (stderr, " DIR: %03d%s;", a, deg_glyph);
|
||||||
|
|
||||||
//save to array for ncurses
|
// fprintf (stderr, " FIX: %d", fix);
|
||||||
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", lat_dec, deg_glyph, lon_dec, deg_glyph);
|
// fprintf (stderr, " QLT: %02d", quality);
|
||||||
|
|
||||||
//save to LRRP report for mapping/logging
|
// fprintf (stderr, " SRC: %08d;", src);
|
||||||
FILE * pFile; //file pointer
|
|
||||||
if (opts->lrrp_file_output == 1)
|
|
||||||
{
|
|
||||||
//open file by name that is supplied in the ncurses terminal, or cli
|
|
||||||
pFile = fopen (opts->lrrp_out_file, "a");
|
|
||||||
fprintf (pFile, "%s\t", getDateL() );
|
|
||||||
fprintf (pFile, "%s\t", getTimeL() );
|
|
||||||
fprintf (pFile, "%08d\t", src);
|
|
||||||
fprintf (pFile, "%.6lf\t", lat_dec);
|
|
||||||
fprintf (pFile, "%.6lf\t", lon_dec);
|
|
||||||
fprintf (pFile, "%d\t ", s);
|
|
||||||
fprintf (pFile, "%d\t ", a);
|
|
||||||
fprintf (pFile, "\n");
|
|
||||||
fclose (pFile);
|
|
||||||
|
|
||||||
}
|
//save to array for ncurses
|
||||||
|
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", lat_dec, deg_glyph, lon_dec, deg_glyph);
|
||||||
|
|
||||||
//NOTE: Thanks to DSheirer (SDRTrunk) for helping me work out a few of the things in here
|
//save to LRRP report for mapping/logging
|
||||||
//not entirely convinced on some of these calcs (speed, angle, and TS) but sure these bits
|
FILE * pFile; //file pointer
|
||||||
//are actual speed/direction/timestamps judging from what the coordinates show on a map
|
if (opts->lrrp_file_output == 1)
|
||||||
|
{
|
||||||
|
//open file by name that is supplied in the ncurses terminal, or cli
|
||||||
|
pFile = fopen (opts->lrrp_out_file, "a");
|
||||||
|
fprintf (pFile, "%s\t", getDateL() );
|
||||||
|
fprintf (pFile, "%s\t", getTimeL() );
|
||||||
|
fprintf (pFile, "%08d\t", src);
|
||||||
|
fprintf (pFile, "%.6lf\t", lat_dec);
|
||||||
|
fprintf (pFile, "%.6lf\t", lon_dec);
|
||||||
|
fprintf (pFile, "%d\t ", s);
|
||||||
|
fprintf (pFile, "%d\t ", a);
|
||||||
|
fprintf (pFile, "\n");
|
||||||
|
fclose (pFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//NOTE: Thanks to DSheirer (SDRTrunk) for helping me work out a few of the things in here
|
||||||
|
//not entirely convinced on some of these calcs (speed, angle, and TS) but sure these bits
|
||||||
|
//are actual speed/direction/timestamps judging from what the coordinates show on a map
|
||||||
}
|
}
|
||||||
|
|
||||||
//externalize embedded GPS - Confirmed working now on NE, NW, SE, and SW coordinates
|
//externalize embedded GPS - Confirmed working now on NE, NW, SE, and SW coordinates
|
||||||
@@ -499,14 +499,14 @@ void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
|||||||
|
|
||||||
char deg_glyph[4];
|
char deg_glyph[4];
|
||||||
sprintf (deg_glyph, "%s", "°");
|
sprintf (deg_glyph, "%s", "°");
|
||||||
|
|
||||||
uint32_t lon_sign = lc_bits[23];
|
uint32_t lon_sign = lc_bits[23];
|
||||||
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24);
|
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24);
|
||||||
uint32_t lat_sign = lc_bits[48];
|
uint32_t lat_sign = lc_bits[48];
|
||||||
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
|
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
|
||||||
double lon_sf = 1.0f; //float value we can multiple longitude with
|
double lon_sf = 1.0f; //float value we can multiple longitude with
|
||||||
double lat_sf = 1.0f; //float value we can multiple latitude with
|
double lat_sf = 1.0f; //float value we can multiple latitude with
|
||||||
|
|
||||||
double lat_unit = (double)180/ pow (2.0, 24); //180 divided by 2^24
|
double lat_unit = (double)180/ pow (2.0, 24); //180 divided by 2^24
|
||||||
double lon_unit = (double)360/ pow (2.0, 25); //360 divided by 2^25
|
double lon_unit = (double)360/ pow (2.0, 25); //360 divided by 2^25
|
||||||
|
|
||||||
@@ -578,11 +578,7 @@ void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
|||||||
fclose (pFile);
|
fclose (pFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
@@ -603,7 +599,7 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
|||||||
|
|
||||||
char deg_glyph[4];
|
char deg_glyph[4];
|
||||||
sprintf (deg_glyph, "%s", "°");
|
sprintf (deg_glyph, "%s", "°");
|
||||||
|
|
||||||
uint32_t lon_sign = lc_bits[48];
|
uint32_t lon_sign = lc_bits[48];
|
||||||
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
|
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
|
||||||
uint32_t lat_sign = lc_bits[24];
|
uint32_t lat_sign = lc_bits[24];
|
||||||
@@ -686,9 +682,6 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|||||||
Reference in New Issue
Block a user