From cc581637c5223dbb119da4054a554ee0ce767040 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 18 Dec 2023 18:42:47 -0500 Subject: [PATCH] Fix Misc Format/Tab Issues on dsd_gps.c; --- src/dsd_gps.c | 389 +++++++++++++++++++++++++------------------------- 1 file changed, 191 insertions(+), 198 deletions(-) diff --git a/src/dsd_gps.c b/src/dsd_gps.c index 144f717..22e6dc7 100644 --- a/src/dsd_gps.c +++ b/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 char deg_glyph[4]; - sprintf (deg_glyph, "%s", "°"); + sprintf (deg_glyph, "%s", "°"); float latitude = 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 @@ -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; //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) ); - longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*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) ); if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North 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) { - //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 - //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 + //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 + //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 - 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_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], 6); //this is one bit shorter than called for, but I believe it works + 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_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], 6); //this is one bit shorter than called for, but I believe it works - //Latitude Bits - uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //Latitude Degrees - 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 + //Latitude Bits + uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //Latitude Degrees + 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 - //Longitude Bits - uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //Longitude Degrees - 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 + //Longitude Bits + uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //Longitude Degrees + 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 - //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 + //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 - //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 + //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 - //timestamp (16-bit value w/ appended 17th bit to MSB) - 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 - uint32_t thour = rtime / 3600; - uint32_t tmin = (rtime % 3600) / 60; - uint32_t tsec = (rtime % 3600) % 60; + //timestamp (16-bit value w/ appended 17th bit to MSB) + 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 + uint32_t thour = rtime / 3600; + uint32_t tmin = (rtime % 3600) / 60; + uint32_t tsec = (rtime % 3600) % 60; - //lat and lon conversion - char deg_glyph[4]; - sprintf (deg_glyph, "%s", "°"); - float latitude = 0.0f; - float longitude = 0.0f; - float m_unit = 1.0f / 60.0f; - float mm_unit = 1.0f / 600000.0f; + //lat and lon conversion + char deg_glyph[4]; + sprintf (deg_glyph, "%s", "°"); + float latitude = 0.0f; + float longitude = 0.0f; + float m_unit = 1.0f / 60.0f; + float mm_unit = 1.0f / 600000.0f; - //speed conversion - float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values - fmps = (float)nmea_speed * 0.514444; UNUSED(fmps); - fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph); - fkph = (float)nmea_speed * 1.852f; UNUSED(fkph); + //speed conversion + float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values + fmps = (float)nmea_speed * 0.514444; UNUSED(fmps); + fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph); + fkph = (float)nmea_speed * 1.852f; UNUSED(fkph); - //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) ); - longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) ); + //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) ); + 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) - // if (nmea_ns) latitude *= -1.0f; //1 is South, 0 is North - // if (nmea_ew) longitude *= -1.0f; //1 is West, 0 is East + //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_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) - if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North - if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East + //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_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, " GPS: %f%s, %f%s;", latitude, deg_glyph, longitude, deg_glyph); + fprintf (stderr, " VCH: %d - SRC: %08d;", slot, src); + 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) - if (nmea_speed > 126) - fprintf (stderr, " SPD > 126 knots or %f MPH;", fmph); //using MPH here, its Harris, they're in the U.S. - else - fprintf (stderr, " SPD: %d knots; %f MPH;", nmea_speed, fmph); + //Speed in Knots (assuming in knots, and not in mps, or kph) + if (nmea_speed > 126) + fprintf (stderr, " SPD > 126 knots or %f MPH;", fmph); //using MPH here, its Harris, they're in the U.S. + else + fprintf (stderr, " SPD: %d knots; %f MPH;", nmea_speed, fmph); - //Course Over Ground (COG) - fprintf (stderr, " COG: %03d%s;", nmea_cog, deg_glyph); //%360 + //Course Over Ground (COG) + fprintf (stderr, " COG: %03d%s;", nmea_cog, deg_glyph); //%360 - //debug speed - // fprintf (stderr, " RSPD: %02X;", nmea_speed); + //debug speed + // fprintf (stderr, " RSPD: %02X;", nmea_speed); - //debug cog - // fprintf (stderr, " RCOG: %03X;", nmea_cog >> 0); + //debug cog + // fprintf (stderr, " RCOG: %03X;", nmea_cog >> 0); - //UTC Time - fprintf (stderr, " T: %02d:%02d:%02d UTC;", thour, tmin, tsec); + //UTC Time + fprintf (stderr, " T: %02d:%02d:%02d UTC;", thour, tmin, tsec); - //Fix Indicator - if (nmea_q) fprintf (stderr, " Current Fix;"); - else fprintf (stderr, " Last Fix;"); + //Fix Indicator + if (nmea_q) fprintf (stderr, " Current Fix;"); + else fprintf (stderr, " Last Fix;"); - //save to ncurses string - sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph); + //save to ncurses string + sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph); - //save to LRRP report for mapping/logging - FILE * pFile; //file pointer - if (opts->lrrp_file_output == 1) - { - //rounded interger formats for the log report - int s = (int)fkph; - int a = nmea_cog; + //save to LRRP report for mapping/logging + FILE * pFile; //file pointer + if (opts->lrrp_file_output == 1) + { + //rounded interger formats for the log report + int s = (int)fkph; + int a = nmea_cog; - //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() ); //could switch to UTC time on PDU if desired - fprintf (pFile, "%08d\t", src); - fprintf (pFile, "%.6lf\t", latitude); - fprintf (pFile, "%.6lf\t", longitude); - fprintf (pFile, "%d\t ", s); - fprintf (pFile, "%d\t ", a); - fprintf (pFile, "\n"); - fclose (pFile); + //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() ); //could switch to UTC time on PDU if desired + fprintf (pFile, "%08d\t", src); + fprintf (pFile, "%.6lf\t", latitude); + fprintf (pFile, "%.6lf\t", longitude); + fprintf (pFile, "%d\t ", s); + fprintf (pFile, "%d\t ", a); + fprintf (pFile, "\n"); + fclose (pFile); - } + } - //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 - //to other GPS functions like precision, etc, unknown. + //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 + //to other GPS functions like precision, etc, unknown. - //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 - //without any documentation, any of these values may still be wrong + //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 + //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) { - uint8_t lat_sign, lat_deg, lat_min = 0; - uint8_t lon_sign, lon_deg, lon_min = 0; - uint16_t lat_mmin = 0; - uint16_t lon_mmin = 0; + uint8_t lat_sign, lat_deg, lat_min = 0; + uint8_t lon_sign, lon_deg, lon_min = 0; + uint16_t lat_mmin = 0; + uint16_t lon_mmin = 0; - //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) - uint16_t rspeed = (uint16_t)ConvertBitIntoBytes(&input[136], 8); //MSB //136 - rspeed = (rspeed << 8) + (uint16_t)ConvertBitIntoBytes(&input[128], 8); //LSB //128 + //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) + uint16_t rspeed = (uint16_t)ConvertBitIntoBytes(&input[136], 8); //MSB //136 + 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?) - uint16_t rangle = (uint16_t)ConvertBitIntoBytes(&input[120], 8); //120,8 - float fspeed = (float)rspeed; - 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 %) + //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 + float fspeed = (float)rspeed; + float fangle = (float)rangle; - int s, a = 0; - s = (int)fspeed * 3.6; - a = (int)fangle % 360; + 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 %) - //fix and quality indicators? - uint8_t fix = input[147]; UNUSED(fix); - uint8_t quality = (uint16_t)ConvertBitIntoBytes(&input[148], 3); UNUSED(quality); + int s, a = 0; + s = (int)fspeed * 3.6; + a = (int)fangle % 360; - //timestamp (16-bit value w/ appended 17th bit to MSB) - 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; + //fix and quality indicators? + uint8_t fix = input[147]; UNUSED(fix); + uint8_t quality = (uint16_t)ConvertBitIntoBytes(&input[148], 3); UNUSED(quality); - float lat_dec = 0.0f; - float lon_dec = 0.0f; + //timestamp (16-bit value w/ appended 17th bit to MSB) + 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]; - sprintf (deg_glyph, "%s", "°"); + float lat_dec = 0.0f; + float lon_dec = 0.0f; - //This appears to be similar to the NMEA GPGGA format (DDmm.mm) but - //octets are ordered in least significant to most significant value - 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 + char deg_glyph[4]; + sprintf (deg_glyph, "%s", "°"); - lon_mmin = (uint16_t)ConvertBitIntoBytes(&input[72], 16); //? bits required, but grabbing two octets - lon_min = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //6 bits required to get 60 - 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 + //This appears to be similar to the NMEA GPGGA format (DDmm.mm) but + //octets are ordered in least significant to most significant value + 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 - int src = 0; - if (slot == 0) src = state->lastsrc; - if (slot == 1) src = state->lastsrcR; + lon_mmin = (uint16_t)ConvertBitIntoBytes(&input[72], 16); //? bits required, but grabbing two octets + lon_min = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //6 bits required to get 60 + 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) - 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) ); + int src = 0; + if (slot == 0) src = state->lastsrc; + if (slot == 1) src = state->lastsrcR; - if (lat_sign) - lat_dec *= -1.0f; + //calculate decimal representation (was a pain to figure out the sub minute values) + 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) - lon_dec *= -1.0f; + if (lat_sign) + lat_dec *= -1.0f; - //line break - fprintf (stderr, "\n"); - fprintf (stderr, " GPS: %f%s, %f%s;", lat_dec, deg_glyph, lon_dec, deg_glyph); + if (lon_sign) + lon_dec *= -1.0f; - //gps fix time - // fprintf (stderr, " RT: %05X;", rtime); //debug - fprintf (stderr, " LTS: %02d:%02d:%02d UTC;", thour, tmin, tsec); //last time synced to GPS - - //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); + //line break + fprintf (stderr, "\n"); + fprintf (stderr, " GPS: %f%s, %f%s;", lat_dec, deg_glyph, lon_dec, deg_glyph); - // fprintf (stderr, " FIX: %d", fix); - // fprintf (stderr, " QLT: %02d", quality); + //gps fix time + // 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 - sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", lat_dec, deg_glyph, lon_dec, deg_glyph); + // fprintf (stderr, " FIX: %d", fix); + // fprintf (stderr, " QLT: %02d", quality); - //save to LRRP report for mapping/logging - 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); + // fprintf (stderr, " SRC: %08d;", src); - } + //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 - //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 + //save to LRRP report for mapping/logging + 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); + + } + + //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 @@ -499,14 +499,14 @@ void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]) char deg_glyph[4]; sprintf (deg_glyph, "%s", "°"); - + uint32_t lon_sign = lc_bits[23]; uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24); uint32_t lat_sign = lc_bits[48]; uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23); 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_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 @@ -578,11 +578,7 @@ void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]) fclose (pFile); } - } - - - } 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]; sprintf (deg_glyph, "%s", "°"); - + uint32_t lon_sign = lc_bits[48]; uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23); 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);