TSIP mode switch for gpsctl

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

TSIP mode switch for gpsctl

by Matt Roberds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

All,

With my earlier patches, I have basically got what I wanted: a way to flip
a Trimble TSIP GPS into NMEA mode from the command line.  But since gpsctl
has built-in -n/-b flags for some other protocols, I figured I'd take a
stab at implementing this for TSIP; the patch is below.  Note that this
hasn't been through the regression tests or splint yet.  It does work, at
least for my Resolution T dev kit.  (In general, gpsctl seems to take a
while to recognize that the GPS is speaking TSIP, but it was doing that
before I started hacking on it.)

Is this about the right way to do it?  I'm pretty sure (not 100%) that I
have to set up the NMEA messages I want with the TSIP command before
switching, because I don't think there's a way to ask for which NMEA
sentences you want once you're in NMEA mode.  Also, I summarily go to
4800 8N1 when switching to NMEA, and 9600 8O1 when going back to TSIP;
maybe I should just leave the current settings alone?

Any other comments?

Thanks!

Matt Roberds

----cut here----
--- driver_tsip.c.orig 2009-06-04 21:31:19.000000000 -0500
+++ driver_tsip.c.withmodeswitch 2009-06-04 21:36:37.000000000 -0500
@@ -830,6 +830,51 @@
 
     return true; /* it would be nice to error-check this */
 }
+
+static void tsip_mode(struct gps_device_t *session, int mode)
+{
+    unsigned char buf[16];
+
+    if (mode == MODE_NMEA) {
+        /* First turn on the NMEA messages we want */
+
+        putbyte(buf,0,0x00); /* subcode 0 */
+        putbyte(buf,1,0x01);            /* 1-second fix interval */
+        putbyte(buf,2,0x00); /* Reserved */
+        putbyte(buf,3,0x00); /* Reserved */
+        putbyte(buf,4,0x01); /* 0=RMC, 1-7=Reserved */
+        putbyte(buf,5,0x19); /* 0=GGA, 1=GGL, 2=VTG, 3=GSV, */
+                                        /* 4=GSA, 5=ZDA, 6-7=Reserved  */
+
+        (void)tsip_write(session, 0x7A, buf, 6);
+
+        /* Now switch to NMEA mode */
+
+        memset(buf, 0, sizeof(buf));
+
+        putbyte(buf,0,0xff); /* current port */
+        putbyte(buf,1,0x06);            /* 4800 bps input */
+        putbyte(buf,2,0x06); /* 4800 bps output */
+        putbyte(buf,3,0x03); /* 8 data bits */
+        putbyte(buf,4,0x00); /* No parity */
+        putbyte(buf,5,0x00); /* 1 stop bit */
+        putbyte(buf,6,0x00); /* No flow control */
+        putbyte(buf,7,0x02); /* Input protocol TSIP */
+        putbyte(buf,8,0x04); /* Output protocol NMEA */
+        putbyte(buf,9,0x00); /* Reserved */
+
+        (void)tsip_write(session, 0xBC, buf, 10);
+
+    } else if (mode == MODE_BINARY) {
+        /* The speed switcher also puts us back in TSIP, so call it */
+        /* with the default 9600 8O1. */
+
+        tsip_speed_switch(session, 9600, 'O', 1);
+
+    } else {
+        gpsd_report(LOG_ERROR, "unknown mode %i requested\n", mode);
+    }
+}
 #endif /* ALLOW_RECONFIGURE */
 
 /* this is everything we export */
@@ -851,7 +896,7 @@
 #ifdef ALLOW_RECONFIGURE
     .configurator   = tsip_configurator,/* initial mode sets */
     .speed_switcher = tsip_speed_switch,/* change baud rate */
-    .mode_switcher  = NULL, /* no mode switcher */
+    .mode_switcher  = tsip_mode, /* there is a mode switcher */
     .rate_switcher  = NULL, /* no rate switcher */
     .min_cycle      = 1, /* not relevant, no rate switcher */
     .revert         = NULL, /* FIXME: revert sentence mix */
----cut here----

_______________________________________________
Gpsd-users mailing list
Gpsd-users@...
https://lists.berlios.de/mailman/listinfo/gpsd-users

Re: TSIP mode switch for gpsctl

by Chris Kuethe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jun 4, 2009 at 8:48 PM, <mattroberds@...> wrote:
> All,

Good bug squashing - thanks!

> With my earlier patches, I have basically got what I wanted: a way to flip
> a Trimble TSIP GPS into NMEA mode from the command line.  But since gpsctl
> has built-in -n/-b flags for some other protocols, I figured I'd take a
> stab at implementing this for TSIP; the patch is below.  Note that this
> hasn't been through the regression tests or splint yet.  It does work, at
> least for my Resolution T dev kit.  (In general, gpsctl seems to take a
> while to recognize that the GPS is speaking TSIP, but it was doing that
> before I started hacking on it.)

Yes, autodetection takes a while. I wish we could do it faster, but it
can't really be helped.

> Is this about the right way to do it?  I'm pretty sure (not 100%) that I
> have to set up the NMEA messages I want with the TSIP command before
> switching, because I don't think there's a way to ask for which NMEA
> sentences you want once you're in NMEA mode.

I haven't found any Trimble NMEA commands to go back. Some receivers
don't save settings in NVRAM/EEPROM, so it may be safe to do the
protocol switch, if you can recover with power cycle. Itrax receivers
are like that - you can switch to ITALK mode, but then you need to
restart to get back to NMEA.

>  Also, I summarily go to
> 4800 8N1 when switching to NMEA, and 9600 8O1 when going back to TSIP;
> maybe I should just leave the current settings alone?

9600 8O1 seems to be the standard for tsip - though some devices are
8N1. While I'm not always a fan of hard-coded settings NMEA@4800-8-N-1
and TSIP@9600-8-O-1 are two very common configurations. It's probably
ok to just support those.

CK

> Any other comments?
>
> Thanks!
>
> Matt Roberds
>
> ----cut here----
> --- driver_tsip.c.orig  2009-06-04 21:31:19.000000000 -0500
> +++ driver_tsip.c.withmodeswitch        2009-06-04 21:36:37.000000000 -0500
> @@ -830,6 +830,51 @@
>
>     return true;       /* it would be nice to error-check this */
>  }
> +
> +static void tsip_mode(struct gps_device_t *session, int mode)
> +{
> +    unsigned char buf[16];
> +
> +    if (mode == MODE_NMEA) {
> +        /* First turn on the NMEA messages we want */
> +
> +        putbyte(buf,0,0x00);           /* subcode 0 */
> +        putbyte(buf,1,0x01);            /* 1-second fix interval */
> +        putbyte(buf,2,0x00);           /* Reserved */
> +        putbyte(buf,3,0x00);           /* Reserved */
> +        putbyte(buf,4,0x01);           /* 0=RMC, 1-7=Reserved */
> +        putbyte(buf,5,0x19);           /* 0=GGA, 1=GGL, 2=VTG, 3=GSV, */
> +                                        /* 4=GSA, 5=ZDA, 6-7=Reserved  */
> +
> +        (void)tsip_write(session, 0x7A, buf, 6);
> +
> +        /* Now switch to NMEA mode */
> +
> +        memset(buf, 0, sizeof(buf));
> +
> +        putbyte(buf,0,0xff);           /* current port */
> +        putbyte(buf,1,0x06);            /* 4800 bps input */
> +        putbyte(buf,2,0x06);           /* 4800 bps output */
> +        putbyte(buf,3,0x03);           /* 8 data bits */
> +        putbyte(buf,4,0x00);           /* No parity */
> +        putbyte(buf,5,0x00);           /* 1 stop bit */
> +        putbyte(buf,6,0x00);           /* No flow control */
> +        putbyte(buf,7,0x02);           /* Input protocol TSIP */
> +        putbyte(buf,8,0x04);           /* Output protocol NMEA */
> +        putbyte(buf,9,0x00);           /* Reserved */
> +
> +        (void)tsip_write(session, 0xBC, buf, 10);
> +
> +    } else if (mode == MODE_BINARY) {
> +        /* The speed switcher also puts us back in TSIP, so call it */
> +        /* with the default 9600 8O1. */
> +
> +        tsip_speed_switch(session, 9600, 'O', 1);
> +
> +    } else {
> +        gpsd_report(LOG_ERROR, "unknown mode %i requested\n", mode);
> +    }
> +}
>  #endif /* ALLOW_RECONFIGURE */
>
>  /* this is everything we export */
> @@ -851,7 +896,7 @@
>  #ifdef ALLOW_RECONFIGURE
>     .configurator   = tsip_configurator,/* initial mode sets */
>     .speed_switcher = tsip_speed_switch,/* change baud rate */
> -    .mode_switcher  = NULL,            /* no mode switcher */
> +    .mode_switcher  = tsip_mode,       /* there is a mode switcher */
>     .rate_switcher  = NULL,            /* no rate switcher */
>     .min_cycle      = 1,               /* not relevant, no rate switcher */
>     .revert         = NULL,            /* FIXME: revert sentence mix */
> ----cut here----
>
> _______________________________________________
> Gpsd-users mailing list
> Gpsd-users@...
> https://lists.berlios.de/mailman/listinfo/gpsd-users
>



--
GDB has a 'break' feature; why doesn't it have 'fix' too?
_______________________________________________
Gpsd-users mailing list
Gpsd-users@...
https://lists.berlios.de/mailman/listinfo/gpsd-users

Re: TSIP mode switch for gpsctl

by Eric Raymond-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

mattroberds@... <mattroberds@...>:

> With my earlier patches, I have basically got what I wanted: a way to flip
> a Trimble TSIP GPS into NMEA mode from the command line.  But since gpsctl
> has built-in -n/-b flags for some other protocols, I figured I'd take a
> stab at implementing this for TSIP; the patch is below.  Note that this
> hasn't been through the regression tests or splint yet.  It does work, at
> least for my Resolution T dev kit.  (In general, gpsctl seems to take a
> while to recognize that the GPS is speaking TSIP, but it was doing that
> before I started hacking on it.)
>
> Is this about the right way to do it?  I'm pretty sure (not 100%) that I
> have to set up the NMEA messages I want with the TSIP command before
> switching, because I don't think there's a way to ask for which NMEA
> sentences you want once you're in NMEA mode.  Also, I summarily go to
> 4800 8N1 when switching to NMEA, and 9600 8O1 when going back to TSIP;
> maybe I should just leave the current settings alone?
>
> Any other comments?

I've merged this patch with a FIXME note. It would indeed be better if
this method didn't modify speed or mode settings.
--
                <a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
_______________________________________________
Gpsd-users mailing list
Gpsd-users@...
https://lists.berlios.de/mailman/listinfo/gpsd-users