Subversion Repositories public

Rev

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

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