| 1 | /* |
| 2 | Locosys NaviGPS GT-31/BGT-31 common functions. |
| 3 | |
| 4 | Copyright (C) 2008 Rodney Lorrimar <[email protected]> |
| 5 | Copyright (C) 2005 Robert Lipe, [email protected] |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #ifndef NAVILINK_H_INCLUDED_ |
| 24 | #define NAVILINK_H_INCLUDED_ |
| 25 | |
| 26 | #include <ctime> |
| 27 | #include "defs.h" |
| 28 | |
| 29 | #define SBP_RECORD_LEN 32 |
| 30 | |
| 31 | /* defined in navilink.c */ |
| 32 | Waypoint* navilink_decode_logpoint(const unsigned char* buffer); |
| 33 | unsigned navilink_checksum_packet(const unsigned char* packet, unsigned length); |
| 34 | |
| 35 | /* defined in sbn.c */ |
| 36 | bool locosys_decode_file_id(char* header, size_t len); |
| 37 | |
| 38 | |
| 39 | #ifdef THIS_IS_ONLY_FOR_REFERENCE |
| 40 | /* Locosys SBP and SBN structures */ |
| 41 | |
| 42 | typedef __packed struct { |
| 43 | UINT8 HDOP; /* HDOP [0..51] with resolution 0.2 */ |
| 44 | UINT8 SVIDCnt; /* Number of SVs in solution [0 to 12] */ |
| 45 | UINT16 UtcSec; /* UTC Second [0 to 59] in seconds with resolution 0.001 */ |
| 46 | UINT32 date_time_UTC_packed; /* refer to protocol doc*/ |
| 47 | UINT32 SVIDList; /* SVs in solution: Bit 0=1: SV1, Bit 1=1: SV2, ... , Bit 31=1: SV32 */ |
| 48 | INT32 Lat; /* Latitude [-90 to 90] in degrees with resolution 0.0000001 */ |
| 49 | INT32 Lon; /* Longitude [-180 to 180] in degrees with resolution 0.0000001 */ |
| 50 | INT32 AltCM; /* Altitude from Mean Sea Level in centi meters */ |
| 51 | UINT16 Sog; /* Speed Over Ground in m/sec with resolution 0.01 */ |
| 52 | UINT16 Cog; /* Course Over Ground [0 to 360] in degrees with resolution 0.01 */ |
| 53 | INT16 ClmbRte; /* Climb rate in m/sec with resolution 0.01 */ |
| 54 | UINT8 bitFlags; /* bitFlags, default 0x00, bit 0=1 indicate the first point after power on */ |
| 55 | UINT8 reserved; |
| 56 | } T_SBP; |
| 57 | |
| 58 | typedef struct __packed { |
| 59 | UINT8 Mid; |
| 60 | UINT16 Valid; |
| 61 | UINT16 Mode; /* Nav Mode: bit map as follows: |
| 62 | * Bits 2-0: GPS Fix Type |
| 63 | * 000 = No Nav |
| 64 | * 001 = 1 SV solution |
| 65 | * 010 = 2 SV solution |
| 66 | * 011 = 3 SV solution (2D) |
| 67 | * 100 = 4 or more SV solution (3D) |
| 68 | * 101 = Least Square 2D solution |
| 69 | * 110 = Least Square 3D solution |
| 70 | * 111 = DR solution (no SV) |
| 71 | * Bit 3 : 1 = Trickle Power ON |
| 72 | * Bits 5-4: Altitude Hold |
| 73 | * 00 = No Altitude Hold |
| 74 | * 01 = Altitude Hold using altitude from KF |
| 75 | * 10 = Altitude Hold using altitude from user |
| 76 | * 11 = forced altitude |
| 77 | * Bit 6 : 1 = DOP exceeded |
| 78 | * Bit 7 : 1 = DGPS correction applied |
| 79 | * Bit 8 : |
| 80 | * 1 = Sensor-based DR |
| 81 | * 0 = Velocity DR, if bits 2-0 = 111 |
| 82 | * = see bits 15-14, if bits 2-0 != 111 |
| 83 | * Bit 9 : 1 = Solution validated |
| 84 | * Bit 10 : 1 = Velocity DR Timeout |
| 85 | * Bit 11 : 1 = Solution edited by UI |
| 86 | * Bit 12 : 1 = Velocity invalid |
| 87 | * Bit 13 : 1 = Altitude Hold disabled |
| 88 | * Bits 15-14: SiRFDrive DR Status (applicable only when bit 8=0) |
| 89 | * 00 = GPS Only |
| 90 | * 01 = Calibrating |
| 91 | * 10 = DR sensor error |
| 92 | * 11 = DR Test mode |
| 93 | */ |
| 94 | UINT16 Week; /* Extended Week Number */ |
| 95 | UINT32 TOW; /* Time of Week [0 to 604800] in seconds with resolution 0.001 */ |
| 96 | UINT16 UtcYr; /* UTC Year [1980 to 3000] */ |
| 97 | UINT8 UtcMth; /* UTC Month [1 to 12] */ |
| 98 | UINT8 UtcDay; /* UTC Day [1 to 31] */ |
| 99 | UINT8 UtcHr; /* UTC Hour [0 to 23] */ |
| 100 | UINT8 UtcMin; /* UTC Minute [0 to 59] */ |
| 101 | UINT16 UtcSec; /* UTC Second [0 to 59] in seconds with resolution 0.001 */ |
| 102 | UINT32 SVIDList; /* SVs in solution: Bit 0=1: SV1, Bit 1=1: SV2, ... , Bit 31=1: SV32 */ |
| 103 | |
| 104 | INT32 Lat; /* Latitude [-90 to 90] in degrees with resolution 0.0000001 */ |
| 105 | INT32 Lon; /* Longitude [-180 to 180] in degrees with resolution 0.0000001 */ |
| 106 | INT32 AltE; /* Altitude from Ellipsoid in meters with resolution 0.01 */ |
| 107 | INT32 AltM; /* Altitude from Mean Sea Level in meters with resolution 0.01 */ |
| 108 | UINT8 Datum; /* Map datum */ |
| 109 | UINT16 Sog; /* Speed Over Ground in m/sec with resolution 0.01 */ |
| 110 | UINT16 Cog; /* Course Over Ground [0 to 360] in degrees with resolution 0.01 */ |
| 111 | INT16 MagVar; /* Magnetic Variation - Reserved */ |
| 112 | INT16 ClmbRte; /* Climb rate in m/sec with resolution 0.01 */ |
| 113 | INT16 HdRte; /* Heading Rate in deg/sec with resolution 0.01 (SiRFDrive only) */ |
| 114 | UINT32 Ehpe; /* Expected Horizontal Position Error in meters with resolution 0.01 */ |
| 115 | UINT32 Evpe; /* Expected Horizontal Vertical Error in meters with resolution 0.01 */ |
| 116 | UINT32 Ete; /* Expected Time Error in meters with resolution 0.01 (SiRFDrive only) - Reserved */ |
| 117 | UINT16 Ehve; /* Expected Horizontal Velocity Error in m/sec with resolution 0.01 (SiRFDrive only) */ |
| 118 | INT32 ClkBias; /* Clock Bias in meters with resolution 0.01 */ |
| 119 | UINT32 ClkBiasE; /* Clock Bias Error in meters with resolution 0.01 (SiRFDrive only) */ |
| 120 | INT32 ClkDrift; /* Clock Drift in m/sec with resolution 0.01 */ |
| 121 | UINT32 ClkDriftE; /* Clock Drift in m/sec with resolution 0.01 (SiRFDrive only) */ |
| 122 | UINT32 Trvled; /* Distance Traveled since reset in meters (SiRFDrive only) */ |
| 123 | UINT16 TrvledE; /* Distance Traveled Error in meters (SiRFDrive only) */ |
| 124 | UINT16 HdE; /* Heading Error [0 to 180] in degrees with resolution 0.01 (SiRFDrive only) */ |
| 125 | UINT8 SVIDCnt; /* Number of SVs in solution [0 to 12] */ |
| 126 | UINT8 HDOP; /* HDOP [0..51] with resolution 0.2 */ |
| 127 | UINT8 Reserved; /* Reserved */ |
| 128 | |
| 129 | UINT16 ufSog; /* Speed Over Ground in m/sec with resolution 0.01 ,unfiltered*/ |
| 130 | UINT16 ufCog; /* Course Over Ground [0 to 360] in degrees with resolution 0.01, unfiltered */ |
| 131 | |
| 132 | } T_SBN_REC; |
| 133 | |
| 134 | #endif |
| 135 | |
| 136 | #endif // NAVILINK_H_INCLUDED_ |