Re: [Gpsbabel-code] DG-100 GPS data logger support
GPSBabel converts and transfers data like waypoints, tracks & routes.
Brought to you by:
robertl
|
From: <mir...@in...> - 2007-09-09 14:06:43
|
Hi,
please consider applying the below patch to dg-100.c.
Changelog:
- increase RX timeout because dg100_erase() needs >20s
- remove unused variables in dg100_getfileheaders()
which were moved into a local code block for debugging
- add more debugging output to dg100_getfileheaders()
- fix loop condition in dg100_getfileheaders()
About the last item (loop condition change):
The spec says I should continue reading headers as long as (numheaders!=0),
and that's what I did. However, there was a problem when reading from a
DG-100 with full memory - numheaders never became zero, and nextheader
wrapped around:
found 150 headers, nextheader=150
found 150 headers, nextheader=300
found 150 headers, nextheader=450
found 150 headers, nextheader=600
found 72 headers, nextheader=0
found 150 headers, nextheader=150
found 150 headers, nextheader=300
I changed the test to (nextheader!=0), which seems to be more reliable.
In case this also breaks, I could combine the two conditions,
but I'd prefer not to do that unless necessary.
Thanks,
Mirko
Index: dg-100.c
===================================================================
RCS file: /cvsroot/gpsbabel/gpsbabel/dg-100.c,v
retrieving revision 1.5
diff -u -p -r1.5 dg-100.c
--- dg-100.c 8 Sep 2007 21:00:14 -0000 1.5
+++ dg-100.c 9 Sep 2007 13:37:07 -0000
@@ -325,8 +325,9 @@ dg100_recv_byte()
{
int result;
- /* allow for a delay of 20s; especially erase can take a long time */
- result = gbser_readc_wait(serial_handle, 20000);
+ /* allow for a delay of 40s;
+ * erasing the whole DG-100 memory takes about 21s */
+ result = gbser_readc_wait(serial_handle, 40000);
switch(result){
case gbser_ERROR:
fatal("dg100_recv_byte(): error reading one byte\n");
@@ -529,8 +530,6 @@ dg100_getfileheaders(struct dynarray16 *
int seqnum;
gbint16 numheaders, nextheader, *h;
int i, offset;
- //time_t ti;
- //int time, date;
nextheader = 0;
do {
@@ -541,6 +540,8 @@ dg100_getfileheaders(struct dynarray16 *
/* process the answer */
numheaders = be_read16(answer);
nextheader = be_read16(answer + 2);
+ dg100_log("found %d headers, nextheader=%d\n",
+ numheaders, nextheader);
h = dynarray16_alloc(headers, numheaders);
for (i = 0; i < numheaders; i++) {
@@ -555,7 +556,7 @@ dg100_getfileheaders(struct dynarray16 *
i, seqnum, ctime(&ti));
}
}
- } while (numheaders != 0);
+ } while (nextheader != 0);
}
static void
|