Merge lp:~bben-pub/igotu2gpx/igotu2gpx into lp:igotu2gpx

Proposed by Benjamin
Status: Needs review
Proposed branch: lp:~bben-pub/igotu2gpx/igotu2gpx
Merge into: lp:igotu2gpx
Diff against target: 186 lines (+60/-4)
7 files modified
.bzrignore (+3/-0)
HACKING (+30/-2)
src/connections/serialconnection/serialconnection.cpp (+1/-0)
src/lib/igotu/commands.cpp (+3/-1)
src/lib/igotu/igotucontrol.cpp (+9/-0)
src/lib/igotu/igotupoints.cpp (+13/-1)
src/lib/igotu/igotupoints.h (+1/-0)
To merge this branch: bzr merge lp:~bben-pub/igotu2gpx/igotu2gpx
Reviewer Review Type Date Requested Status
MobileAction i-gotU USB GPS travel logger Mac/Linux developers Pending
Review via email: mp+319657@code.launchpad.net

Description of the change

Fixes the bug for the years 2000 + n*16 due to the year being coded on 4 bits.

To post a comment you must log in.
Revision history for this message
Matija Nalis (mnalis) wrote :

"2016 FIX" part doesn't work for me on GT-200 (Firmware version: 2.11, Model: GT-200) - it claims to have "Number of points: 7536640" on empty device which is way too much (and so download takes hours). Without this patch it correctly says "Number of points: 0"

Revision history for this message
Benjamin (bben-pub) wrote :

> "2016 FIX" part doesn't work for me on GT-200 (Firmware version: 2.11, Model:
> GT-200) - it claims to have "Number of points: 7536640" on empty device which
> is way too much (and so download takes hours). Without this patch it correctly
> says "Number of points: 0"

I believe the issue comes from the previous update on which I based my changes (which simply modify the dates). I used a fix to support GT600 devices as it's the one I have, but it may break the GT200 compatibility. Did you try to use that GT600 branch to check if it's true?

Revision history for this message
Matija Nalis (mnalis) wrote :

> > "2016 FIX" part doesn't work for me on GT-200 (Firmware version: 2.11,
> Model:
> > GT-200) - it claims to have "Number of points: 7536640" on empty device
> which
> > is way too much (and so download takes hours). Without this patch it
> correctly
> > says "Number of points: 0"
>
> I believe the issue comes from the previous update on which I based my changes
> (which simply modify the dates). I used a fix to support GT600 devices as it's
> the one I have, but it may break the GT200 compatibility. Did you try to use
> that GT600 branch to check if it's true?

the issue seems to be with
http://bazaar.launchpad.net/~bben-pub/igotu2gpx/igotu2gpx/revision/213
at file "src/lib/igotu/commands.cpp" where there is added command
"count += result.data()[0]<<16;" being unconditionally done. It probably should be executed only if GT-600 (or GT-200e?) is detected, a not for everybody else (like plain GT-200).

Unmerged revisions

213. By Benjamin

Fix for the GT600 + year 2016

212. By charles <charles@masterpingoo>

Added 'clean' command support for GT-200e / GT-600

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-07-05 12:58:10 +0000
3+++ .bzrignore 2017-03-13 03:20:51 +0000
4@@ -44,3 +44,6 @@
5 /igotu2gpx-*.zip
6
7 /debian/tmp/
8+
9+# MacOS X
10+.DS_Store
11
12=== modified file 'HACKING'
13--- HACKING 2010-03-17 06:59:00 +0000
14+++ HACKING 2017-03-13 03:20:51 +0000
15@@ -347,6 +347,32 @@
16
17 ----
18 purge = false
19+ blocks = 0x800
20+ for i = blocks - 1; i > 0; --i:
21+ if purge:
22+ while UnknownWriteCommand2(0x0001) != 0x00:
23+ pass
24+ else:
25+ if ReadCommand(i * 0x1000, 0x10) != rep(0xff, 0x10):
26+ purge = true
27+ else:
28+ continue
29+ UnknownWriteCommand1(0x00)
30+ WriteCommand(0x20, i * 0x1000, '')
31+ if purge:
32+ UnknownPurgeCommand1(0x1e)
33+ UnknownPurgeCommand1(0x1f)
34+ while UnknownWriteCommand2(0x0001) != 0x00:
35+ pass
36+ UnknownPurgeCommand1(0x1e)
37+ UnknownPurgeCommand1(0x1f)
38+----
39+
40+GT-600, Firmware 5.24, @trip PC 3.2 1012.751
41+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
43+----
44+ purge = false
45 blocks = 0x200
46 for i = blocks - 1; i > 0; --i:
47 if purge:
48@@ -360,10 +386,12 @@
49 UnknownWriteCommand1(0x00)
50 WriteCommand(0x20, i * 0x1000, '')
51 if purge:
52+ UnknownPurgeCommand1(0x1d)
53 UnknownPurgeCommand1(0x1e)
54 UnknownPurgeCommand1(0x1f)
55 while UnknownWriteCommand2(0x0001) != 0x00:
56 pass
57+ UnknownPurgeCommand1(0x1d)
58 UnknownPurgeCommand1(0x1e)
59 UnknownPurgeCommand1(0x1f)
60 ----
61@@ -413,9 +441,9 @@
62 0x80: LED flashing when valid data is recorded is disabled
63 0x0004: uint8 max allowed time when button is pushed and start tracer mode?
64 0x0005: uint8 initial timeout when button is pushed and start tracer mode?
65- 0x0004: uint8 max allowed time when RTC power of GPS is lost (data/time is
66+ 0x0006: uint8 max allowed time when RTC power of GPS is lost (data/time is
67 not a valid value)
68- 0x0005: uint8 initial timeout when RTC power of GPS is lost (data/time is
69+ 0x0007: uint8 initial timeout when RTC power of GPS is lost (data/time is
70 not a valid value)
71 0x0008: uint8 schedule date offset: start date = utc date + offset
72 0x0009..0x00ff: uint4 schedule table plans (1 if no schedule used,
73
74=== modified file 'src/connections/serialconnection/serialconnection.cpp'
75--- src/connections/serialconnection/serialconnection.cpp 2013-05-18 12:54:49 +0000
76+++ src/connections/serialconnection/serialconnection.cpp 2017-03-13 03:20:51 +0000
77@@ -26,6 +26,7 @@
78 #else
79 #include <cerrno>
80 #include <fcntl.h>
81+#include <unistd.h>
82 #include <termios.h>
83 #include <unistd.h>
84 #endif
85
86=== modified file 'src/lib/igotu/commands.cpp'
87--- src/lib/igotu/commands.cpp 2013-05-18 12:54:49 +0000
88+++ src/lib/igotu/commands.cpp 2017-03-13 03:20:51 +0000
89@@ -126,7 +126,7 @@
90 id = Gt120;
91 break;
92 case 0x17:
93- name = IgotuCommand::tr("GT-200e");
94+ name = IgotuCommand::tr("GT-200e/GT-600");
95 id = Gt200e;
96 break;
97 }
98@@ -161,6 +161,8 @@
99 throw Exception(IgotuCommand::tr("Response too short"));
100 count = qFromBigEndian<quint16>(reinterpret_cast<const uchar*>
101 (result.data() + 1));
102+ count += result.data()[0]<<16;
103+
104 return result;
105 }
106
107
108=== modified file 'src/lib/igotu/igotucontrol.cpp'
109--- src/lib/igotu/igotucontrol.cpp 2013-05-18 12:54:49 +0000
110+++ src/lib/igotu/igotucontrol.cpp 2017-03-13 03:20:51 +0000
111@@ -478,6 +478,7 @@
112 model.sendAndReceive();
113
114 unsigned blocks = 1;
115+ bool run_UnknownPurgeCommand1_0x1d = false;
116
117 switch (model.modelId()) {
118 case ModelCommand::Gt100:
119@@ -489,6 +490,10 @@
120 case ModelCommand::Gt200:
121 blocks = 0x100;
122 break;
123+ case ModelCommand::Gt200e:
124+ blocks = 0x800;
125+ run_UnknownPurgeCommand1_0x1d = true;
126+ break;
127 default:
128 throw Exception(IgotuControl::tr
129 ("%1: Unable to clear memory of this GPS tracker model. "
130@@ -517,10 +522,14 @@
131 .sendAndReceive();
132 }
133 if (purgeBlocks) {
134+ if (run_UnknownPurgeCommand1_0x1d)
135+ UnknownPurgeCommand1(connection.get(), 0x1d).sendAndReceive();
136 UnknownPurgeCommand1(connection.get(), 0x1e).sendAndReceive();
137 UnknownPurgeCommand1(connection.get(), 0x1f).sendAndReceive();
138 waitForWrite();
139 }
140+ if (run_UnknownPurgeCommand1_0x1d)
141+ UnknownPurgeCommand1(connection.get(), 0x1d).sendAndReceive();
142 UnknownPurgeCommand1(connection.get(), 0x1e).sendAndReceive();
143 UnknownPurgeCommand1(connection.get(), 0x1f).sendAndReceive();
144 emit commandRunning(blocks, blocks);
145
146=== modified file 'src/lib/igotu/igotupoints.cpp'
147--- src/lib/igotu/igotupoints.cpp 2013-05-18 12:54:49 +0000
148+++ src/lib/igotu/igotupoints.cpp 2017-03-13 03:20:51 +0000
149@@ -145,12 +145,24 @@
150 (reinterpret_cast<const uchar*>(record.data()) + 4);
151
152 return QDateTime
153- (QDate(2000 + ((date >> 20) & 0xf), (date >> 16) & 0xf,
154+ (QDate(year((date >> 20) & 0xf), (date >> 16) & 0xf,
155 (date >> 11) & 0x1f),
156 QTime((date >> 6) & 0x1f, date & 0x3f, sec / 1000, sec % 1000),
157 Qt::UTC);
158 }
159
160+int IgotuPoint::year(unsigned yearOffset) const
161+{
162+ const int currentYear = QDate::currentDate().year();
163+ const int quotient = (currentYear - 2000) / 16;
164+ int year = 2000 + 16 * quotient + yearOffset;
165+
166+ if (year > currentYear)
167+ year -= 16;
168+
169+ return year;
170+}
171+
172 QString IgotuPoint::dateTimeString(int utcOffset) const
173 {
174 const QDateTime date = dateTime().addSecs(utcOffset);
175
176=== modified file 'src/lib/igotu/igotupoints.h'
177--- src/lib/igotu/igotupoints.h 2013-05-18 12:54:49 +0000
178+++ src/lib/igotu/igotupoints.h 2017-03-13 03:20:51 +0000
179@@ -45,6 +45,7 @@
180 bool isTrackStart() const;
181
182 QDateTime dateTime() const;
183+ int year(unsigned yearOffset) const;
184 // offset in seconds
185 QString humanDateTimeString(int utcOffset = 0) const;
186 // offset in seconds

Subscribers

People subscribed via source and target branches