218
218
#-------------------------------------------------------------------------
219
219
# Get options from command line.
220
220
#-------------------------------------------------------------------------
221
if (! getopts('ab:cd:Ef:hil:m:o:p:Rr:s:tvw') or $opt_h) {
221
if (! getopts('ab:cd:Ef:hil:m:o:p:Rr:s:tvwx') or $opt_h) {
222
222
my $str1 = describe_log_format(0x00fff);
223
223
my $str2 = describe_log_format(0xff000);
225
225
Usage: $NAME [options]
227
227
-a Read all the log memory (overlapped data)
228
-b filename.bin Do not read data from a GPS device, but rather read a
229
previously saved .bin file. Ignore -f option
230
-c Create a gpx file with tracks and waypoints
228
-b filename.bin Don't read data from a GPS device, but rather read
229
a previously saved .bin file. Ignore -f option
230
-c Create a GPX file with tracks and waypoints
231
231
-d debug_level Debug level: 0..7
232
232
-E Erase data log memory
233
233
-f filename Base name for saved files (.bin and .gpx)
234
234
-h Print this message and exit
235
-i Ignore some error conditions and try to extract data
236
-l {on|off} Turn loggin ON/OFF
235
-i Ignore some error conditions, try to extract data
236
-l {on|off} Turn logging ON/OFF
237
237
-m {stop|overlap} Set STOP/OVERLAP recording method on memory full
238
-o log_format Enable or disable log fields (FIELD1,-FIELD2,...), available fields:
238
-o log_format Enable or disable log fields (FIELD1,-FIELD2,...),
241
242
-p port Communication port, default: $port
242
-R Recover from disabled log: erase data and reset recording criteria
243
-R Recover from disabled log: erase data and reset
243
245
-r time:distance:speed Set logging criteria (zero to disable):
244
every 1-999 seconds, every 10-9999 meters, over 10-999 km/h
246
every 0.10-9999999.90 seconds, every 0.10-9999999.90
247
meters, over 0.10-9999999.90 km/h
245
248
-s speed Serial port speed, default $baudrate baud
246
-t Create a gpx file with tracks
249
-t Create a GPX file with tracks
247
250
-v Print MTKBabel version and exit
248
-w Create a gpx file with waypoints
251
-w Create a GPX file with waypoints
252
-x Force reading Holux format
251
255
Download traks and waypoints from GPS device, creating the
260
264
#-------------------------------------------------------------------------
261
265
# Check command line options.
262
266
#-------------------------------------------------------------------------
263
if ($opt_v) { print "\nMTKBabel Version 0.8\n\n"; exit }
267
if ($opt_v) { print "\nMTKBabel Version 0.8.2\n\n"; exit }
264
268
$debug = $opt_d if (defined($opt_d) and ($opt_d >= $LOG_EMERG) and ($opt_d <= $LOG_DEBUG));
265
269
$port = $opt_p if (defined($opt_p));
266
270
$baudrate = int($opt_s) if (defined($opt_s));
267
271
$opt_f = substr($opt_f, 0, -4) if (substr($opt_f, -4) eq '.bin');
268
272
$opt_b = substr($opt_b, 0, -4) if (substr($opt_b, -4) eq '.bin');
274
#-------------------------------------------------------------------------
275
# Force Holux format. Required to read a binary file because some
276
# Holux devices does not embed Holux identifier into the data.
277
#-------------------------------------------------------------------------
280
set_data_types($model_id);
271
283
#-------------------------------------------------------------------------
272
284
# Do not open the device, read instead an existing binary log file.
306
318
# Query firmware release (PMTK_Q_RELEASE). Examples:
320
# Holux M-1200E PMTK705,AXN_1.30-B_1.3_C01,0000,01035-01A,1.0
308
321
# ??? PMTK705,M-core_1.8,0001
309
322
# 747 ??? PMTK705,B-core_1.1,0002,TSI_747CD,1.0
323
# Qstarz BT-Q1000X PMTK705,AXN_1.0-B_1.3_C01,0003,QST1000,1.0
310
324
# 747 ??? PMTK705,B-core_1.1,0004,TSI747CD,1.0
325
# Qstarz BT-Q1000P PMTK705,B-core_1.1,0005,QST1000P,1.0
326
# 747 A+ Trip Recorder PMTK705,AXN_1.0-B_1.3_C01,0006
311
327
# ??? PMTK705,M-core_1.85,0008
312
328
# i-Blue 747 PMTK705,M-core_1.94,001B
313
329
# Holux M-241 PMTK705,B-core_1.1,0021,01017-00C,1.0
314
330
# Holux M-241 PMTK705,B-core_1.20,0023,01017-00D,1.0
331
# Holum M-241 fw 1.13 PMTK705,B-core_1.20,0043,01017-00F,1.0
316
335
packet_send('PMTK605');
317
336
$ret = packet_wait('PMTK705,');
369
390
undef($time) if ($time eq '');
370
391
undef($distance) if ($distance eq '');
371
392
undef($speed) if ($speed eq '');
372
$time = int($time ) if (defined($time));
373
$distance = int($distance) if (defined($distance));
374
$speed = int($speed ) if (defined($speed));
375
if (defined($time) and (($time >= 1 and $time <= 999) or ($time == 0))) {
376
packet_send(sprintf('PMTK182,1,3,%u', $time * 10));
377
packet_wait('PMTK001,182,1,3');
379
if (defined($distance) and (($distance >= 10 and $distance <= 9999) or ($distance == 0))) {
380
packet_send(sprintf('PMTK182,1,4,%u', $distance * 10));
381
packet_wait('PMTK001,182,1,3');
383
if (defined($speed) and (($speed >= 10 and $speed <= 999) or ($speed == 0))) {
384
packet_send(sprintf('PMTK182,1,5,%u', $speed * 10));
393
# Expect floating point values.
394
$time = eval(1.0 * $time ) if (defined($time));
395
$distance = eval(1.0 * $distance) if (defined($distance));
396
$speed = eval(1.0 * $speed ) if (defined($speed));
397
if (defined($time) and (($time >= 0.10 and $time <= 9999999.90) or ($time == 0))) {
398
packet_send(sprintf('PMTK182,1,3,%u', int($time * 10)));
399
packet_wait('PMTK001,182,1,3');
401
if (defined($distance) and (($distance >= 0.10 and $distance <= 9999999.90) or ($distance == 0))) {
402
packet_send(sprintf('PMTK182,1,4,%u', int($distance * 10)));
403
packet_wait('PMTK001,182,1,3');
405
if (defined($speed) and (($speed >= 0.10 and $speed <= 9999999.90) or ($speed == 0))) {
406
packet_send(sprintf('PMTK182,1,5,%u', int($speed * 10)));
385
407
packet_wait('PMTK001,182,1,3');
815
837
#------------------------------------------------------------------
817
# - record separator: AAAAAAAAAAAAAAXXYYYYYYYYBBBBBBBB
818
# - non written space: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
819
# - Holux M-241 separators : HOLUXGR241LOGGER
839
# - record separator: "AAAAAAAAAAAAAAXXYYYYYYYYBBBBBBBB"
840
# - non written space: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
841
# - Holux M-241 separators: "HOLUXGR241LOGGER"
843
# - Holux M-241 fw 1.13 sep.: "HOLUXGR241LOGGER "
844
# "HOLUXGR241WAYPNT "
821
845
#------------------------------------------------------------------
822
846
if (($log_len - tell($fp)) >= $SIZEOF_SEPARATOR) {
856
888
#----------------------------------------------------------
857
889
printf("Separator: %s\n", $buffer) if ($debug >= $LOG_INFO);
858
890
$model_id = '0021';
891
if (($log_len - tell($fp)) >= 4) {
892
$buffer = my_read($fp, 4);
893
if ($buffer eq ' ') {
859
899
set_data_types($model_id);
860
900
$next_data_force_waypoint = 1;
1661
1701
#-------------------------------------------------------------------------
1662
1702
sub flash_memory_size {
1663
1703
my $model = shift;
1664
return( 8 * 1024 * 1024 / 8) if ($model == 0x1388); # 757/ZI v1 8 Mbit = 1 Mb
1665
return( 8 * 1024 * 1024 / 8) if ($model == 0x5202); # 757/ZI v2 8 Mbit = 1 Mb
1666
return(32 * 1024 * 1024 / 8) if ($model == 0x8300); # Qstartz BT-1200 32 Mbit = 4 Mb
1705
return( 8 * 1024 * 1024 / 8) if ($model == 0x1388); # 757/ZI v1
1706
return( 8 * 1024 * 1024 / 8) if ($model == 0x5202); # 757/ZI v2
1708
return(32 * 1024 * 1024 / 8) if ($model == 0x0000); # Holux M-1200E
1709
return(32 * 1024 * 1024 / 8) if ($model == 0x0005); # Qstarz BT-Q1000P
1710
return(32 * 1024 * 1024 / 8) if ($model == 0x0006); # 747 A+ GPS Trip Recorder
1667
1711
return(32 * 1024 * 1024 / 8) if ($model == 0x0008); # Pentagram PathFinder P 3106
1668
# 0x0051 i-Blue 737, Qstartz 810, Polaris iBT-GPS, Holux M1000
1669
# 0x0002 Qstartz 815
1712
return(32 * 1024 * 1024 / 8) if ($model == 0x8300); # Qstarz BT-1200
1714
# 0x0051 i-Blue 737, Qstarz 810, Polaris iBT-GPS, Holux M1000
1670
1716
# 0x001b i-Blue 747
1671
1717
# 0x001d BT-Q1000 / BGL-32
1672
1718
# 0x0131 EB-85A
1673
return(16 * 1024 * 1024 / 8); # 16Mbit -> 2Mb
1719
return(16 * 1024 * 1024 / 8);
1676
1722
#-------------------------------------------------------------------------
1681
1727
my $port = shift;
1682
1728
my $baudrate = shift;
1683
1729
die("Cannot open $port. Did you switch ON the GPS device?\n") if (! -c $port);
1684
$device = Device::SerialPort->new($port);
1730
$device = Device::SerialPort->new($port)
1731
|| die "ERROR: Opening serial device $port: $!";
1685
1732
$device->baudrate($baudrate) || die "fail setting baud rate";
1686
1733
$device->parity('none') || die "fail setting parity";
1687
1734
$device->databits(8) || die "fail setting databits";
1720
1767
my $model_id = shift;
1722
if ($model_id eq '0005' or
1769
if ($model_id eq '0000' or
1770
$model_id eq '0005' or
1723
1771
$model_id eq '0021' or
1724
$model_id eq '0023')
1772
$model_id eq '0023' or
1773
$model_id eq '0043')
1726
printf("Setting log format and data types for Holum M-241, model ID %s\n", $model_id) if ($debug >= $LOG_INFO);
1775
printf("Setting log format and data types for Holux, model ID %s\n", $model_id) if ($debug >= $LOG_INFO);
1727
1776
$LOG_HAS_CHECKSUM_SEPARATOR = 0;
1728
1777
$SIZEOF_LOG_LATITUDE = $SIZEOF_FLOAT;
1729
1778
$SIZEOF_LOG_LONGITUDE = $SIZEOF_FLOAT;