Debian Codegraph @

src/garmin.h

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