Subversion Repositories public

Rev

Rev 214 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 andreas 1
#ifndef __GARMIN_GARMIN_H__
2
#define __GARMIN_GARMIN_H__
3
 
4
 
5
#include <stdio.h>
6
#include <usb.h>
7
#include <math.h>
8
 
9
 
10
/* ------------------------------------------------------------------------- */
11
/* 7.3   Basic Data Types                                                    */
12
/* ------------------------------------------------------------------------- */
13
 
14
/* conversions */
15
 
16
#define DEGREES      180.0
17
#define SEMICIRCLES  0x80000000
18
 
19
#define SEMI2DEG(a)  (double)(a) * DEGREES / SEMICIRCLES
20
#define DEG2SEMI(a)  rint((double)(a) * SEMICIRCLES / DEGREES)
21
 
22
#define DEG2RAD(a)   (a) * M_PI / DEGREES
23
#define RAD2DEG(a)   (a) * DEGREES / M_PI
24
 
25
 
26
/* number of seconds since Dec 31, 1989, 12:00 AM (UTC) */
27
 
28
#define TIME_OFFSET  631065600
29
 
30
 
31
/* types */
32
 
33
typedef unsigned char   uint8;
34
typedef unsigned short  uint16;
35
typedef unsigned int    uint32;
36
typedef short           sint16;
37
typedef int             sint32;
38
typedef float           float32;
39
typedef double          float64;
40
typedef unsigned char   bool;
41
 
42
 
43
/* 2^31 semicircles = 180 degrees where N, E are positive, S and W negative. */
44
 
45
typedef struct position_type {
46
  sint32                lat;     /* latitude in semicircles  */
47
  sint32                lon;     /* longitude in semicircles */
48
} position_type;
49
 
50
 
51
typedef struct radian_position_type {
52
  float64               lat;     /* latitude in radians  */
53
  float64               lon;     /* longitude in radians */
54
} radian_position_type;
55
 
56
 
57
/* Time is the number of seconds since 12:00 am Dec 31, 1989 UTC. */
58
 
59
typedef uint32          time_type;
60
 
61
 
62
/* Symbol type for waypoints. */
63
 
64
typedef uint16          symbol_type;
65
 
66
 
67
/* Symbol values for waypoints */
68
 
69
typedef enum {
70
 
71
  /* Marine symbols */
72
 
73
  sym_anchor          =   0,  /* white anchor symbol              */
74
  sym_bell            =   1,  /* white bell symbol                */
75
  sym_diamond_grn     =   2,  /* green diamond symbol             */
76
  sym_diamond_red     =   3,  /* red diamond symbol               */
77
  sym_dive1           =   4,  /* diver down flag 1                */
78
  sym_dive2           =   5,  /* diver down flag 2                */
79
  sym_dollar          =   6,  /* white dollar symbol              */
80
  sym_fish            =   7,  /* white fish symbol                */
81
  sym_fuel            =   8,  /* white fuel symbol                */
82
  sym_horn            =   9,  /* white horn symbol                */
83
  sym_house           =  10,  /* white house symbol               */
84
  sym_knife           =  11,  /* white knife & fork symbol        */
85
  sym_light           =  12,  /* white light symbol               */
86
  sym_mug             =  13,  /* white mug symbol                 */
87
  sym_skull           =  14,  /* white skull and crossbones symbol*/
88
  sym_square_grn      =  15,  /* green square symbol              */
89
  sym_square_red      =  16,  /* red square symbol                */
90
  sym_wbuoy           =  17,  /* white buoy waypoint symbol       */
91
  sym_wpt_dot         =  18,  /* waypoint dot                     */
92
  sym_wreck           =  19,  /* white wreck symbol               */
93
  sym_null            =  20,  /* null symbol (transparent)        */
94
  sym_mob             =  21,  /* man overboard symbol             */
95
  sym_buoy_ambr       =  22,  /* amber map buoy symbol            */
96
  sym_buoy_blck       =  23,  /* black map buoy symbol            */
97
  sym_buoy_blue       =  24,  /* blue map buoy symbol             */
98
  sym_buoy_grn        =  25,  /* green map buoy symbol            */
99
  sym_buoy_grn_red    =  26,  /* green/red map buoy symbol        */
100
  sym_buoy_grn_wht    =  27,  /* green/white map buoy symbol      */
101
  sym_buoy_orng       =  28,  /* orange map buoy symbol           */
102
  sym_buoy_red        =  29,  /* red map buoy symbol              */
103
  sym_buoy_red_grn    =  30,  /* red/green map buoy symbol        */
104
  sym_buoy_red_wht    =  31,  /* red/white map buoy symbol        */
105
  sym_buoy_violet     =  32,  /* violet map buoy symbol           */
106
  sym_buoy_wht        =  33,  /* white map buoy symbol            */
107
  sym_buoy_wht_grn    =  34,  /* white/green map buoy symbol      */
108
  sym_buoy_wht_red    =  35,  /* white/red map buoy symbol        */
109
  sym_dot             =  36,  /* white dot symbol                 */
110
  sym_rbcn            =  37,  /* radio beacon symbol              */
111
  sym_boat_ramp       = 150,  /* boat ramp symbol                 */
112
  sym_camp            = 151,  /* campground symbol                */
113
  sym_restrooms       = 152,  /* restrooms symbol                 */
114
  sym_showers         = 153,  /* shower symbol                    */
115
  sym_drinking_wtr    = 154,  /* drinking water symbol            */
116
  sym_phone           = 155,  /* telephone symbol                 */
117
  sym_1st_aid         = 156,  /* first aid symbol                 */
118
  sym_info            = 157,  /* information symbol               */
119
  sym_parking         = 158,  /* parking symbol                   */
120
  sym_park            = 159,  /* park symbol                      */
121
  sym_picnic          = 160,  /* picnic symbol                    */
122
  sym_scenic          = 161,  /* scenic area symbol               */
123
  sym_skiing          = 162,  /* skiing symbol                    */
124
  sym_swimming        = 163,  /* swimming symbol                  */
125
  sym_dam             = 164,  /* dam symbol                       */
126
  sym_controlled      = 165,  /* controlled area symbol           */
127
  sym_danger          = 166,  /* danger symbol                    */
128
  sym_restricted      = 167,  /* restricted area symbol           */
129
  sym_null_2          = 168,  /* null symbol                      */
130
  sym_ball            = 169,  /* ball symbol                      */
131
  sym_car             = 170,  /* car symbol                       */
132
  sym_deer            = 171,  /* deer symbol                      */
133
  sym_shpng_cart      = 172,  /* shopping cart symbol             */
134
  sym_lodging         = 173,  /* lodging symbol                   */
135
  sym_mine            = 174,  /* mine symbol                      */
136
  sym_trail_head      = 175,  /* trail head symbol                */
137
  sym_truck_stop      = 176,  /* truck stop symbol                */
138
  sym_user_exit       = 177,  /* user exit symbol                 */
139
  sym_flag            = 178,  /* flag symbol                      */
140
  sym_circle_x        = 179,  /* circle with x in the center      */
141
  sym_open_24hr       = 180,  /* open 24 hours symbol             */
142
  sym_fhs_facility    = 181,  /* U Fishing Hot Spots(TM) Facility */
143
  sym_bot_cond        = 182,  /* Bottom Conditions                */
144
  sym_tide_pred_stn   = 183,  /* Tide/Current Prediction Station  */
145
  sym_anchor_prohib   = 184,  /* U anchor prohibited symbol       */
146
  sym_beacon          = 185,  /* U beacon symbol                  */
147
  sym_coast_guard     = 186,  /* U coast guard symbol             */
148
  sym_reef            = 187,  /* U reef symbol                    */
149
  sym_weedbed         = 188,  /* U weedbed symbol                 */
150
  sym_dropoff         = 189,  /* U dropoff symbol                 */
151
  sym_dock            = 190,  /* U dock symbol                    */
152
  sym_marina          = 191,  /* U marina symbol                  */
153
  sym_bait_tackle     = 192,  /* U bait and tackle symbol         */
154
  sym_stump           = 193,  /* U stump symbol                   */
155
 
156
  /* User customizable symbols */
157
 
158
  sym_begin_custom   = 7680,  /* first user customizable symbol   */
159
  sym_end_custom     = 8191,  /* last user customizable symbol    */
160
 
161
  /* Land symbols */
162
 
163
  sym_is_hwy         = 8192,  /* interstate hwy symbol            */
164
  sym_us_hwy         = 8193,  /* us hwy symbol                    */
165
  sym_st_hwy         = 8194,  /* state hwy symbol                 */
166
  sym_mi_mrkr        = 8195,  /* mile marker symbol               */
167
  sym_trcbck         = 8196,  /* TracBack (feet) symbol           */
168
  sym_golf           = 8197,  /* golf symbol                      */
169
  sym_sml_cty        = 8198,  /* small city symbol                */
170
  sym_med_cty        = 8199,  /* medium city symbol               */
171
  sym_lrg_cty        = 8200,  /* large city symbol                */
172
  sym_freeway        = 8201,  /* intl freeway hwy symbol          */
173
  sym_ntl_hwy        = 8202,  /* intl national hwy symbol         */
174
  sym_cap_cty        = 8203,  /* capitol city symbol (star)       */
175
  sym_amuse_pk       = 8204,  /* amusement park symbol            */
176
  sym_bowling        = 8205,  /* bowling symbol                   */
177
  sym_car_rental     = 8206,  /* car rental symbol                */
178
  sym_car_repair     = 8207,  /* car repair symbol                */
179
  sym_fastfood       = 8208,  /* fast food symbol                 */
180
  sym_fitness        = 8209,  /* fitness symbol                   */
181
  sym_movie          = 8210,  /* movie symbol                     */
182
  sym_museum         = 8211,  /* museum symbol                    */
183
  sym_pharmacy       = 8212,  /* pharmacy symbol                  */
184
  sym_pizza          = 8213,  /* pizza symbol                     */
185
  sym_post_ofc       = 8214,  /* post office symbol               */
186
  sym_rv_park        = 8215,  /* RV park symbol                   */
187
  sym_school         = 8216,  /* school symbol                    */
188
  sym_stadium        = 8217,  /* stadium symbol                   */
189
  sym_store          = 8218,  /* dept. store symbol               */
190
  sym_zoo            = 8219,  /* zoo symbol                       */
191
  sym_gas_plus       = 8220,  /* convenience store symbol         */
192
  sym_faces          = 8221,  /* live theater symbol              */
193
  sym_ramp_int       = 8222,  /* ramp intersection symbol         */
194
  sym_st_int         = 8223,  /* street intersection symbol       */
195
  sym_weigh_sttn     = 8226,  /* inspection/weigh station symbol  */
196
  sym_toll_booth     = 8227,  /* toll booth symbol                */
197
  sym_elev_pt        = 8228,  /* elevation point symbol           */
198
  sym_ex_no_srvc     = 8229,  /* exit without services symbol     */
199
  sym_geo_place_mm   = 8230,  /* Geographic place name, man-made  */
200
  sym_geo_place_wtr  = 8231,  /* Geographic place name, water     */
201
  sym_geo_place_lnd  = 8232,  /* Geographic place name, land      */
202
  sym_bridge         = 8233,  /* bridge symbol                    */
203
  sym_building       = 8234,  /* building symbol                  */
204
  sym_cemetery       = 8235,  /* cemetery symbol                  */
205
  sym_church         = 8236,  /* church symbol                    */
206
  sym_civil          = 8237,  /* civil location symbol            */
207
  sym_crossing       = 8238,  /* crossing symbol                  */
208
  sym_hist_town      = 8239,  /* historical town symbol           */
209
  sym_levee          = 8240,  /* levee symbol                     */
210
  sym_military       = 8241,  /* military location symbol         */
211
  sym_oil_field      = 8242,  /* oil field symbol                 */
212
  sym_tunnel         = 8243,  /* tunnel symbol                    */
213
  sym_beach          = 8244,  /* beach symbol                     */
214
  sym_forest         = 8245,  /* forest symbol                    */
215
  sym_summit         = 8246,  /* summit symbol                    */
216
  sym_lrg_ramp_int   = 8247,  /* large ramp intersection symbol   */
217
  sym_lrg_ex_no_srvc = 8248,  /* large exit without services smbl */
218
  sym_badge          = 8249,  /* police/official badge symbol     */
219
  sym_cards          = 8250,  /* gambling/casino symbol           */
220
  sym_snowski        = 8251,  /* snow skiing symbol               */
221
  sym_iceskate       = 8252,  /* ice skating symbol               */
222
  sym_wrecker        = 8253,  /* tow truck (wrecker) symbol       */
223
  sym_border         = 8254,  /* border crossing (port of entry)  */
224
  sym_geocache       = 8255,  /* geocache location                */
225
  sym_geocache_fnd   = 8256,  /* found geocache                   */
226
  sym_cntct_smiley   = 8257,  /* Rino contact symbol, "smiley"    */
227
  sym_cntct_ball_cap = 8258,  /* Rino contact symbol, "ball cap"  */
228
  sym_cntct_big_ears = 8259,  /* Rino contact symbol, "big ear"   */
229
  sym_cntct_spike    = 8260,  /* Rino contact symbol, "spike"     */
230
  sym_cntct_goatee   = 8261,  /* Rino contact symbol, "goatee"    */
231
  sym_cntct_afro     = 8262,  /* Rino contact symbol, "afro"      */
232
  sym_cntct_dreads   = 8263,  /* Rino contact symbol, "dreads"    */
233
  sym_cntct_female1  = 8264,  /* Rino contact symbol, "female 1"  */
234
  sym_cntct_female2  = 8265,  /* Rino contact symbol, "female 2"  */
235
  sym_cntct_female3  = 8266,  /* Rino contact symbol, "female 3"  */
236
  sym_cntct_ranger   = 8267,  /* Rino contact symbol, "ranger"    */
237
  sym_cntct_kung_fu  = 8268,  /* Rino contact symbol, "kung fu"   */
238
  sym_cntct_sumo     = 8269,  /* Rino contact symbol, "sumo"      */
239
  sym_cntct_pirate   = 8270,  /* Rino contact symbol, "pirate"    */
240
  sym_cntct_biker    = 8271,  /* Rino contact symbol, "biker"     */
241
  sym_cntct_alien    = 8272,  /* Rino contact symbol, "alien"     */
242
  sym_cntct_bug      = 8273,  /* Rino contact symbol, "bug"       */
243
  sym_cntct_cat      = 8274,  /* Rino contact symbol, "cat"       */
244
  sym_cntct_dog      = 8275,  /* Rino contact symbol, "dog"       */
245
  sym_cntct_pig      = 8276,  /* Rino contact symbol, "pig"       */
246
  sym_hydrant        = 8282,  /* water hydrant symbol             */
247
  sym_flag_blue      = 8284,  /* blue flag symbol                 */
248
  sym_flag_green     = 8285,  /* green flag symbol                */
249
  sym_flag_red       = 8286,  /* red flag symbol                  */
250
  sym_pin_blue       = 8287,  /* blue pin symbol                  */
251
  sym_pin_green      = 8288,  /* green pin symbol                 */
252
  sym_pin_red        = 8289,  /* red pin symbol                   */
253
  sym_block_blue     = 8290,  /* blue block symbol                */
254
  sym_block_green    = 8291,  /* green block symbol               */
255
  sym_block_red      = 8292,  /* red block symbol                 */
256
  sym_bike_trail     = 8293,  /* bike trail symbol                */
257
  sym_circle_red     = 8294,  /* red circle symbol                */
258
  sym_circle_green   = 8295,  /* green circle symbol              */
259
  sym_circle_blue    = 8296,  /* blue circle symbol               */
260
  sym_diamond_blue   = 8299,  /* blue diamond symbol              */
261
  sym_oval_red       = 8300,  /* red oval symbol                  */
262
  sym_oval_green     = 8301,  /* green oval symbol                */
263
  sym_oval_blue      = 8302,  /* blue oval symbol                 */
264
  sym_rect_red       = 8303,  /* red rectangle symbol             */
265
  sym_rect_green     = 8304,  /* green rectangle symbol           */
266
  sym_rect_blue      = 8305,  /* blue rectangle symbol            */
267
  sym_square_blue    = 8308,  /* blue square symbol               */
268
  sym_letter_a_red   = 8309,  /* red letter 'A' symbol            */
269
  sym_letter_b_red   = 8310,  /* red letter 'B' symbol            */
270
  sym_letter_c_red   = 8311,  /* red letter 'C' symbol            */
271
  sym_letter_d_red   = 8312,  /* red letter 'D' symbol            */
272
  sym_letter_a_green = 8313,  /* green letter 'A' symbol          */
273
  sym_letter_b_green = 8314,  /* green letter 'B' symbol          */
274
  sym_letter_c_green = 8315,  /* green letter 'C' symbol          */
275
  sym_letter_d_green = 8316,  /* green letter 'D' symbol          */
276
  sym_letter_a_blue  = 8317,  /* blue letter 'A' symbol           */
277
  sym_letter_b_blue  = 8318,  /* blue letter 'B' symbol           */
278
  sym_letter_c_blue  = 8319,  /* blue letter 'C' symbol           */
279
  sym_letter_d_blue  = 8320,  /* blue letter 'D' symbol           */  
280
  sym_number_0_red   = 8321,  /* red number '0' symbol            */
281
  sym_number_1_red   = 8322,  /* red number '1' symbol            */
282
  sym_number_2_red   = 8323,  /* red number '2' symbol            */
283
  sym_number_3_red   = 8324,  /* red number '3' symbol            */
284
  sym_number_4_red   = 8325,  /* red number '4' symbol            */
285
  sym_number_5_red   = 8326,  /* red number '5' symbol            */
286
  sym_number_6_red   = 8327,  /* red number '6' symbol            */
287
  sym_number_7_red   = 8328,  /* red number '7' symbol            */
288
  sym_number_8_red   = 8329,  /* red number '8' symbol            */
289
  sym_number_9_red   = 8330,  /* red number '9' symbol            */
290
  sym_number_0_green = 8331,  /* green number '0' symbol          */
291
  sym_number_1_green = 8332,  /* green number '1' symbol          */
292
  sym_number_2_green = 8333,  /* green number '2' symbol          */
293
  sym_number_3_green = 8334,  /* green number '3' symbol          */
294
  sym_number_4_green = 8335,  /* green number '4' symbol          */
295
  sym_number_5_green = 8336,  /* green number '5' symbol          */
296
  sym_number_6_green = 8337,  /* green number '6' symbol          */
297
  sym_number_7_green = 8338,  /* green number '7' symbol          */
298
  sym_number_8_green = 8339,  /* green number '8' symbol          */
299
  sym_number_9_green = 8340,  /* green number '9' symbol          */
300
  sym_number_0_blue  = 8341,  /* blue number '0' symbol           */
301
  sym_number_1_blue  = 8342,  /* blue number '1' symbol           */
302
  sym_number_2_blue  = 8343,  /* blue number '2' symbol           */
303
  sym_number_3_blue  = 8344,  /* blue number '3' symbol           */
304
  sym_number_4_blue  = 8345,  /* blue number '4' symbol           */
305
  sym_number_5_blue  = 8346,  /* blue number '5' symbol           */
306
  sym_number_6_blue  = 8347,  /* blue number '6' symbol           */
307
  sym_number_7_blue  = 8348,  /* blue number '7' symbol           */
308
  sym_number_8_blue  = 8349,  /* blue number '8' symbol           */
309
  sym_number_9_blue  = 8350,  /* blue number '9' symbol           */
310
  sym_triangle_blue  = 8351,  /* blue triangle symbol             */
311
  sym_triangle_green = 8352,  /* green triangle symbol            */
312
  sym_triangle_red   = 8353,  /* red triangle symbol              */
313
  sym_food_asian     = 8359,  /* asian food symbol                */
314
  sym_food_deli      = 8360,  /* deli symbol                      */
315
  sym_food_italian   = 8361,  /* italian food symbol              */
316
  sym_food_seafood   = 8362,  /* seafood food symbol              */
317
  sym_food_steak     = 8363,  /* steak symbol                     */
318
 
319
  /* Aviation symbols */
320
 
321
  sym_airport        = 16384, /* airport symbol                   */
322
  sym_int            = 16385, /* intersection symbol              */
323
  sym_ndb            = 16386, /* non-directional beacon symbol    */
324
  sym_vor            = 16387, /* VHF omni-range symbol            */
325
  sym_heliport       = 16388, /* heliport symbol                  */
326
  sym_private        = 16389, /* private field symbol             */
327
  sym_soft_fld       = 16390, /* soft field symbol                */
328
  sym_tall_tower     = 16391, /* tall tower symbol                */
329
  sym_short_tower    = 16392, /* short tower symbol               */
330
  sym_glider         = 16393, /* glider symbol                    */
331
  sym_ultralight     = 16394, /* ultralight symbol                */
332
  sym_parachute      = 16395, /* parachute symbol                 */
333
  sym_vortac         = 16396, /* VOR/TACAN symbol                 */
334
  sym_vordme         = 16397, /* VOR-DME symbol                   */
335
  sym_faf            = 16398, /* first approach fix               */
336
  sym_lom            = 16399, /* localizer outer marker           */
337
  sym_map            = 16400, /* missed approach point            */
338
  sym_tacan          = 16401, /* TACAN symbol                     */
339
  sym_seaplane       = 16402  /* Seaplane Base                    */
340
} symbol_value;
341
 
342
 
343
typedef struct D100 {
344
  char             ident[6];       /* identifier            */
345
  position_type    posn;           /* position              */
346
  uint32           unused;         /* should be set to zero */
347
  char             cmnt[40];       /* comment               */
348
} D100;
349
 
350
 
351
typedef struct D101 {
352
  char             ident[6];       /* identifier            */
353
  position_type    posn;           /* position              */
354
  uint32           unused;         /* should be set to zero */
355
  char             cmnt[40];       /* comment               */
356
  float32          dst;            /* proximity distance (meters) */
357
  uint8            smbl;           /* symbol id                   */
358
} D101;
359
 
360
 
361
typedef struct D102 {
362
  char             ident[6];      /* identifier                   */
363
  position_type    posn;          /* position                     */
364
  uint32           unused;        /* should be set to zero        */
365
  char             cmnt[40];      /* comment                      */
366
  float32          dst;           /* proximity distance (meters)  */
367
  symbol_type      smbl;          /* symbol id                    */
368
} D102;
369
 
370
 
371
typedef struct D103 {
372
  char             ident[6];      /* identifier                    */
373
  position_type    posn;          /* position                      */
374
  uint32           unused;        /* should be set to zero         */
375
  char             cmnt[40];      /* comment                       */
376
  uint8            smbl;          /* symbol id                     */
377
  uint8            dspl;          /* display option                */
378
} D103;
379
 
380
 
381
/* The enumerated values for the "smbl" member of the D103 are: */
382
 
383
typedef enum {
384
  D103_smbl_dot        =  0,   /* dot symbol                                */
385
  D103_smbl_house      =  1,   /* house symbol                              */
386
  D103_smbl_gas        =  2,   /* gas symbol                                */
387
  D103_smbl_car        =  3,   /* car symbol                                */
388
  D103_smbl_fish       =  4,   /* fish symbol                               */
389
  D103_smbl_boat       =  5,   /* boat symbol                               */
390
  D103_smbl_anchor     =  6,   /* anchor symbol                             */
391
  D103_smbl_wreck      =  7,   /* wreck symbol                              */
392
  D103_smbl_exit       =  8,   /* exit symbol                               */
393
  D103_smbl_skull      =  9,   /* skull symbol                              */
394
  D103_smbl_flag       = 10,   /* flag symbol                               */
395
  D103_smbl_camp       = 11,   /* camp symbol                               */
396
  D103_smbl_circle_x   = 12,   /* circle with x symbol                      */
397
  D103_smbl_deer       = 13,   /* deer symbol                               */
398
  D103_smbl_1st_aid    = 14,   /* first aid symbol                          */
399
  D103_smbl_back_track = 15    /* back track symbol                         */
400
} D103_smbl;
401
 
402
 
403
/* The enumerated values for the "dspl" member of the D103 are: */
404
 
405
typedef enum {
406
  D103_dspl_name       =  0,   /* Display symbol with waypoint name         */
407
  D103_dspl_none       =  1,   /* Display symbol by itself                  */
408
  D103_dspl_cmnt       =  2    /* Display symbol with comment               */
409
} D103_dspl;
410
 
411
 
412
typedef struct D104 {
413
  char              ident[6];        /* identifier                    */
414
  position_type     posn;            /* position                      */
415
  uint32            unused;          /* should be set to zero         */
416
  char              cmnt[40];        /* comment                       */
417
  float32           dst;             /* proximity distance (meters)   */
418
  symbol_type       smbl;            /* symbol id                     */
419
  uint8             dspl;            /* display option                */
420
} D104;
421
 
422
 
423
/* The enumerated values for the "dspl" member of the D104 are: */
424
 
425
typedef enum {
426
  D104_dspl_smbl_none    = 0,    /* Display symbol by itself             */
427
  D104_dspl_smbl_only    = 1,    /* Display symbol by itself             */
428
  D104_dspl_smbl_name    = 3,    /* Display symbol with waypoint name    */
429
  D104_dspl_smbl_cmnt    = 5     /* Display symbol with comment          */
430
} D104_dspl;
431
 
432
 
433
typedef struct D105 {
434
  position_type     posn;         /* position                    */
435
  symbol_type       smbl;         /* symbol id                   */
436
  char *            wpt_ident;    /* null-terminated string      */
437
} D105;
438
 
439
 
440
typedef struct D106 {
441
  uint8             wpt_class;      /* class                   */
442
  uint8             subclass[13];   /* subclass                */
443
  position_type     posn;           /* position                */
444
  symbol_type       smbl;           /* symbol id               */
445
  char *            wpt_ident;      /* null-terminated string  */
446
  char *            lnk_ident;      /* null-terminated string  */
447
} D106;
448
 
449
 
450
typedef struct D107 {
451
  char              ident[6];   /* identifier                   */
452
  position_type     posn;       /* position                     */
453
  uint32            unused;     /* should be set to zero        */
454
  char              cmnt[40];   /* comment                      */
455
  uint8             smbl;       /* symbol id                    */
456
  uint8             dspl;       /* display option               */
457
  float32           dst;        /* proximity distance (meters)  */
458
  uint8             color;      /* waypoint color               */
459
} D107;
460
 
461
 
462
typedef enum {
463
  D107_clr_default    = 0,              /* Default waypoint color        */
464
  D107_clr_red        = 1,              /* Red                           */
465
  D107_clr_green      = 2,              /* Green                         */
466
  D107_clr_blue       = 3               /* Blue                          */
467
} D107_clr;
468
 
469
 
470
typedef struct D108 {   /*                                 size   */
471
  uint8            wpt_class;    /* class (see below)               1      */
472
  uint8            color;        /* color (see below)               1      */
473
  uint8            dspl;         /* display options (see below)     1      */
474
  uint8            attr;         /* attributes (see below)          1      */
475
  symbol_type      smbl;         /* waypoint symbol                 2      */
476
  uint8            subclass[18]; /* subclass                        18     */
477
  position_type    posn;         /* 32 bit semicircle               8      */
478
  float32          alt;          /* altitude in meters              4      */
479
  float32          dpth;         /* depth in meters                 4      */
480
  float32          dist;         /* proximity distance in meters    4      */
481
  char             state[2];     /* state                           2      */
482
  char             cc[2];        /* country code                    2      */
483
  char *           ident;        /* variable length string          1-51   */
484
  char *           comment;      /* waypoint user comment           1-51   */
485
  char *           facility;     /* facility name                   1-31   */
486
  char *           city;         /* city name                       1-25   */
487
  char *           addr;         /* address number                  1-51   */
488
  char *           cross_road;   /* intersecting road label         1-51   */
489
} D108;
490
 
491
 
492
/* Enumerated values for the "wpt_class" member of the D108 are: */
493
 
494
typedef enum {
495
  D108_user_wpt           = 0x00,     /* User waypoint                     */
496
  D108_avtn_apt_wpt       = 0x40,     /* Aviation Airport waypoint         */
497
  D108_avtn_int_wpt       = 0x41,     /* Aviation Intersection waypoint    */
498
  D108_avtn_ndb_wpt       = 0x42,     /* Aviation NDB waypoint             */
499
  D108_avtn_vor_wpt       = 0x43,     /* Aviation VOR waypoint             */
500
  D108_avtn_arwy_wpt      = 0x44,     /* Aviation Airport Runway waypoint  */
501
  D108_avtn_aint_wpt      = 0x45,     /* Aviation Airport Intersection     */
502
  D108_avtn_andb_wpt      = 0x46,     /* Aviation Airport NDB waypoint     */
503
  D108_map_pnt_wpt        = 0x80,     /* Map Point waypoint                */
504
  D108_map_area_wpt       = 0x81,     /* Map Area waypoint                 */
505
  D108_map_int_wpt        = 0x82,     /* Map Intersection waypoint         */
506
  D108_map_adrs_wpt       = 0x83,     /* Map Address waypoint              */
507
  D108_map_label_wpt      = 0x84,     /* Map Label Waypoint                */
508
  D108_map_line_wpt       = 0x85      /* Map Line Waypoint                 */
509
} D108_wpt_class;
510
 
511
 
512
/* The "color" member can be one of the following values: */
513
 
514
typedef enum {
515
  D108_black          = 0x00,
516
  D108_dark_red       = 0x01,
517
  D108_dark_green     = 0x02,
518
  D108_dark_yellow    = 0x03,
519
  D108_dark_blue      = 0x04,
520
  D108_dark_magenta   = 0x05,
521
  D108_dark_cyan      = 0x06,
522
  D108_light_gray     = 0x07,
523
  D108_dark_gray      = 0x08,
524
  D108_red            = 0x09,
525
  D108_green          = 0x0a,
526
  D108_yellow         = 0x0b,
527
  D108_blue           = 0x0c,
528
  D108_magenta        = 0x0d,
529
  D108_cyan           = 0x0e,
530
  D108_white          = 0x0f,
531
  D108_default_color  = 0xff
532
} D108_color;
533
 
534
 
535
typedef struct D109 {    /*                                  size */
536
  uint8           dtyp;           /* data packet type (0x01 for D109) 1    */
537
  uint8           wpt_class;      /* class                            1    */
538
  uint8           dspl_color;     /* display & color (see below)      1    */
539
  uint8           attr;           /* attributes (0x70 for D109)       1    */
540
  symbol_type     smbl;           /* waypoint symbol                  2    */
541
  uint8           subclass[18];   /* subclass                         18   */
542
  position_type   posn;           /* 32 bit semicircle                8    */
543
  float32         alt;            /* altitude in meters               4    */
544
  float32         dpth;           /* depth in meters                  4    */
545
  float32         dist;           /* proximity distance in meters     4    */
546
  char            state[2];       /* state                            2    */
547
  char            cc[2];          /* country code                     2    */
548
  uint32          ete;            /* outbound link ete in seconds     4    */
549
  char *          ident;         /* variable length string           1-51 */
550
  char *          comment;       /* waypoint user comment            1-51 */
551
  char *          facility;      /* facility name                    1-31 */
552
  char *          city;          /* city name                        1-25 */
553
  char *          addr;          /* address number                   1-51 */
554
  char *          cross_road;    /* intersecting road label          1-51 */
555
} D109;
556
 
557
 
558
typedef struct D110 {    /*                                  size */
559
  uint8           dtyp;           /* data packet type (0x01 for D110) 1    */
560
  uint8           wpt_class;      /* class                            1    */
561
  uint8           dspl_color;     /* display & color (see below)      1    */
562
  uint8           attr;           /* attributes (0x80 for D110)       1    */
563
  symbol_type     smbl;           /* waypoint symbol                  2    */
564
  uint8           subclass[18];   /* subclass                         18   */
565
  position_type   posn;           /* 32 bit semicircle                8    */
566
  float32         alt;            /* altitude in meters               4    */
567
  float32         dpth;           /* depth in meters                  4    */
568
  float32         dist;           /* proximity distance in meters     4    */
569
  char            state[2];       /* state                            2    */
570
  char            cc[2];          /* country code                     2    */
571
  uint32          ete;            /* outbound link ete in seconds     4    */
572
  float32         temp;           /* temperature                      4    */
573
  time_type       time;           /* timestamp                        4    */
574
  uint16          wpt_cat;        /* category membership              2    */
575
  char *          ident;          /* variable length string           1-51 */
576
  char *          comment;        /* waypoint user comment            1-51 */
577
  char *          facility;       /* facility name                    1-31 */
578
  char *          city;           /* city name                        1-25 */
579
  char *          addr;           /* address number                   1-51 */
580
  char *          cross_road;     /* intersecting road label          1-51 */
581
} D110;
582
 
583
 
584
/* Enumerated values for the "wpt_class" member of the D108 are: */
585
 
586
typedef enum {
587
  D110_user_wpt           = 0x00,     /* User waypoint                     */
588
  D110_avtn_apt_wpt       = 0x40,     /* Aviation Airport waypoint         */
589
  D110_avtn_int_wpt       = 0x41,     /* Aviation Intersection waypoint    */
590
  D110_avtn_ndb_wpt       = 0x42,     /* Aviation NDB waypoint             */
591
  D110_avtn_vor_wpt       = 0x43,     /* Aviation VOR waypoint             */
592
  D110_avtn_arwy_wpt      = 0x44,     /* Aviation Airport Runway waypoint  */
593
  D110_avtn_aint_wpt      = 0x45,     /* Aviation Airport Intersection     */
594
  D110_avtn_andb_wpt      = 0x46,     /* Aviation Airport NDB waypoint     */
595
  D110_map_pnt_wpt        = 0x80,     /* Map Point waypoint                */
596
  D110_map_area_wpt       = 0x81,     /* Map Area waypoint                 */
597
  D110_map_int_wpt        = 0x82,     /* Map Intersection waypoint         */
598
  D110_map_adrs_wpt       = 0x83,     /* Map Address waypoint              */
599
  D110_map_line_wpt       = 0x84      /* Map Line Waypoint                 */
600
} D110_wpt_class;
601
 
602
 
603
typedef enum {
604
  D110_black          = 0x00,
605
  D110_dark_red       = 0x01,
606
  D110_dark_green     = 0x02,
607
  D110_dark_yellow    = 0x03,
608
  D110_dark_blue      = 0x04,
609
  D110_dark_magenta   = 0x05,
610
  D110_dark_cyan      = 0x06,
611
  D110_light_gray     = 0x07,
612
  D110_dark_gray      = 0x08,
613
  D110_red            = 0x09,
614
  D110_green          = 0x0a,
615
  D110_yellow         = 0x0b,
616
  D110_blue           = 0x0c,
617
  D110_magenta        = 0x0d,
618
  D110_cyan           = 0x0e,
619
  D110_white          = 0x0f,
620
  D110_transparent    = 0x10
621
} D110_color;
622
 
623
 
624
typedef enum {
625
  D110_symbol_name     = 0,    /* Display symbol with waypoint name    */
626
  D110_symbol_only     = 1,    /* Display symbol by itself             */
627
  D110_symbol_comment  = 2     /* Display symbol with comment          */
628
} D110_dspl;
629
 
630
 
631
typedef struct D120 {
632
  char              name[17];        /* category name */
633
} D120;
634
 
635
 
636
typedef struct D150 {
637
  char              ident[6];        /* identifier                */
638
  char              cc[2];           /* country code              */
639
  uint8             wpt_class;       /* class                     */
640
  position_type     posn;            /* position                  */
641
  sint16            alt;             /* altitude (meters)         */
642
  char              city[24];        /* city                      */
643
  char              state[2];        /* state                     */
644
  char              name[30];        /* facility name             */
645
  char              cmnt[40];        /* comment                   */
646
} D150;
647
 
648
 
649
/* Enumerated values for the "wpt_class" member of the D150 are: */
650
 
651
typedef enum {
652
  D150_apt_wpt_class    = 0,   /* airport waypoint class                   */
653
  D150_int_wpt_class    = 1,   /* intersection waypoint class              */
654
  D150_ndb_wpt_class    = 2,   /* NDB waypoint class                       */
655
  D150_vor_wpt_class    = 3,   /* VOR waypoint class                       */
656
  D150_usr_wpt_class    = 4,   /* user defined waypoint class              */
657
  D150_rwy_wpt_class    = 5,   /* airport runway threshold waypoint class  */
658
  D150_aint_wpt_class   = 6,   /* airport intersection waypoint class      */
659
  D150_locked_wpt_class = 7    /* locked waypoint class                    */
660
} D150_wpt_class;
661
 
662
 
663
typedef struct D151 {
664
  char             ident[6];        /* identifier                   */
665
  position_type    posn;            /* position                     */
666
  uint32           unused;          /* should be set to zero        */
667
  char             cmnt[40];        /* comment                      */
668
  float32          dst;             /* proximity distance (meters)  */
669
  char             name[30];        /* facility name                */
670
  char             city[24];        /* city                         */
671
  char             state[2];        /* state                        */
672
  sint16           alt;             /* altitude (meters)            */
673
  char             cc[2];           /* country code                 */
674
  char             unused2;         /* should be set to zero        */
675
  uint8            wpt_class;       /* class                        */
676
} D151;
677
 
678
 
679
/* 
680
   The enumerated values for the "wpt_class" member of the D151 are: 
681
*/
682
 
683
typedef enum {
684
  D151_apt_wpt_class     = 0,      /* airport waypoint class             */
685
  D151_vor_wpt_class     = 1,      /* VOR waypoint class                 */
686
  D151_usr_wpt_class     = 2,      /* user defined waypoint class        */
687
  D151_locked_wpt_class  = 3       /* locked waypoint class              */
688
} D151_wpt_class;
689
 
690
 
691
typedef struct D152 { 
692
  char            ident[6];        /* identifier                     */
693
  position_type   posn;            /* position                       */
694
  uint32          unused;          /* should be set to zero          */
695
  char            cmnt[40];        /* comment                        */
696
  float32         dst;             /* proximity distance (meters)    */
697
  char            name[30];        /* facility name                  */
698
  char            city[24];        /* city                           */
699
  char            state[2];        /* state                          */
700
  sint16          alt;             /* altitude (meters)              */
701
  char            cc[2];           /* country code                   */
702
  char            unused2;         /* should be set to zero          */
703
  uint8           wpt_class;       /* class                          */
704
} D152;
705
 
706
 
707
/* Enumerated values for the "wpt_class" member of the D152 are: */
708
 
709
typedef enum {
710
  D152_apt_wpt_class    = 0,             /* airport waypoint class         */
711
  D152_int_wpt_class    = 1,             /* intersection waypoint class    */
712
  D152_ndb_wpt_class    = 2,             /* NDB waypoint class             */
713
  D152_vor_wpt_class    = 3,             /* VOR waypoint class             */
714
  D152_usr_wpt_class    = 4,             /* user defined waypoint class    */
715
  D152_locked_wpt_class = 5              /* locked waypoint class          */
716
} D152_wpt_class;
717
 
718
 
719
typedef struct D154 {
720
  char              ident[6];        /* identifier                     */
721
  position_type     posn;            /* position                       */
722
  uint32            unused;          /* should be set to zero          */
723
  char              cmnt[40];        /* comment                        */
724
  float32           dst;             /* proximity distance (meters)    */
725
  char              name[30];        /* facility name                  */
726
  char              city[24];        /* city                           */
727
  char              state[2];        /* state                          */
728
  sint16            alt;             /* altitude (meters)              */
729
  char              cc[2];           /* country code                   */
730
  char              unused2;         /* should be set to zero          */
731
  uint8             wpt_class;       /* class                          */
732
  symbol_type       smbl;            /* symbol id                      */
733
} D154;
734
 
735
 
736
/* Enumerated values for the "wpt_class" member of the D154 are: */
737
 
738
typedef enum {
739
  D154_apt_wpt_class    = 0,     /* airport waypoint class                  */
740
  D154_int_wpt_class    = 1,     /* intersection waypoint class             */
741
  D154_ndb_wpt_class    = 2,     /* NDB waypoint class                      */
742
  D154_vor_wpt_class    = 3,     /* VOR waypoint class                      */
743
  D154_usr_wpt_class    = 4,     /* user defined waypoint class             */
744
  D154_rwy_wpt_class    = 5,     /* airport runway threshold waypoint class */
745
  D154_aint_wpt_class   = 6,     /* airport intersection waypoint class     */
746
  D154_andb_wpt_class   = 7,     /* airport NDB waypoint class              */
747
  D154_sym_wpt_class    = 8,     /* user defined symbol-only waypoint class */
748
  D154_locked_wpt_class = 9      /* locked waypoint class                   */
749
} D154_wpt_class;
750
 
751
 
752
typedef struct D155 {
753
  char              ident[6];        /* identifier                   */
754
  position_type     posn;            /* position                     */
755
  uint32            unused;          /* should be set to zero        */
756
  char              cmnt[40];        /* comment                      */
757
  float32           dst;             /* proximity distance (meters)  */
758
  char              name[30];        /* facility name                */
759
  char              city[24];        /* city                         */
760
  char              state[2];        /* state                        */
761
  sint16            alt;             /* altitude (meters)            */
762
  char              cc[2];           /* country code                 */
763
  char              unused2;         /* should be set to zero        */
764
  uint8             wpt_class;       /* class                        */
765
  symbol_type       smbl;            /* symbol id                    */
766
  uint8             dspl;            /* display option               */
767
} D155;
768
 
769
 
770
/* The enumerated values for the "dspl" member of the D155 are: */
771
 
772
typedef enum {
773
  D155_dspl_smbl_only   = 1,  /* Display symbol by itself               */
774
  D155_dspl_smbl_name   = 3,  /* Display symbol with waypoint name      */
775
  D155_dspl_smbl_cmnt   = 5   /* Display symbol with comment            */
776
} D155_dspl;
777
 
778
 
779
/* Enumerated values for the "wpt_class" member of the D155 are: */
780
 
781
typedef enum {
782
  D155_apt_wpt_class    = 0,  /* airport waypoint class                */
783
  D155_int_wpt_class    = 1,  /* intersection waypoint class           */
784
  D155_ndb_wpt_class    = 2,  /* NDB waypoint class                    */
785
  D155_vor_wpt_class    = 3,  /* VOR waypoint class                    */
786
  D155_usr_wpt_class    = 4,  /* user defined waypoint class           */
787
  D155_locked_wpt_class = 5   /* locked waypoint class                 */
788
} D155_wpt_class;
789
 
790
 
791
typedef uint8    D200;  /* route number  */
792
 
793
 
794
typedef struct D201 {
795
  uint8                 nmbr;       /* route number            */
796
  char                  cmnt[20];   /* comment                 */
797
} D201;
798
 
799
 
800
typedef struct D202 {
801
  char *                rte_ident;  /* null-terminated string  */
802
} D202;
803
 
804
 
805
typedef struct D210 {
806
  uint16                class;        /* link class; see below           */
807
  uint8                 subclass[18]; /* sublcass                        */
808
  char *                ident;        /* variable length string          */
809
} D210;
810
 
811
 
812
/* The "class" member can be one of the following values: */
813
 
814
typedef enum {
815
  D210_line           = 0,
816
  D210_link           = 1,
817
  D210_net            = 2,
818
  D210_direct         = 3,
819
  D210_snap           = 0xff
820
} D210_class;
821
 
822
 
823
typedef struct D300 {
824
  position_type     posn;      /* position                        */
825
  uint32            time;      /* time                            */
826
  bool              new_trk;   /* new track segment?              */
827
} D300;
828
 
829
 
830
typedef struct D301 {
831
  position_type     posn;     /* position                  */
832
  uint32            time;     /* time                      */
833
  float32           alt;      /* altitude in meters        */
834
  float32           dpth;     /* depth in meters           */
835
  bool              new_trk;  /* new track segment?        */
836
} D301;
837
 
838
 
839
typedef struct D302 {
840
  position_type     posn;
841
  uint32            time;
842
  float32           alt;
843
  float32           dpth;
844
  float32           temp;
845
  bool              new_trk;
846
} D302;
847
 
848
 
849
typedef struct D303 {
850
  position_type     posn;
851
  uint32            time;
852
  float32           alt;
853
  uint8             heart_rate;
854
} D303;
855
 
856
 
857
typedef struct D304 {
858
  position_type     posn;
859
  uint32            time;
860
  float32           alt;
861
  float32           distance;
862
  uint8             heart_rate;
863
  uint8             cadence;
864
  bool              sensor;
865
} D304;
866
 
867
 
868
typedef struct D310 {
869
  bool          dspl;           /* display on the map?        */
870
  uint8         color;          /* color (same as D108)       */
871
  char *        trk_ident;      /* null-terminated string     */
872
} D310;
873
 
874
 
875
typedef struct D311 {
876
  uint16        index;   /* unique among all tracks received from device */
877
} D311;
878
 
879
 
880
typedef struct D312 {
881
  bool          dspl;           /* display on the map?    */
882
  uint8         color;          /* color (same as D110)   */
883
  char *        trk_ident;      /* null-terminated string */
884
} D312;
885
 
886
 
887
typedef enum {
888
  D312_black          = 0x00,
889
  D312_dark_red       = 0x01,
890
  D312_dark_green     = 0x02,
891
  D312_dark_yellow    = 0x03,
892
  D312_dark_blue      = 0x04,
893
  D312_dark_magenta   = 0x05,
894
  D312_dark_cyan      = 0x06,
895
  D312_light_gray     = 0x07,
896
  D312_dark_gray      = 0x08,
897
  D312_red            = 0x09,
898
  D312_green          = 0x0a,
899
  D312_yellow         = 0x0b,
900
  D312_blue           = 0x0c,
901
  D312_magenta        = 0x0d,
902
  D312_cyan           = 0x0e,
903
  D312_white          = 0x0f,
904
  D312_transparent    = 0x10,
905
  D312_default_color  = 0xff
906
} D312_color;
907
 
908
 
909
typedef struct D400 {
910
  D100    wpt;  /* waypoint                       */
911
  float32          dst;  /* proximity distance (meters)    */
912
} D400;
913
 
914
 
915
typedef struct D403 { 
916
  D103   wpt;  /* waypoint                          */
917
  float32         dst;  /* proximity distance (meters)       */
918
} D403;
919
 
920
 
921
typedef struct D450 {
922
  sint16          idx;  /* proximity index                   */
923
  D150   wpt;  /* waypoint                          */
924
  float32         dst;  /* proximity distance (meters)       */
925
} D450;
926
 
927
 
928
typedef struct D500 {
929
  sint16        wn;    /* week number                          (weeks)    */
930
  float32       toa;   /* almanac data reference time              (s)    */
931
  float32       af0;   /* clock correction coefficient             (s)    */
932
  float32       af1;   /* clock correction coefficient           (s/s)    */
933
  float32       e;     /* eccentricity                             (-)    */
934
  float32       sqrta; /* square root of semi-major axis (a)  (m**1/2)    */
935
  float32       m0;    /* mean anomaly at reference time           (r)    */
936
  float32       w;     /* argument of perigee                      (r)    */
937
  float32       omg0;  /* right ascension                          (r)    */
938
  float32       odot;  /* rate of right ascension                (r/s)    */
939
  float32       i;     /* inclination angle                        (r)    */
940
} D500;
941
 
942
 
943
typedef struct D501 {
944
  sint16        wn;    /* week number                          (weeks)   */
945
  float32       toa;   /* almanac data reference time              (s)   */
946
  float32       af0;   /* clock correction coefficient             (s)   */
947
  float32       af1;   /* clock correction coefficient           (s/s)   */
948
  float32       e;     /* eccentricity                             (-)   */
949
  float32       sqrta; /* square root of semi-major axis (a)  (m**1/2)   */
950
  float32       m0;    /* mean anomaly at reference time           (r)   */
951
  float32       w;     /* argument of perigee                      (r)   */
952
  float32       omg0;  /* right ascension                          (r)   */
953
  float32       odot;  /* rate of right ascension                (r/s)   */
954
  float32       i;     /* inclination angle                        (r)   */
955
  uint8         hlth;  /* almanac health                                 */
956
} D501;
957
 
958
 
959
typedef struct D550 {
960
  char          svid;  /* satellite id                                   */
961
  sint16        wn;    /* week number                          (weeks)   */
962
  float32       toa;   /* almanac data reference time              (s)   */
963
  float32       af0;   /* clock correction coefficient             (s)   */
964
  float32       af1;   /* clock correction coefficient           (s/s)   */
965
  float32       e;     /* eccentricity                             (-)   */
966
  float32       sqrta; /* square root of semi-major axis (a)  (m**1/2)   */
967
  float32       m0;    /* mean anomaly at reference time           (r)   */
968
  float32       w;     /* argument of perigee                      (r)   */
969
  float32       omg0;  /* right ascension                          (r)   */
970
  float32       odot;  /* rate of right ascension                (r/s)   */
971
  float32       i;     /* inclination angle                        (r)   */
972
} D550;
973
 
974
 
975
typedef struct D551 {
976
  char          svid;  /* satellite id                                   */
977
  sint16        wn;    /* week number                          (weeks)   */
978
  float32       toa;   /* almanac data reference time              (s)   */
979
  float32       af0;   /* clock correction coefficient             (s)   */
980
  float32       af1;   /* clock correction coefficient           (s/s)   */
981
  float32       e;     /* eccentricity                             (-)   */
982
  float32       sqrta; /* square root of semi-major axis (a)  (m**1/2)   */
983
  float32       m0;    /* mean anomaly at reference time           (r)   */
984
  float32       w;     /* argument of perigee                      (r)   */
985
  float32       omg0;  /* right ascension                          (r)   */
986
  float32       odot;  /* rate of right ascension                (r/s)   */
987
  float32       i;     /* inclination angle                        (r)   */
988
  uint8         hlth;  /* almanac health bits 17:24            (coded)   */
989
} D551;
990
 
991
 
992
typedef struct D600 {
993
  uint8     month;            /* month  (1-12)                  */
994
  uint8     day;              /* day    (1-31)                  */
995
  uint16    year;             /* year   (1990 means 1990)       */
996
  sint16    hour;             /* hour   (0-23)                  */
997
  uint8     minute;           /* minute (0-59)                  */
998
  uint8     second;           /* second (0-59)                  */
999
} D600;
1000
 
1001
 
1002
typedef struct D650 {
1003
  time_type         takeoff_time;
1004
  time_type         landing_time;
1005
  position_type     takeoff_posn;
1006
  position_type     landing_posn;
1007
  uint32            night_time;
1008
  uint32            num_landings;
1009
  float32           max_speed;
1010
  float32           max_alt;
1011
  float32           distance;
1012
  bool              cross_country_flag;
1013
  char *            departure_name;
1014
  char *            departure_ident;
1015
  char *            arrival_name;
1016
  char *            arrival_ident;
1017
  char *            ac_id;
1018
} D650;
1019
 
1020
 
1021
typedef radian_position_type  D700;
1022
 
1023
 
1024
typedef struct D800 {
1025
  float32               alt;        /* alt above WGS 84 ellipsoid (m)        */
1026
  float32               epe;        /* est. position error, 2 sigma (m)      */
1027
  float32               eph;        /* epe, but horizontal only (meters)     */
1028
  float32               epv;        /* epe, but vertical only (meters)       */
1029
  sint16                fix;        /* type of position fix                  */
1030
  float64               tow;        /* time of week (seconds)                */
1031
  radian_position_type  posn;       /* latitude and longitude (radians)      */
1032
  float32               east;       /* velocity east  (meters/second)        */
1033
  float32               north;      /* velocity north (meters/second)        */
1034
  float32               up;         /* velocity up    (meters/second)        */
1035
  float32               msl_hght;   /* ht. of WGS 84 ellipsoid above MSL (m) */
1036
  sint16                leap_scnds; /* diff between GPS and UTC (seconds)    */
1037
  sint32                wn_days;    /* week number days                      */
1038
} D800;
1039
 
1040
 
1041
typedef enum {
1042
  D800_unusable  = 0,    /* failed integrity check                   */
1043
  D800_invalid   = 1,    /* invalid or unavailable                   */
1044
  D800_2D        = 2,    /* two dimensional                          */
1045
  D800_3D        = 3,    /* three dimensional                        */
1046
  D800_2D_diff   = 4,    /* two dimensional differential             */
1047
  D800_3D_diff   = 5     /* three dimensional differential           */
1048
} D800_fix;
1049
 
1050
 
1051
typedef struct D906 {
1052
  uint32           start_time;
1053
  uint32           total_time;      /* In hundredths of a second */
1054
  float32          total_distance;  /* In meters */
1055
  position_type    begin;           /* Invalid if lat and lon are 0x7fffffff */
1056
  position_type    end;             /* Invalid if lat and lon are 0x7fffffff */
1057
  uint16           calories;
1058
  uint8            track_index;     /* See below */
1059
  uint8            unused;          /* Unused.  Set to 0. */
1060
} D906;
1061
 
1062
 
1063
typedef struct D1002 {
1064
  uint32                       num_valid_steps;
1065
  struct {
1066
    char                       custom_name[16];
1067
    float32                    target_custom_zone_low;
1068
    float32                    target_custom_zone_high;
1069
    uint16                     duration_value;
1070
    uint8                      intensity;
1071
    uint8                      duration_type;
1072
    uint8                      target_type;
1073
    uint8                      target_value;
1074
    uint16                     unused;
1075
  }                            steps[20];
1076
  char                         name[16];
1077
  uint8                        sport_type;
1078
} D1002;
1079
 
1080
 
1081
typedef enum {
1082
  D1002_time = 0,
1083
  D1002_distance,
1084
  D1002_heart_rate_less_than,
1085
  D1002_heart_rate_greater_than,
1086
  D1002_calories_burned,
1087
  D1002_open,
1088
  D1002_repeat
1089
} D1002_duration_type;
1090
 
1091
 
1092
typedef struct D1000 {
1093
  uint32                       track_index;
1094
  uint32                       first_lap_index;
1095
  uint32                       last_lap_index;
1096
  uint8                        sport_type;
1097
  uint8                        program_type;
1098
  uint16                       unused;
1099
  struct {
1100
    uint32                     time;
1101
    float32                    distance;
1102
  }                            virtual_partner;
1103
  D1002           workout;
1104
} D1000;
1105
 
1106
 
1107
typedef enum {
1108
  D1000_running              = 0,
1109
  D1000_biking               = 1,
1110
  D1000_other                = 2
1111
} D1000_sport_type;
1112
 
1113
 
1114
typedef enum {
1115
  D1000_none                 = 0,
1116
  D1000_virtual_partner      = 1,
1117
  D1000_workout              = 2
1118
} D1000_program_type;
1119
 
1120
 
1121
typedef struct D1001 {
1122
  uint32                       index;
1123
  time_type                    start_time;
1124
  uint32                       total_time;
1125
  float32                      total_dist;
1126
  float32                      max_speed;
1127
  position_type                begin;
1128
  position_type                end;
1129
  uint16                       calories;
1130
  uint8                        avg_heart_rate;
1131
  uint8                        max_heart_rate;
1132
  uint8                        intensity;
1133
} D1001;
1134
 
1135
 
1136
typedef enum {
1137
  D1001_active        = 0,
1138
  D1001_rest          = 1
1139
} D1001_intensity;
1140
 
1141
 
1142
/* D1002 defined above D1000 */
1143
 
1144
 
1145
typedef struct D1003 {
1146
  char                         workout_name[16];
1147
  time_type                    day;
1148
} D1003;
1149
 
1150
 
1151
typedef struct D1004 {
1152
  struct {
1153
    struct {
1154
      uint8                    low_heart_rate;
1155
      uint8                    high_heart_rate;
1156
      uint16                   unused;
1157
    }                          heart_rate_zones[5];
1158
    struct {
1159
      float32                  low_speed;
1160
      float32                  high_speed;
1161
      char                     name[16];
1162
    }                          speed_zones[10];
1163
    float32                    gear_weight;
1164
    uint8                      max_heart_rate;
1165
    uint8                      unused1;
1166
    uint16                     unused2;
1167
  }                            activities[3];
1168
  float32                      weight;
1169
  uint16                       birth_year;
1170
  uint8                        birth_month;
1171
  uint8                        birth_day;
1172
  uint8                        gender;
1173
} D1004;
1174
 
1175
 
1176
typedef enum {
1177
  D1004_female = 0,
1178
  D1004_male   = 1
1179
} D1004_gender;
1180
 
1181
 
1182
typedef struct D1005 {
1183
  uint32                       max_workouts;
1184
  uint32                       max_unscheduled_workouts;
1185
  uint32                       max_occurrences;
1186
} D1005;
1187
 
1188
 
1189
typedef struct D1006 {
1190
  uint16                       index;
1191
  uint16                       unused;
1192
  char                         course_name[16];
1193
  uint16                       track_index;
1194
} D1006;
1195
 
1196
 
1197
typedef struct D1007 {
1198
  uint16                       course_index;
1199
  uint16                       lap_index;
1200
  uint32                       total_time;
1201
  float32                      total_dist;
1202
  position_type                begin;
1203
  position_type                end;
1204
  uint8                        avg_heart_rate;
1205
  uint8                        max_heart_rate;
1206
  uint8                        intensity;
1207
  uint8                        avg_cadence;
1208
} D1007;
1209
 
1210
 
1211
typedef struct D1008 {
1212
  uint32                       num_valid_steps;
1213
  struct {
1214
    char                       custom_name[16];
1215
    float32                    target_custom_zone_low;
1216
    float32                    target_custom_zone_high;
1217
    uint16                     duration_value;
1218
    uint8                      intensity;
1219
    uint8                      duration_type;
1220
    uint8                      target_type;
1221
    uint8                      target_value;
1222
    uint16                     unused;
1223
  }                            steps[20];
1224
  char                         name[16];
1225
  uint8                        sport_type;
1226
} D1008;
1227
 
1228
 
1229
typedef struct D1009 {
1230
  uint16                       track_index;
1231
  uint16                       first_lap_index;
1232
  uint16                       last_lap_index;
1233
  uint8                        sport_type;
1234
  uint8                        program_type;
1235
  uint8                        multisport;
1236
  uint8                        unused1;
1237
  uint16                       unused2;
1238
  struct {
1239
    uint32                     time;
1240
    float32                    distance;
1241
  }                            quick_workout;
1242
  D1008                        workout;
1243
} D1009;
1244
 
1245
 
1246
typedef enum {
1247
  D1009_no                  = 0,
1248
  D1009_yes                 = 1,
1249
  D1009_yesAndLastInGroup   = 2
1250
} D1009_multisport;
1251
 
1252
 
1253
typedef struct D1010 {
1254
  uint32                       track_index;
1255
  uint32                       first_lap_index;
1256
  uint32                       last_lap_index;
1257
  uint8                        sport_type;
1258
  uint8                        program_type;
1259
  uint8                        multisport;
1260
  uint8                        unused;
1261
  struct {
1262
    uint32                     time;
1263
    float32                    distance;
1264
  }                            virtual_partner;
1265
  D1002                        workout;
1266
} D1010;
1267
 
1268
 
1269
typedef enum {
1270
  D1010_none               = 0,
1271
  D1010_virtual_partner    = 1,
1272
  D1010_workout            = 2,
1273
  D1010_auto_multisport    = 3
1274
} D1010_program_type;
1275
 
1276
 
1277
typedef struct D1011 {
1278
  uint16                       index;
1279
  uint16                       unused;
1280
  time_type                    start_time;
1281
  uint32                       total_time;
1282
  float32                      total_dist;
1283
  float32                      max_speed;
1284
  position_type                begin;
1285
  position_type                end;
1286
  uint16                       calories;
1287
  uint8                        avg_heart_rate;
1288
  uint8                        max_heart_rate;
1289
  uint8                        intensity;
1290
  uint8                        avg_cadence;
1291
  uint8                        trigger_method;
1292
} D1011;
1293
 
1294
 
1295
typedef enum {
1296
  D1011_manual           = 0,
1297
  D1011_distance         = 1,
1298
  D1011_location         = 2,
1299
  D1011_time             = 3,
1300
  D1011_heart_rate       = 4
1301
} D1011_trigger_method;
1302
 
1303
 
1304
typedef struct D1012 {
1305
  char                         name[11];
1306
  uint8                        unused1;
1307
  uint16                       course_index;
1308
  uint16                       unused2;
1309
  time_type                    track_point_time;
1310
  uint8                        point_type;
1311
} D1012;
1312
 
1313
 
1314
typedef enum {
1315
  D1012_generic              = 0x00,
1316
  D1012_summit               = 0x01,
1317
  D1012_valley               = 0x02,
1318
  D1012_water                = 0x03,
1319
  D1012_food                 = 0x04,
1320
  D1012_danger               = 0x05,
1321
  D1012_left                 = 0x06,
1322
  D1012_right                = 0x07,
1323
  D1012_straight             = 0x08,
1324
  D1012_first_aid            = 0x09,
1325
  D1012_fourth_category      = 0x0a,
1326
  D1012_third_category       = 0x0b,
1327
  D1012_second_category      = 0x0c,
1328
  D1012_first_category       = 0x0d,
1329
  D1012_hors_category        = 0x0e,
1330
  D1012_sprint               = 0x0f
1331
} D1012_point_type;
1332
 
1333
 
1334
typedef struct D1013 {
1335
  uint32                       max_courses;
1336
  uint32                       max_course_laps;
1337
  uint32                       max_course_pnt;
1338
  uint32                       max_course_trk_pnt;
1339
} D1013;
1340
 
1341
 
1342
typedef struct D1015 {
1343
  uint16                       index;
1344
  uint16                       unused;
1345
  time_type                    start_time;
1346
  uint32                       total_time;
1347
  float32                      total_dist;
1348
  float32                      max_speed;
1349
  position_type                begin;
1350
  position_type                end;
1351
  uint16                       calories;
1352
  uint8                        avg_heart_rate;
1353
  uint8                        max_heart_rate;
1354
  uint8                        intensity;
1355
  uint8                        avg_cadence;
1356
  uint8                        trigger_method;
1357
  /* FIXME - additional bytes are unknown */
1358
  uint8                        unknown[5];
1359
} D1015;
1360
 
1361
 
1362
typedef enum {
1363
  data_Dnil  =    0,
1364
  data_Dlist =    1,      /* List of data */
1365
  data_D100  =  100,      /* waypoint */
1366
  data_D101  =  101,      /* waypoint */
1367
  data_D102  =  102,      /* waypoint */
1368
  data_D103  =  103,      /* waypoint */
1369
  data_D104  =  104,      /* waypoint */
1370
  data_D105  =  105,      /* waypoint */
1371
  data_D106  =  106,      /* waypoint */
1372
  data_D107  =  107,      /* waypoint */
1373
  data_D108  =  108,      /* waypoint */
1374
  data_D109  =  109,      /* waypoint */
1375
  data_D110  =  110,      /* waypoint */
1376
  data_D120  =  120,      /* waypoint category */
1377
  data_D150  =  150,      /* waypoint */
1378
  data_D151  =  151,      /* waypoint */
1379
  data_D152  =  152,      /* waypoint */
1380
  data_D154  =  154,      /* waypoint */
1381
  data_D155  =  155,      /* waypoint */
1382
  data_D200  =  200,      /* route header */
1383
  data_D201  =  201,      /* route header */
1384
  data_D202  =  202,      /* route header */
1385
  data_D210  =  210,      /* route link */
1386
  data_D300  =  300,      /* track point */
1387
  data_D301  =  301,      /* track point */
1388
  data_D302  =  302,      /* track point */
1389
  data_D303  =  303,      /* track point */
1390
  data_D304  =  304,      /* track point */
1391
  data_D310  =  310,      /* track header */
1392
  data_D311  =  311,      /* track header */
1393
  data_D312  =  312,      /* track header */
1394
  data_D400  =  400,      /* proximity waypoint */
1395
  data_D403  =  403,      /* proximity waypoint */
1396
  data_D450  =  450,      /* proximity waypoint */
1397
  data_D500  =  500,      /* almanac */
1398
  data_D501  =  501,      /* almanac */
1399
  data_D550  =  550,      /* almanac */
1400
  data_D551  =  551,      /* almanac */
1401
  data_D600  =  600,      /* date/time */
1402
  data_D601  =  601,      /* --- UNDOCUMENTED --- */
1403
  data_D650  =  650,      /* flightbook record */
1404
  data_D700  =  700,      /* position */
1405
  data_D800  =  800,      /* position/velocity/time (PVT) */
1406
  data_D801  =  801,      /* --- UNDOCUMENTED --- */
1407
  data_D906  =  906,      /* lap */
1408
  data_D907  =  907,      /* --- UNDOCUMENTED --- */
1409
  data_D908  =  908,      /* --- UNDOCUMENTED --- */
1410
  data_D909  =  909,      /* --- UNDOCUMENTED --- */
1411
  data_D910  =  910,      /* --- UNDOCUMENTED --- */
1412
  data_D1000 = 1000,      /* run */
1413
  data_D1001 = 1001,      /* lap */
1414
  data_D1002 = 1002,      /* workout */
1415
  data_D1003 = 1003,      /* workout occurrence */
1416
  data_D1004 = 1004,      /* fitness user profile */
1417
  data_D1005 = 1005,      /* workout limits */
1418
  data_D1006 = 1006,      /* course */
1419
  data_D1007 = 1007,      /* course lap */
1420
  data_D1008 = 1008,      /* workout */
1421
  data_D1009 = 1009,      /* run */
1422
  data_D1010 = 1010,      /* run */
1423
  data_D1011 = 1011,      /* lap */
1424
  data_D1012 = 1012,      /* course point */
1425
  data_D1013 = 1013,      /* course limits */
1426
  data_D1015 = 1015,      /* lap */
1427
  data_NUM_DATATYPES
1428
} garmin_datatype;
1429
 
1430
 
1431
/* Garmin data of any type, including lists of {data, lists}. */
1432
 
1433
typedef struct garmin_data {
1434
  garmin_datatype   type;
1435
  void *            data;
1436
} garmin_data;
1437
 
1438
 
1439
/* A garmin list node (contains data and a 'next' pointer) */
1440
 
1441
typedef struct garmin_list_node {
1442
  garmin_data *                      data;
1443
  struct garmin_list_node *          next;
1444
} garmin_list_node;
1445
 
1446
 
1447
/* A singly linked list of garmin data (can be a list of lists) */
1448
 
1449
typedef struct garmin_list {
1450
  int                                id;
1451
  int                                elements;
1452
  garmin_list_node *                 head;
1453
  garmin_list_node *                 tail;
1454
} garmin_list;
1455
 
1456
 
1457
/* ------------------------------------------------------------------------- */
1458
/* 3.2   USB Protocol                                                        */
1459
/* ------------------------------------------------------------------------- */
1460
 
1461
#define GARMIN_USB_VID  0x091e
1462
#define GARMIN_USB_PID  0x0003
1463
 
1464
#define GARMIN_DIR_NONE  0
1465
#define GARMIN_DIR_READ  1
1466
#define GARMIN_DIR_WRITE 2
1467
 
1468
 
1469
/* ------------------------------------------------------------------------- */
1470
/* 3.2.2 USB Packet Format                                                   */
1471
/* ------------------------------------------------------------------------- */
1472
 
1473
#define GARMIN_PROTOCOL_USB   0x00
1474
#define GARMIN_PROTOCOL_APP   0x14
1475
 
1476
 
1477
/* Following the scheme of jeeps / gpsbabel... */
1478
 
1479
 
1480
#define PACKET_HEADER_SIZE   12
1481
 
1482
 
1483
typedef union garmin_packet {
1484
  struct {
1485
    uint8            type;         /*  byte 0      */
1486
    uint8            reserved1;
1487
    uint8            reserved2;
1488
    uint8            reserved3;
1489
    uint8            id[2];        /*  bytes 4-5   */ 
1490
    uint8            reserved4;
1491
    uint8            reserved5;
1492
    uint8            size[4];      /*  bytes 8-11  */
1493
    uint8            data[1];      /*  bytes 12+   */
1494
  }                  packet;
1495
  char               data[1024];
1496
} garmin_packet;
1497
 
1498
 
1499
/* ------------------------------------------------------------------------- */
1500
/* 3.2.3 USB Protocol Layer Packet Ids                                       */
1501
/* ------------------------------------------------------------------------- */
1502
 
1503
typedef enum {
1504
  Pid_Data_Available       = 0x02,
1505
  Pid_Start_Session        = 0x05,
1506
  Pid_Session_Started      = 0x06
1507
} USB_Pid;
1508
 
1509
 
1510
/* ------------------------------------------------------------------------- */
1511
/* 6.1   A000 - Product Data Protocol                                        */
1512
/* ------------------------------------------------------------------------- */
1513
 
1514
 
1515
typedef struct garmin_product {
1516
  uint16          product_id;
1517
  sint16          software_version;
1518
  char *          product_description;
1519
  char **         additional_data;
1520
} garmin_product;
1521
 
1522
 
1523
typedef struct garmin_extended_data {
1524
  char **         ext_data;
1525
} garmin_extended_data;
1526
 
1527
 
1528
/* ------------------------------------------------------------------------- */
1529
/* 6.2   A001 - Protocol Capability Protocol                                 */
1530
/* ------------------------------------------------------------------------- */
1531
 
1532
 
1533
typedef enum {
1534
  Tag_Phys_Prot_Id    = 'P',
1535
  Tag_Link_Prot_Id    = 'L',
1536
  Tag_Appl_Prot_Id    = 'A',
1537
  Tag_Data_Type_Id    = 'D'
1538
} A001_tag;
1539
 
1540
 
1541
/* ------------------------------------------------------------------------- */
1542
/* 6.3.1 A010 - Device Command Protocol 1                                    */
1543
/* ------------------------------------------------------------------------- */
1544
 
1545
typedef enum {
1546
  A010_Cmnd_Abort_Transfer                = 0x0000,
1547
  A010_Cmnd_Transfer_Alm                  = 0x0001,
1548
  A010_Cmnd_Transfer_Posn                 = 0x0002,
1549
  A010_Cmnd_Transfer_Prx                  = 0x0003,
1550
  A010_Cmnd_Transfer_Rte                  = 0x0004,
1551
  A010_Cmnd_Transfer_Time                 = 0x0005,
1552
  A010_Cmnd_Transfer_Trk                  = 0x0006,
1553
  A010_Cmnd_Transfer_Wpt                  = 0x0007,
1554
  A010_Cmnd_Turn_Off_Pwr                  = 0x0008,
1555
  A010_Cmnd_Start_Pvt_Data                = 0x0031,
1556
  A010_Cmnd_Stop_Pvt_Data                 = 0x0032,
1557
  A010_Cmnd_FlightBook_Transfer           = 0x005c,
1558
  A010_Cmnd_Transfer_Laps                 = 0x0075,
1559
  A010_Cmnd_Transfer_Wpt_Cats             = 0x0079,
1560
  A010_Cmnd_Transfer_Runs                 = 0x01c2,
1561
  A010_Cmnd_Transfer_Workouts             = 0x01c3,
1562
  A010_Cmnd_Transfer_Workout_Occurrences  = 0x01c4,
1563
  A010_Cmnd_Transfer_Fitness_User_Profile = 0x01c5,
1564
  A010_Cmnd_Transfer_Workout_Limits       = 0x01c6,
1565
  A010_Cmnd_Transfer_Courses              = 0x0231,
1566
  A010_Cmnd_Transfer_Course_Laps          = 0x0232,
1567
  A010_Cmnd_Transfer_Course_Points        = 0x0233,
1568
  A010_Cmnd_Transfer_Course_Tracks        = 0x0234,
1569
  A010_Cmnd_Transfer_Course_Limits        = 0x0235
1570
} A010_command_id;
1571
 
1572
 
1573
/* ------------------------------------------------------------------------- */
1574
/* 6.3.2 A011 - Device Command Protocol 2                                    */
1575
/* ------------------------------------------------------------------------- */
1576
 
1577
typedef enum {
1578
  A011_Cmnd_Abort_Transfer                = 0x0000,
1579
  A011_Cmnd_Transfer_Alm                  = 0x0004,
1580
  A011_Cmnd_Transfer_Rte                  = 0x0008,
1581
  A011_Cmnd_Transfer_Prx                  = 0x0011,
1582
  A011_Cmnd_Transfer_Time                 = 0x0014,
1583
  A011_Cmnd_Transfer_Wpt                  = 0x0015,
1584
  A011_Cmnd_Turn_Off_Pwr                  = 0x001a,  
1585
} A011_command_id;
1586
 
1587
 
1588
/* Unified command enum */
1589
 
1590
typedef enum {
1591
 
1592
  /* A010 and A011 */
1593
 
1594
  Cmnd_Abort_Transfer,
1595
  Cmnd_Transfer_Alm,
1596
  Cmnd_Transfer_Prx,
1597
  Cmnd_Transfer_Rte,
1598
  Cmnd_Transfer_Time,
1599
  Cmnd_Transfer_Wpt,
1600
  Cmnd_Turn_Off_Pwr,
1601
 
1602
  /* A010 only */
1603
 
1604
  Cmnd_Transfer_Posn,
1605
  Cmnd_Transfer_Trk,
1606
  Cmnd_Start_Pvt_Data,
1607
  Cmnd_Stop_Pvt_Data,
1608
  Cmnd_FlightBook_Transfer,
1609
  Cmnd_Transfer_Laps,
1610
  Cmnd_Transfer_Wpt_Cats,
1611
  Cmnd_Transfer_Runs,
1612
  Cmnd_Transfer_Workouts,
1613
  Cmnd_Transfer_Workout_Occurrences,
1614
  Cmnd_Transfer_Fitness_User_Profile,
1615
  Cmnd_Transfer_Workout_Limits,
1616
  Cmnd_Transfer_Courses,
1617
  Cmnd_Transfer_Course_Laps,
1618
  Cmnd_Transfer_Course_Points,
1619
  Cmnd_Transfer_Course_Tracks,
1620
  Cmnd_Transfer_Course_Limits
1621
 
1622
} garmin_command;
1623
 
1624
 
1625
/* ------------------------------------------------------------------------- */
1626
/* 4.1   L000 - Basic Link Protocol                                          */
1627
/* ------------------------------------------------------------------------- */
1628
 
1629
typedef enum {
1630
  L000_Pid_Protocol_Array       = 0x00fd,
1631
  L000_Pid_Product_Rqst         = 0x00fe,
1632
  L000_Pid_Product_Data         = 0x00ff,
1633
  L000_Pid_Ext_Product_Data     = 0x00f8
1634
} L000_packet_id;
1635
 
1636
 
1637
/* ------------------------------------------------------------------------- */
1638
/* 4.2   L001 - Link Protocol 1                                              */
1639
/* ------------------------------------------------------------------------- */
1640
 
1641
typedef enum {
1642
  L001_Pid_Command_Data         = 0x000a,
1643
  L001_Pid_Xfer_Cmplt           = 0x000c,
1644
  L001_Pid_Date_Time_Data       = 0x000e,
1645
  L001_Pid_Position_Data        = 0x0011,
1646
  L001_Pid_Prx_Wpt_Data         = 0x0013,
1647
  L001_Pid_Records              = 0x001b,
1648
  /* L001_Pid_Undocumented_1    = 0x001c, */
1649
  L001_Pid_Rte_Hdr              = 0x001d,
1650
  L001_Pid_Rte_Wpt_Data         = 0x001e,
1651
  L001_Pid_Almanac_Data         = 0x001f,
1652
  L001_Pid_Trk_Data             = 0x0022,
1653
  L001_Pid_Wpt_Data             = 0x0023,
1654
  L001_Pid_Pvt_Data             = 0x0033,
1655
  L001_Pid_Rte_Link_Data        = 0x0062,
1656
  L001_Pid_Trk_Hdr              = 0x0063,
1657
  L001_Pid_FlightBook_Record    = 0x0086,
1658
  L001_Pid_Lap                  = 0x0095,
1659
  L001_Pid_Wpt_Cat              = 0x0098,
1660
  L001_Pid_Run                  = 0x03de,
1661
  L001_Pid_Workout              = 0x03df,
1662
  L001_Pid_Workout_Occurrence   = 0x03e0,
1663
  L001_Pid_Fitness_User_Profile = 0x03e1,
1664
  L001_Pid_Workout_Limits       = 0x03e2,
1665
  L001_Pid_Course               = 0x0425,
1666
  L001_Pid_Course_Lap           = 0x0426,
1667
  L001_Pid_Course_Point         = 0x0427,
1668
  L001_Pid_Course_Trk_Hdr       = 0x0428,
1669
  L001_Pid_Course_Trk_Data      = 0x0429,
1670
  L001_Pid_Course_Limits        = 0x042a
1671
} L001_packet_id;
1672
 
1673
 
1674
/* ------------------------------------------------------------------------- */
1675
/* 4.3   Link Protocol 2                                                     */
1676
/* ------------------------------------------------------------------------- */
1677
 
1678
typedef enum {
1679
  L002_Pid_Almanac_Data         = 0x0004,
1680
  L002_Pid_Command_Data         = 0x000b,
1681
  L002_Pid_Xfer_Cmplt           = 0x000c,
1682
  L002_Pid_Date_Time_Data       = 0x0014,
1683
  L002_Pid_Position_Data        = 0x0018,
1684
  L002_Pid_Prx_Wpt_Data         = 0x001b,
1685
  L002_Pid_Records              = 0x0023,
1686
  L002_Pid_Rte_Hdr              = 0x0025,
1687
  L002_Pid_Rte_Wpt_Data         = 0x0027,
1688
  L002_Pid_Wpt_Data             = 0x002b
1689
} L002_packet_id;
1690
 
1691
 
1692
/* Unified PID enum */
1693
 
1694
typedef enum {
1695
 
1696
  /* Invalid Pid */
1697
 
1698
  Pid_Nil,
1699
 
1700
  /* L000 Pids */
1701
 
1702
  Pid_Protocol_Array,
1703
  Pid_Product_Rqst,
1704
  Pid_Product_Data,
1705
  Pid_Ext_Product_Data,
1706
 
1707
  /* L001 and L002 Pids */
1708
 
1709
  Pid_Almanac_Data,
1710
  Pid_Command_Data,
1711
  Pid_Xfer_Cmplt,
1712
  Pid_Date_Time_Data,
1713
  Pid_Position_Data,
1714
  Pid_Prx_Wpt_Data,
1715
  Pid_Records,
1716
  Pid_Rte_Hdr,
1717
  Pid_Rte_Wpt_Data,
1718
  Pid_Wpt_Data,
1719
 
1720
  /* L001 only */
1721
 
1722
  Pid_Trk_Data,
1723
  Pid_Pvt_Data,
1724
  Pid_Rte_Link_Data,
1725
  Pid_Trk_Hdr,
1726
  Pid_FlightBook_Record,
1727
  Pid_Lap,
1728
  Pid_Wpt_Cat,
1729
  Pid_Run,
1730
  Pid_Workout,
1731
  Pid_Workout_Occurrence,
1732
  Pid_Fitness_User_Profile,
1733
  Pid_Workout_Limits,
1734
  Pid_Course,
1735
  Pid_Course_Lap,
1736
  Pid_Course_Point,
1737
  Pid_Course_Trk_Hdr,
1738
  Pid_Course_Trk_Data,
1739
  Pid_Course_Limits
1740
 
1741
} garmin_pid;
1742
 
1743
 
1744
/* Unified protocol enums */
1745
 
1746
typedef enum {
1747
  phys_P000 = 0,
1748
  phys_NUM_PROTOCOLS
1749
} phys_protocol;
1750
 
1751
 
1752
typedef enum {
1753
  link_L000 = 0,      /* basic link protocol */
1754
  link_L001 = 1,      /* link protocol 1 */
1755
  link_L002 = 2,      /* link protocol 2 */
1756
  link_NUM_PROTOCOLS
1757
} link_protocol;
1758
 
1759
 
1760
typedef enum {
1761
  appl_Anil  =    0,
1762
  appl_A000  =    0,      /* product data protocol */
1763
  appl_A001  =    1,      /* protocol capability protocol */
1764
  appl_A010  =   10,      /* device command protocol 1 */
1765
  appl_A011  =   11,      /* device command protocol 2 */
1766
  appl_A100  =  100,      /* waypoint transfer protocol */
1767
  appl_A101  =  101,      /* waypoint category transfer protocol */
1768
  appl_A200  =  200,      /* route transfer protocol */
1769
  appl_A201  =  201,      /* route transfer protocol */
1770
  appl_A300  =  300,      /* track log transfer protocol */
1771
  appl_A301  =  301,      /* track log transfer protocol */
1772
  appl_A302  =  302,      /* track log transfer protocol */
1773
  appl_A400  =  400,      /* proximity waypoint transfer protocol */
1774
  appl_A500  =  500,      /* almanac transfer protocol */
1775
  appl_A600  =  600,      /* date and time initialization protocol */
1776
  appl_A601  =  601,      /* --- UNDOCUMENTED --- */
1777
  appl_A650  =  650,      /* flightbook transfer protocol */
1778
  appl_A700  =  700,      /* position initialization protocol */
1779
  appl_A800  =  800,      /* PVT protocol */
1780
  appl_A801  =  801,      /* --- UNDOCUMENTED --- */
1781
  appl_A902  =  902,      /* --- UNDOCUMENTED --- */
1782
  appl_A903  =  903,      /* --- UNDOCUMENTED --- */
1783
  appl_A906  =  906,      /* lap transfer protocol */
1784
  appl_A907  =  907,      /* --- UNDOCUMENTED --- */
1785
  appl_A1000 = 1000,     /* run transfer protocol */
1786
  appl_A1002 = 1002,     /* workout transfer protocol */
1787
  appl_A1003 = 1003,     /* workout occurrence transfer protocol */
1788
  appl_A1004 = 1004,     /* fitness user profile transfer protocol */
1789
  appl_A1005 = 1005,     /* workout limits transfer protocol */
1790
  appl_A1006 = 1006,     /* course transfer protocol */
1791
  appl_A1007 = 1007,     /* course lap transfer protocol */
1792
  appl_A1008 = 1008,     /* course point transfer protocol */
1793
  appl_A1009 = 1009,     /* course limits transfer protocol */
1794
  appl_A1012 = 1012,     /* course track transfer protocol */
1795
  appl_NUM_PROTOCOLS
1796
} appl_protocol;
1797
 
1798
 
1799
/* ========================================================================= */
1800
/* Constants                                                                 */
1801
/* ========================================================================= */
1802
 
1803
#define GARMIN_MAGIC    "<@gArMiN@>"  /* appears at the start of all files. */
1804
#define GARMIN_VERSION  100           /* version 1.00 */
1805
#define GARMIN_HEADER   20            /* bytes needed for file header. */
1806
 
1807
 
1808
/* ========================================================================= */
1809
/* Data structures                                                           */
1810
/* ========================================================================= */
1811
 
1812
typedef struct waypoint_protocols {
1813
  appl_protocol              waypoint;
1814
  appl_protocol              category;
1815
  appl_protocol              proximity;
1816
} waypoint_protocols;
1817
 
1818
 
1819
typedef struct workout_protocols {
1820
  appl_protocol              workout;
1821
  appl_protocol              occurrence;
1822
  appl_protocol              limits;
1823
} workout_protocols;
1824
 
1825
 
1826
typedef struct course_protocols {
1827
  appl_protocol              course;
1828
  appl_protocol              lap;
1829
  appl_protocol              track;
1830
  appl_protocol              point;
1831
  appl_protocol              limits;
1832
} course_protocols;
1833
 
1834
 
1835
typedef struct garmin_protocols {
1836
  phys_protocol              physical;  /* The physical protocol */
1837
  link_protocol              link;      /* The link protocol */
1838
  appl_protocol              command;   /* The device command protocol */
1839
  waypoint_protocols         waypoint;  /* Application protocols */
1840
  appl_protocol              route;
1841
  appl_protocol              track;
1842
  appl_protocol              almanac;
1843
  appl_protocol              date_time;
1844
  appl_protocol              flightbook;
1845
  appl_protocol              position;
1846
  appl_protocol              pvt;
1847
  appl_protocol              lap;
1848
  appl_protocol              run;
1849
  workout_protocols          workout;
1850
  appl_protocol              fitness;
1851
  course_protocols           course;
1852
} garmin_protocols;
1853
 
1854
 
1855
typedef struct waypoint_datatypes {
1856
  garmin_datatype            waypoint;
1857
  garmin_datatype            category;
1858
  garmin_datatype            proximity;
1859
} waypoint_datatypes;
1860
 
1861
 
1862
typedef struct route_datatypes {
1863
  garmin_datatype            header;
1864
  garmin_datatype            waypoint;
1865
  garmin_datatype            link;
1866
} route_datatypes;
1867
 
1868
 
1869
typedef struct track_datatypes {
1870
  garmin_datatype            header;
1871
  garmin_datatype            data;
1872
} track_datatypes;
1873
 
1874
 
1875
typedef struct workout_datatypes {
1876
  garmin_datatype            workout;
1877
  garmin_datatype            occurrence;
1878
  garmin_datatype            limits;
1879
} workout_datatypes;
1880
 
1881
 
1882
typedef struct course_datatypes {
1883
  garmin_datatype            course;
1884
  garmin_datatype            lap;
1885
  track_datatypes            track;
1886
  garmin_datatype            point;
1887
  garmin_datatype            limits;
1888
} course_datatypes;
1889
 
1890
 
1891
typedef struct garmin_datatypes {
1892
  waypoint_datatypes         waypoint;
1893
  route_datatypes            route;
1894
  track_datatypes            track;
1895
  garmin_datatype            almanac;
1896
  garmin_datatype            date_time;
1897
  garmin_datatype            flightbook;
1898
  garmin_datatype            position;
1899
  garmin_datatype            pvt;
1900
  garmin_datatype            lap;
1901
  garmin_datatype            run;
1902
  workout_datatypes          workout;
1903
  garmin_datatype            fitness;
1904
  course_datatypes           course;
1905
} garmin_datatypes;
1906
 
1907
 
1908
typedef struct garmin_usb {
1909
  usb_dev_handle *          handle;
101 andreas 1910
  int			    fd;
93 andreas 1911
  int                       bulk_out;
1912
  int                       bulk_in;
1913
  int                       intr_in;
1914
  int                       read_bulk;
1915
} garmin_usb;
1916
 
1917
 
1918
typedef struct garmin_unit {
1919
  uint32                     id;
1920
  garmin_product             product;
1921
  garmin_extended_data       extended;
1922
  garmin_protocols           protocol;
1923
  garmin_datatypes           datatype;
1924
  garmin_usb                 usb;
1925
  int                        verbose;   /* this may become a 'flags' field. */
1926
} garmin_unit;
1927
 
1928
 
1929
typedef enum {
1930
  GET_WAYPOINTS,
1931
  GET_WAYPOINT_CATEGORIES,
1932
  GET_ROUTES,
1933
  GET_TRACKLOG,
1934
  GET_PROXIMITY_WAYPOINTS,
1935
  GET_ALMANAC,
1936
  GET_FLIGHTBOOK,
1937
  GET_RUNS,
1938
  GET_WORKOUTS,
1939
  GET_FITNESS_USER_PROFILE,
1940
  GET_WORKOUT_LIMITS,
1941
  GET_COURSES,
1942
  GET_COURSE_LIMITS
1943
} garmin_get_type;
1944
 
136 andreas 1945
typedef enum {
1946
  err_info,
1947
  err_warning,
1948
  err_error,
1949
  err_fatal
1950
} err_type;
93 andreas 1951
 
136 andreas 1952
 
93 andreas 1953
/* ========================================================================= */
1954
/* Function prototypes                                                       */
1955
/* ========================================================================= */
1956
 
1957
/* ------------------------------------------------------------------------- */
1958
/* packet_id.c                                                               */
1959
/* ------------------------------------------------------------------------- */
1960
 
1961
uint16      garmin_lpid ( link_protocol     link,
1962
			  garmin_pid        gpid );
1963
 
1964
garmin_pid  garmin_gpid ( link_protocol     link,
1965
			  uint16            lpid );
1966
 
1967
 
1968
/* ------------------------------------------------------------------------- */
1969
/* unpack.c                                                                  */
1970
/* ------------------------------------------------------------------------- */
1971
 
1972
garmin_data * garmin_load          ( const char *     filename );
1973
garmin_data * garmin_unpack_packet ( garmin_packet *  p, 
1974
				     garmin_datatype  type );
1975
garmin_data * garmin_unpack        ( uint8 **         buf,
1976
				     garmin_datatype  type );
1977
 
1978
 
1979
/* ------------------------------------------------------------------------- */
1980
/* pack.c                                                                    */
1981
/* ------------------------------------------------------------------------- */
1982
 
1983
uint32 garmin_save ( garmin_data * data, 
1984
		     const char *  filename, 
1985
		     const char *  dir );
218 andreas 1986
uint32 garmin_save_all ( garmin_data * data,
1987
		     const char * filename,
1988
		     const char * dir,
1989
		     int flag );
93 andreas 1990
uint32 garmin_pack ( garmin_data * data, 
1991
		     uint8 **      buf );
1992
 
1993
 
1994
/* ------------------------------------------------------------------------- */
1995
/* print.c                                                                   */
1996
/* ------------------------------------------------------------------------- */
1997
 
1998
void garmin_print_data      ( garmin_data * data, FILE * fp, int spaces );
1999
void garmin_print_protocols ( garmin_unit * unit, FILE * fp, int spaces );
2000
void garmin_print_info      ( garmin_unit * unit, FILE * fp, int spaces );
2001
 
2002
 
2003
/* ------------------------------------------------------------------------- */
2004
/* command.c                                                                 */
2005
/* ------------------------------------------------------------------------- */
2006
 
2007
 
2008
int  garmin_command_supported ( garmin_unit *    garmin,
2009
				garmin_command   cmd );
2010
 
2011
int  garmin_make_command_packet ( garmin_unit *    garmin, 
2012
				  garmin_command   cmd,
2013
				  garmin_packet *  packet );
2014
 
2015
int  garmin_send_command ( garmin_unit *    garmin, 
2016
			   garmin_command   cmd );
2017
 
2018
 
2019
/* ------------------------------------------------------------------------- */
2020
/* protocol.c                                                                */
2021
/* ------------------------------------------------------------------------- */
2022
 
2023
void garmin_read_a000_a001           ( garmin_unit *    garmin );
2024
garmin_data * garmin_read_a100       ( garmin_unit *    garmin );
2025
garmin_data * garmin_read_a101       ( garmin_unit *    garmin );
2026
garmin_data * garmin_read_a200       ( garmin_unit *    garmin );
2027
garmin_data * garmin_read_a201       ( garmin_unit *    garmin );
2028
garmin_data * garmin_read_a300       ( garmin_unit *    garmin );
2029
garmin_data * garmin_read_a301       ( garmin_unit *    garmin );
2030
garmin_data * garmin_read_a302       ( garmin_unit *    garmin );
2031
garmin_data * garmin_read_a400       ( garmin_unit *    garmin );
2032
garmin_data * garmin_read_a500       ( garmin_unit *    garmin );
2033
garmin_data * garmin_read_a600       ( garmin_unit *    garmin );
2034
garmin_data * garmin_read_a650       ( garmin_unit *    garmin );
2035
garmin_data * garmin_read_a700       ( garmin_unit *    garmin );
2036
garmin_data * garmin_read_a800       ( garmin_unit *    garmin );
2037
garmin_data * garmin_read_a906       ( garmin_unit *    garmin );
2038
garmin_data * garmin_read_a1000      ( garmin_unit *    garmin );
2039
garmin_data * garmin_read_a1002      ( garmin_unit *    garmin );
2040
garmin_data * garmin_read_a1003      ( garmin_unit *    garmin );
2041
garmin_data * garmin_read_a1004      ( garmin_unit *    garmin );
2042
garmin_data * garmin_read_a1005      ( garmin_unit *    garmin );
2043
garmin_data * garmin_read_a1006      ( garmin_unit *    garmin );
2044
garmin_data * garmin_read_a1007      ( garmin_unit *    garmin );
2045
garmin_data * garmin_read_a1008      ( garmin_unit *    garmin );
2046
garmin_data * garmin_read_a1009      ( garmin_unit *    garmin );
2047
garmin_data * garmin_read_a1012      ( garmin_unit *    garmin );
2048
 
2049
garmin_data * garmin_read_via        ( garmin_unit *    garmin, 
2050
				       appl_protocol    protocol );
2051
garmin_data * garmin_get             ( garmin_unit *    garmin, 
2052
				       garmin_get_type  what );
2053
int           garmin_init            ( garmin_unit *    garmin,
2054
				       int              verbose );
2055
 
2056
 
2057
/* ------------------------------------------------------------------------- */
2058
/* usb_comm.c                                                                */
2059
/* ------------------------------------------------------------------------- */
2060
 
101 andreas 2061
void    garmin_set_device(const char *device);
2062
void    garmin_set_method(int mth);
93 andreas 2063
int     garmin_open           ( garmin_unit * garmin );
2064
int     garmin_close          ( garmin_unit * garmin );
2065
uint32  garmin_start_session  ( garmin_unit * garmin );
2066
int     garmin_read           ( garmin_unit * garmin, garmin_packet * p );
2067
int     garmin_write          ( garmin_unit * garmin, garmin_packet * p );
2068
uint8   garmin_packet_type    ( garmin_packet * p );
2069
uint16  garmin_packet_id      ( garmin_packet * p );
2070
uint32  garmin_packet_size    ( garmin_packet * p );
2071
uint8 * garmin_packet_data    ( garmin_packet * p );
2072
 
2073
void    garmin_print_packet   ( garmin_packet *  p, 
2074
				int              dir, 
2075
				FILE *           fp );
2076
int     garmin_packetize      ( garmin_packet *  p,
2077
				uint16           id, 
2078
				uint32           size, 
2079
				uint8 *          data );
2080
 
2081
 
2082
/* ------------------------------------------------------------------------- */
2083
/* byte_util.c                                                               */
2084
/* ------------------------------------------------------------------------- */
2085
 
2086
uint16   get_uint16  ( const uint8 * d );
2087
sint16   get_sint16  ( const uint8 * d );
2088
uint32   get_uint32  ( const uint8 * d );
2089
sint32   get_sint32  ( const uint8 * d );
2090
float32  get_float32 ( const uint8 * d );
2091
float64  get_float64 ( const uint8 * d );
2092
 
2093
void     put_uint16  ( uint8 * d, const uint16  v );
2094
void     put_sint16  ( uint8 * d, const sint16  v );
2095
void     put_uint32  ( uint8 * d, const uint32  v );
2096
void     put_sint32  ( uint8 * d, const sint32  v );
2097
void     put_float32 ( uint8 * d, const float32 v );
2098
void     put_float64 ( uint8 * d, const float64 v );
2099
 
2100
char *   get_string  ( garmin_packet * p, int * offset );
2101
char *   get_vstring ( uint8 ** buf );
2102
void     put_vstring ( uint8 ** buf, const char * x );
2103
char **  get_strings ( garmin_packet * p, int * offset );
2104
 
2105
 
2106
/* ------------------------------------------------------------------------- */
2107
/* datatype.c                                                                */
2108
/* ------------------------------------------------------------------------- */
2109
 
2110
garmin_data * garmin_alloc_data     ( garmin_datatype type );
2111
garmin_list * garmin_alloc_list     ( void );
2112
garmin_list * garmin_list_append    ( garmin_list * list, 
2113
				      garmin_data * data );
2114
garmin_data * garmin_list_data      ( garmin_data * data, 
2115
				      uint32        which );
2116
void          garmin_free_list      ( garmin_list * l );
2117
void          garmin_free_list_only ( garmin_list * l );
2118
void          garmin_free_data      ( garmin_data * d );
2119
uint32        garmin_data_size      ( garmin_data * d );
2120
 
2121
 
2122
/* ------------------------------------------------------------------------- */
2123
/* symbol_name.c                                                             */
2124
/* ------------------------------------------------------------------------- */
2125
 
2126
char * garmin_symbol_name ( symbol_value s );
2127
 
2128
 
2129
/* ------------------------------------------------------------------------- */
2130
/* run.c                                                                     */
2131
/* ------------------------------------------------------------------------- */
2132
 
2133
void   garmin_save_runs ( garmin_unit * garmin );
2134
 
136 andreas 2135
/* ------------------------------------------------------------------------- */
2136
/* prghook.c                                                                     */
2137
/* ------------------------------------------------------------------------- */
93 andreas 2138
 
136 andreas 2139
void garmin_set_hook(void (*func)(char *str));
2140
void garmin_clear_hook();
2141
void garmin_callback();
2142
 
2143
/* ------------------------------------------------------------------------- */
2144
/* error.c                                                                     */
2145
/* ------------------------------------------------------------------------- */
2146
 
2147
void garmin_queue_error(char *str, err_type type);
214 andreas 2148
void garmin_clear_errors(void);
136 andreas 2149
char *garmin_get_first_error(int *key);
2150
char *garmin_get_next_error(int *key);
214 andreas 2151
int garmin_count_error(void);
136 andreas 2152
 
93 andreas 2153
#endif /* __GARMIN_GARMIN_H__ */