-
Notifications
You must be signed in to change notification settings - Fork 127
/
garmin.h
208 lines (186 loc) · 5.94 KB
/
garmin.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
Jeeps wrapper for Garmin serial protocol.
Copyright (C) 2002, 2003, 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.
*/
#ifndef GARMIN_H_INCLUDED_
#define GARMIN_H_INCLUDED_
#include <cstdio> // for size_t
#include <QList> // for QList
#include <QByteArray> // for QByteArray
#include <QString> // for QString
#include <QTextCodec> // for QTextCodec
#include <QVector> // for QVector
#include "defs.h"
#include "format.h" // for Format
#include "jeeps/gpsdevice.h" // for gpsdevh
#include "jeeps/gpssend.h" // for GPS_PWay, GPS_SWay, GPS_PTrack, GPS_PPvt_Data, GPS_SLap
#include "mkshort.h" // for MakeShort
#include "option.h" // for OptionString, OptionBool
class GarminFormat : public Format
{
public:
QVector<arglist_t>* get_args() override
{
return &garmin_args;
}
ff_type get_type() const override
{
return ff_type_serial;
}
QVector<ff_cap> get_cap() const override
{
return FF_CAP_RW_ALL;
}
void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override
{
rw_deinit();
}
void wr_init(const QString& fname) override
{
rw_init(fname);
}
void write() override;
void wr_deinit() override
{
rw_deinit();
}
void rd_position_init(const QString& fname) override;
Waypoint* rd_position(posn_status* status) override;
void rd_position_deinit() override
{
rw_deinit();
}
private:
/* Member Functions */
QByteArray str_from_unicode(const QString& qstr);
QString str_to_unicode(const QByteArray& cstr);
static void write_char_string(char* dest, const char* source, size_t destsize);
void rw_init(const QString& fname);
void rw_deinit();
static int waypt_read_cb(int total_ct, GPS_SWay** /* unused */);
void waypt_read();
static int lap_read_nop_cb(int /* unused */, GPS_SWay** /* unused */);
static unsigned int checkWayPointIsAtSplit(Waypoint* wpt, GPS_SLap** laps, int nlaps);
void track_read();
void route_read();
static void pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt);
static GPS_SWay* sane_GPS_Way_New();
static int waypt_write_cb(GPS_SWay** /* unused */);
static const char* get_gc_info(const Waypoint* wpt);
int waypoint_prepare();
void waypoint_write();
void route_hdr_pr(const route_head* rte);
void route_waypt_pr(const Waypoint* wpt);
void route_write();
void track_hdr_pr(const route_head* trk_head);
void track_waypt_pr(const Waypoint* wpt);
int track_prepare();
void track_write();
void course_write();
static const char* d103_symbol_from_icon_number(unsigned int n);
static int d103_icon_number_from_symbol(const QString& s);
void garmin_fs_garmin_after_read(GPS_PWay way, Waypoint* wpt, int protoid);
void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, int protoid);
/* Data Members */
const char* portname{};
MakeShort* mkshort_handle{};
GPS_PWay* tx_waylist{};
GPS_PWay* tx_routelist{};
GPS_PWay* cur_tx_routelist_entry{};
GPS_PTrack* tx_tracklist{};
GPS_PTrack* cur_tx_tracklist_entry{};
int my_track_count = 0;
OptionBool getposn;
OptionBool poweroff;
OptionBool eraset;
OptionBool resettime;
OptionInt snlen;
OptionBool snwhiteopt;
OptionString deficon;
OptionInt categoryopt;
OptionInt categorybitsopt{false, 0};
OptionInt baudopt;
OptionString opt_codec;
int baud = 0;
int category{};
int categorybits{};
bool receiver_must_upper = true;
QTextCodec* codec{nullptr};
QString valid_chars;
QVector<arglist_t> garmin_args = {
{
"snlen", &snlen, "Length of generated shortnames", nullptr,
ARGTYPE_INT, "1", nullptr, nullptr
},
{
"snwhite", &snwhiteopt, "Allow whitespace synth. shortnames",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{ "deficon", &deficon, "Default icon name", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr },
{
"get_posn", &getposn, "Return current position as a waypoint",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"power_off", &poweroff, "Command unit to power itself down",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"erase_t", &eraset, "Erase existing courses when writing new ones",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"resettime", &resettime, "Sync GPS time to computer time",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"category", &categoryopt, "Category number to use for written waypoints",
nullptr, ARGTYPE_INT, "1", "16", nullptr
},
{
"bitscategory", &categorybitsopt, "Bitmap of categories",
nullptr, ARGTYPE_INT, "1", "65535", nullptr
},
{
"baud", &baudopt, "Speed in bits per second of serial port (baud=9600)",
nullptr, ARGTYPE_INT, ARG_NOMINMAX, nullptr
},
{
"codec", &opt_codec, "override codec to use for device",
nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
};
gpsdevh* pvt_fd{};
static constexpr const char* d103_icons[16] = {
"dot",
"house",
"gas",
"car",
"fish",
"boat",
"anchor",
"wreck",
"exit",
"skull",
"flag",
"camp",
"circle_x",
"deer",
"1st_aid",
"back-track"
};
};
#endif // GARMIN_H_INCLUDED_