]> err.no Git - gant/commitdiff
Adding Wali's changes
authorJordan Miller <jordan@luckyone.(none)>
Thu, 1 Oct 2009 01:36:22 +0000 (20:36 -0500)
committerJordan Miller <jordan@luckyone.(none)>
Thu, 1 Oct 2009 01:36:22 +0000 (20:36 -0500)
antlib.c
gant.c

index a486e0dfa9ebf9f23d2bad98576a8ff031aa1ffa..7a1668efc3b85ba64ae8539b45a5c38a38d50d0f 100644 (file)
--- a/antlib.c
+++ b/antlib.c
@@ -68,6 +68,13 @@ msg_send(uchar mesg, uchar *inbuf, uchar len)
                if (dbg) {
                        perror("failed write");
                }
+       } else if (dbg == 2) {
+               // Wali: additional raw data output
+               printf(">>>\n    00000000:");
+               for (i = 0; i < (len + 4); i++) {
+                       printf(" %02x", buf[i]);
+               }
+               putchar('\n');
        }
        return 1;
 }
@@ -142,8 +149,14 @@ get_data(int fd)
                        fprintf(stderr, "%02x", buf[j]);
                fprintf(stderr, "\n");
                exit(1);
+       } else if (dbg == 2) {
+               // Wali: additional raw data output
+               printf("<<<\n    00000000:");
+               for (i = 0; i < bufc; i++) {
+                       printf(" %02x", buf[i]);
+               }
+               putchar('\n');
        }
-
        // some data in buf
        // search for possible valid messages
   srch = 0;
diff --git a/gant.c b/gant.c
index f4fdcf530a36a532efc4c13297fffa2d1ac201b0..3a90df4059897d9c27e1e782f5804a451ade35bc 100644 (file)
--- a/gant.c
+++ b/gant.c
 
 #include "antdefs.h"
 
-char *releasetime = "Jan 24 2009, 16:10:12";
-uint majorrelease = 0;
-uint minorrelease = 6;
+// all version numbering according ant agent for windows 2.2.1
+char *releasetime = "Jul 30 2009, 17:42:56";
+uint majorrelease = 2;
+uint minorrelease = 2;
+uint majorbuild = 7;
+uint minorbuild = 0;
 
 double round(double);
 
@@ -38,7 +41,7 @@ int donebind = 0;
 int sentgetv;
 char *fname = "garmin";
 
-static char  ANTSPT_KEY[] = "A8A423B9F55E63C1"; // ANT+Sport key
+static char ANTSPT_KEY[] = "A8A423B9F55E63C1"; // ANT+Sport key
 
 static uchar ebuf[MESG_DATA_SIZE]; // response event data gets stored here
 static uchar cbuf[MESG_DATA_SIZE]; // channel event data gets stored here
@@ -64,6 +67,7 @@ uint isa405;
 uint waitauth;
 int nphase0;
 char modelname[256];
+char devname[256];
 ushort part = 0;
 ushort ver = 0;
 uint unitid = 0;
@@ -98,9 +102,10 @@ int outfd; // output file
 char *fn = "default_output_file";
 char *progname;
 
-#define BSIZE 8*100
-uchar *burstbuf = 0;
-uchar *blast = 0;
+#define BSIZE 8*10000
+//uchar blast[BSIZE]; // should be like that, but not working
+uchar *blast = 0; // first time reading not initialized, but why it is working reading from adr 0?
+
 int blsize = 0;
 int bused = 0;
 int lseq = -1;
@@ -110,24 +115,24 @@ int lseq = -1;
 char *
 ground(double d)
 {
-  int neg = 0;
-  static char res[30];
-  ulong ival;
-  ulong l; /* hope it doesn't overflow */
+       int neg = 0;
+       static char res[30];
+       ulong ival;
+       ulong l; /* hope it doesn't overflow */
 
-  if (d < 0) {
-    neg = 1;
-    d = -d;
-  }
-  ival = floor(d);
-  d -= ival;
-  l = floor(d*100000000);
-  if (l % 10 >= 5)
-    l = l/10+1;
-  else
-    l = l/10;
-  sprintf(res,"%s%ld.%07ld", neg?"-":"", ival, l);
-  return res;
+       if (d < 0) {
+               neg = 1;
+               d = -d;
+       }
+       ival = floor(d);
+       d -= ival;
+       l = floor(d*100000000);
+       if (l % 10 >= 5)
+               l = l/10+1;
+       else
+               l = l/10;
+       sprintf(res,"%s%ld.%07ld", neg?"-":"", ival, l);
+       return res;
 }
 
 char *
@@ -173,7 +178,7 @@ print_tcx_footer(FILE *tcxfile)
        fprintf(tcxfile, "        </Track>\n");
        fprintf(tcxfile, "      </Lap>\n");
        fprintf(tcxfile, "      <Creator xsi:type=\"Device_t\">\n");
-       fprintf(tcxfile, "        <Name>%s</Name>\n", modelname);
+       fprintf(tcxfile, "        <Name>%s</Name>\n", devname);
        fprintf(tcxfile, "        <UnitId>%u</UnitId>\n", unitid);
        fprintf(tcxfile, "        <ProductID>%u</ProductID>\n", part);
        fprintf(tcxfile, "        <Version>\n");
@@ -186,20 +191,20 @@ print_tcx_footer(FILE *tcxfile)
        fprintf(tcxfile, "    </Activity>\n");
        fprintf(tcxfile, "  </Activities>\n\n");
        fprintf(tcxfile, "  <Author xsi:type=\"Application_t\">\n");
-       fprintf(tcxfile, "    <Name>Garmin ANT for Linux</Name>\n");
+       fprintf(tcxfile, "    <Name>Garmin ANT Agent(tm)</Name>\n");
        fprintf(tcxfile, "    <Build>\n");
        fprintf(tcxfile, "      <Version>\n");
        fprintf(tcxfile, "        <VersionMajor>%u</VersionMajor>\n", majorrelease);
        fprintf(tcxfile, "        <VersionMinor>%u</VersionMinor>\n", minorrelease);
-       fprintf(tcxfile, "        <BuildMajor>0</BuildMajor>\n");
-       fprintf(tcxfile, "        <BuildMinor>0</BuildMinor>\n");
+       fprintf(tcxfile, "        <BuildMajor>%u</BuildMajor>\n", majorbuild);
+       fprintf(tcxfile, "        <BuildMinor>%u</BuildMinor>\n", minorbuild);
        fprintf(tcxfile, "      </Version>\n");
        fprintf(tcxfile, "      <Type>Release</Type>\n");
        fprintf(tcxfile, "      <Time>%s</Time>\n", releasetime);
-       fprintf(tcxfile, "      <Builder>make</Builder>\n");
+       fprintf(tcxfile, "      <Builder>sqa</Builder>\n");
        fprintf(tcxfile, "    </Build>\n");
        fprintf(tcxfile, "    <LangID>EN</LangID>\n");
-       fprintf(tcxfile, "    <PartNumber>006-A0XXX-00</PartNumber>\n");
+       fprintf(tcxfile, "    <PartNumber>006-A0214-00</PartNumber>\n");
        fprintf(tcxfile, "  </Author>\n\n");
        fprintf(tcxfile, "</TrainingCenterDatabase>\n");
        return;
@@ -240,7 +245,7 @@ struct pair_msg {
 #define ACKSIZE 8 // above structure must be this size
 #define AUTHSIZE 24 // ditto
 #define PAIRSIZE 16
-#define MAXLAPS 256  // max of saving laps data before output with trackpoint data
+#define MAXLAPS 256 // max of saving laps data before output with trackpoint data
 #define MAXTRACK 256 // max number of tracks to be saved per download
 
 decode(ushort bloblen, ushort pkttype, ushort pktlen, int dsize, uchar *data)
@@ -258,7 +263,6 @@ decode(ushort bloblen, ushort pkttype, ushort pktlen, int dsize, uchar *data)
        int doff = 20;
        char model[256];
        char gpsver[256];
-       char devname[256];
        float alt;
        float dist;
        uint tv;
@@ -400,11 +404,11 @@ decode(ushort bloblen, ushort pkttype, ushort pktlen, int dsize, uchar *data)
                        }
                        // use first lap starttime as filename
                        lap = firstlap_id_track[track_id-firsttrack_id] - firstlap_id;
-            if (dbg) printf("lap %u track_id %u firsttrack_id %u firstlap_id %u\n", lap, track_id, firsttrack_id, firstlap_id);
+                       if (dbg) printf("lap %u track_id %u firsttrack_id %u firstlap_id %u\n", lap, track_id, firsttrack_id, firstlap_id);
                        tv_lap = lapbuf[lap][4] + lapbuf[lap][5]*256 +
                                        lapbuf[lap][6]*256*256 + lapbuf[lap][7]*256*256*256;
                        ttv = tv_lap + 631065600; // garmin epoch offset
-                       strftime(tbuf, sizeof tbuf, "%Y.%m.%d %H%M%S.TCX", localtime(&ttv));
+                       strftime(tbuf, sizeof tbuf, "%Y-%m-%d-%H%M%S.TCX", localtime(&ttv));
                        // open file and start with header of xml file
                        tcxfile = fopen(tbuf, "wt");
                        print_tcx_header(tcxfile);
@@ -545,22 +549,24 @@ decode(ushort bloblen, ushort pkttype, ushort pktlen, int dsize, uchar *data)
                        }
                        if (dist < (float)40000000) {
                                fprintf(tcxfile, "            <SensorState>%s</SensorState>\n", u1 ? "Present" : "Absent");
-                               fprintf(tcxfile, "            <Extensions>\n");
-                               fprintf(tcxfile, "              <TPX xmlns=\"http://www.garmin.com/xmlschemas/ActivityExtension/v2\" CadenceSensor=\"");
-                               // get type of pod from data, could not figure it out, so using sporttyp of first track
-                               if (sporttyp_track[track_id-firsttrack_id] == 1) {
-                                       fprintf(tcxfile, "Bike\"/>\n");
-                               } else {
-                                       fprintf(tcxfile, "Footpod\"");
-                                       if (cad != 255) {
-                                               fprintf(tcxfile, ">\n");
-                                               fprintf(tcxfile, "                <RunCadence>%d</RunCadence>\n", cad);
-                                               fprintf(tcxfile, "              </TPX>\n");
+                               if (u1 == 1 || cad != 255) {
+                                       fprintf(tcxfile, "            <Extensions>\n");
+                                       fprintf(tcxfile, "              <TPX xmlns=\"http://www.garmin.com/xmlschemas/ActivityExtension/v2\" CadenceSensor=\"");
+                                       // get type of pod from data, could not figure it out, so using sporttyp of first track
+                                       if (sporttyp_track[track_id-firsttrack_id] == 1) {
+                                               fprintf(tcxfile, "Bike\"/>\n");
                                        } else {
-                                               fprintf(tcxfile, "/>\n");
+                                               fprintf(tcxfile, "Footpod\"");
+                                               if (cad != 255) {
+                                                       fprintf(tcxfile, ">\n");
+                                                       fprintf(tcxfile, "                <RunCadence>%d</RunCadence>\n", cad);
+                                                       fprintf(tcxfile, "              </TPX>\n");
+                                               } else {
+                                                       fprintf(tcxfile, "/>\n");
+                                               }
                                        }
+                                       fprintf(tcxfile, "            </Extensions>\n");
                                }
-                               fprintf(tcxfile, "            </Extensions>\n");
                                track_pause = 0;
                        }
                        fprintf(tcxfile, "          </Trackpoint>\n");