Patch for WSG-1000 to upload marks

View: New views
1 Messages — Rating Filter:   Alert me  

Patch for WSG-1000 to upload marks

by Jamie Honan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The WSG-1000 is similar to WBT-200/100/201, but it also allows waypoint
(or 'mark') uploads.

This patch adds this in a simple way. Also allows you to specify
erase=1 to pre-erase waypoints before uploading.

Patch generated against cvs version of 2009-10-16.
Files
   vecs.c (only for description)
   wbt200.c - for mods.

protocol for marks for wsg-1000

Read Mark

PC-->WSG1000:   @AL,10,2,idx\r\n
//Idx=0:127

WSG1000-->PC:           @AL,10,2,idx,markid,icon,lat,lon,alt,name\r\n

Write Mark
When write a marks list that should be erasing all marks first.
@AL,10,3\r\n //Delete all marks suggest delay 1~5 Sec.

Write a mark
@AL,10,1,idx,lat,lon,alt,name\r\n

Regards
Jamie


diff -u gpsbabel/vecs.c gpsbabel-jh/vecs.c
--- gpsbabel/vecs.c 2009-10-12 08:20:27.000000000 +1100
+++ gpsbabel-jh/vecs.c 2009-10-16 11:46:23.000000000 +1100
@@ -479,7 +479,7 @@
         {
                 &wbt_svecs,
                 "wbt",
-                "Wintec WBT-100/200 GPS Download",
+                "Wintec WBT-100/200 Download, WSG-1000 Marks Upload",
                 NULL
         },
  {
diff -u gpsbabel/wbt-200.c gpsbabel-jh/wbt-200.c
--- gpsbabel/wbt-200.c 2009-06-17 11:27:34.000000000 +1000
+++ gpsbabel-jh/wbt-200.c 2009-10-16 12:29:59.000000000 +1100
@@ -91,6 +91,7 @@
 static FILE *fl;
 static char *port;
 static char *erase;
+static int markpt_index; /* starts from 0, maybe allow user settable */
 
 static enum {
     UNKNOWN, WBT200, WBT201, WSG1000
@@ -510,7 +511,7 @@
 
     sprintf(wp_name, fmt, index);
 
-    wpt->latitude       = lat;;
+    wpt->latitude       = lat;
     wpt->longitude      = lon;
     wpt->altitude       = alt;
     wpt->creation_time  = tim;
@@ -956,6 +957,78 @@
     do_simple("@AL,2,1", BUFSPEC(line_buf));
 }
 
+/* WSG1000 G-TRENDER has the ability to upload (and download) mark points.
+ * These are slightly different to waypoints (or points of interest).
+ * Future version should allow start index, since these probably determine
+ * icon displayed.
+ * Also, download (although, waypoints are easier to set) in future.
+ * pre-erase using erase=1
+ */
+
+static void
+wsg1000_writemarkpt(const waypoint *wpt)
+{
+    char                line_buf[100];
+    char                cmd_buf[100];
+    char                *name;
+
+    if (markpt_index < 0 || markpt_index > 127) /* index from 0 to 127 */
+        fatal(MYNAME ": Maximum of 128 route points\n");
+    if (wpt->shortname)
+         name = wpt->shortname;
+    else if (wpt->description)
+         name = wpt->description;
+    else if (wpt->notes)
+         name = wpt->notes;
+    else {
+        sprintf(line_buf, "%d", markpt_index+1);
+        name = line_buf;
+    }
+    sprintf(cmd_buf, "@AL,10,1,%d,%lf,%lf,%lf,%.32s",
+        markpt_index,
+ wpt->latitude,
+ wpt->longitude,
+ wpt->altitude,
+        name);
+    db(1, "Route write %s\n", cmd_buf);
+    do_simple(cmd_buf, BUFSPEC(line_buf));
+    markpt_index++;
+}
+
+static void wsg1000_mark_write(void) {
+    char                line_buf[100];
+
+    const char          *tmp;
+
+    double              ver_hw;
+    double              ver_sw;
+    double              ver_fmt;
+
+    /* Read various device information. We don't use much of this yet -
+     * just log_addr_start and log_addr_end - but it's useful to have it
+     * here for debug and documentation purposes.
+     */
+    tmp = get_param("@AL,7,1", BUFSPEC(line_buf));
+    db(1, "Route write device \"%s\"\n", tmp);
+    ver_hw         = get_param_float("@AL,8,1");
+    ver_sw         = get_param_float("@AL,8,2");
+    ver_fmt        = get_param_float("@AL,8,3");
+
+    db(2, "versions: hw=%f, sw=%f, fmt=%f\n",
+        ver_hw, ver_sw, ver_fmt);
+    
+    if (*erase != '0') {
+        /* erase marks from device */
+        do_simple("@AL,10,3", BUFSPEC(line_buf));
+        gb_sleep(5*1000);
+    }
+    markpt_index = 0; /* index from 0 to 127 */
+    waypt_disp_all(wsg1000_writemarkpt);
+
+    do_simple("@AL,2,1", BUFSPEC(line_buf));
+}
+
+
 static void file_read(void) {
     char                buf[512];
     size_t              rc;
@@ -1032,23 +1105,35 @@
     }
 }
 
+static void mark_write(void) {
+    switch (dev_type) {
+        case WSG1000:
+            wsg1000_mark_write();
+            break;
+            
+        default:
+            fatal(MYNAME ": Device does not support route upload\n");
+            break;
+    }
+}
+
 /* wbt */
 
 static arglist_t wbt_sargs[] = {
-    { "erase", &erase, "Erase device data after download",
+    { "erase", &erase, "Erase log after download, marks before upload",
         "0", ARGTYPE_BOOL, ARG_NOMINMAX },
     ARG_TERMINATOR
 };
 
 ff_vecs_t wbt_svecs = {
     ff_type_serial,
-    { ff_cap_read, ff_cap_read, ff_cap_none },
+    { ff_cap_read, ff_cap_read, ff_cap_write },
+    rd_init,
     rd_init,
-    NULL,
     rd_deinit,
-    NULL,
+    rd_deinit,
     data_read,
-    NULL,
+    mark_write,
     NULL,
     wbt_sargs,
     CET_CHARSET_UTF8, 1         /* master process: don't convert anything | CET-REVIEW */


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Gpsbabel-code mailing list  http://www.gpsbabel.org
Gpsbabel-code@...
https://lists.sourceforge.net/lists/listinfo/gpsbabel-code