forked from GPSBabel/gpsbabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarminusb.h
70 lines (60 loc) · 2.38 KB
/
garminusb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Definitions for Garmin USB protocol and implementation.
Copyright (C) 2004, 2005, 2006 Robert Lipe, [email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <cstdio>
#include "jeeps/gpsdevice.h"
/* This structure is a bit funny looking to avoid variable length
* arrays which aren't present in C89. This contains the visible
* fields in the USB packets of the Garmin USB receivers (60C, 76C, etc.)
* All data are little endian.
*/
typedef
union {
struct {
unsigned char type;
unsigned char reserved1;
unsigned char reserved2;
unsigned char reserved3;
unsigned char pkt_id[2];
unsigned char reserved6;
unsigned char reserved7;
unsigned char datasz[4];
unsigned char databuf[1]; /* actually an variable length array... */
} gusb_pkt;
unsigned char dbuf[1024];
} garmin_usb_packet;
/*
* Internal interfaces that are common regardless of underlying
* OS implementation.
*/
#define GUSB_MAX_UNITS 20
typedef struct {
unsigned long serial_number;
unsigned long unit_id;
unsigned long unit_version;
char* os_identifier; /* In case the OS has another name for it. */
char* product_identifier; /* From the hardware itself. */
} garmin_unit_info_t;
extern garmin_unit_info_t garmin_unit_info[GUSB_MAX_UNITS];
int gusb_cmd_send(const garmin_usb_packet* obuf, size_t sz);
int gusb_cmd_get(garmin_usb_packet* ibuf, size_t sz);
int gusb_init(const char* portname, gpsdevh** dh);
int gusb_close(gpsdevh*, bool exit_lib = true);
/*
* New packet types in USB.
*/
#define GUSB_SESSION_START 5 /* We request units attention */
#define GUSB_SESSION_ACK 6 /* Unit responds that we have its attention */
#define GUSB_REQUEST_BULK 2 /* Unit requests we read from bulk pipe */