summaryrefslogtreecommitdiff
path: root/tsip.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-07-17 19:36:33 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-07-17 19:36:33 +0000
commit862acd40de895ede921570c35a5b52616e3f728f (patch)
tree6cf648c41d627b79ecab4add6a5251f052ddaba9 /tsip.c
parent39f91572201da61c849d0f53042787a7fdec96a0 (diff)
downloadgpsd-862acd40de895ede921570c35a5b52616e3f728f.tar.gz
TSIP patch to add wrapup hook that restores old serial-line parameters.
Diffstat (limited to 'tsip.c')
-rw-r--r--tsip.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/tsip.c b/tsip.c
index 906b82f4..f4325c22 100644
--- a/tsip.c
+++ b/tsip.c
@@ -55,7 +55,9 @@ static void tsip_initializer(struct gps_device_t *session)
{
unsigned char buf[100];
- /* TSIP is ODD parity 1 stopbit, change it */
+ /* TSIP is ODD parity 1 stopbit, save original values and change it */
+ session->tsip.parity = session->gpsdata.parity;
+ session->tsip.stopbits = session->gpsdata.stopbits;
gpsd_set_speed(session, session->gpsdata.baudrate, 'O', 1);
/* I/O Options */
@@ -77,6 +79,17 @@ static void tsip_initializer(struct gps_device_t *session)
/* Request Current Datum Values */
putbyte(buf,0,0x15);
(void)tsip_write(session->gpsdata.gps_fd, 0x8e, buf, 1);
+
+ /* Request Navigation Configuration */
+ putbyte(buf,0,0x03);
+ (void)tsip_write(session->gpsdata.gps_fd, 0xbb, buf, 1);
+}
+
+static void tsip_wrapup(struct gps_device_t *session)
+{
+ /* restore saved parity and stopbits when leaving TSIP mode */
+ gpsd_set_speed(session, session->gpsdata.baudrate,
+ session->tsip.parity, session->tsip.stopbits);
}
static bool tsip_speed_switch(struct gps_device_t *session, unsigned int speed)
@@ -103,7 +116,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
int i, j, len, count;
gps_mask_t mask = 0;
unsigned int id;
- u_int8_t u1,u2,u3,u4;
+ u_int8_t u1,u2,u3,u4,u5;
int16_t s1,s2,s3,s4;
int32_t sl1,sl2,sl3;
u_int32_t ul1,ul2;
@@ -599,6 +612,20 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
gpsd_report(4,"Unhandled TSIP superpacket type 0x%02x\n",u1);
}
break;
+ case 0xbb: /* Navigation Configuration */
+ if (len != 40)
+ break;
+ u1 = getub(buf,0); /* Subcode */
+ u2 = getub(buf,1); /* Operating Dimension */
+ u3 = getub(buf,2); /* DGPS Mode */
+ u4 = getub(buf,3); /* Dynamics Code */
+ f1 = getf(buf,5); /* Elevation Mask */
+ f2 = getf(buf,9); /* AMU Mask */
+ f3 = getf(buf,13); /* DOP Mask */
+ f4 = getf(buf,17); /* DOP Switch */
+ u5 = getub(buf,21); /* DGPS Age Limit */
+ gpsd_report(4, "Navigation Configuration %u %u %u %u %f %f %f %f %u\n",u1,u2,u3,u4,f1,f2,f3,f4,u5);
+ break;
default:
gpsd_report(4,"Unhandled TSIP packet type 0x%02x\n",id);
break;
@@ -643,7 +670,7 @@ struct gps_type_t tsip_binary =
.mode_switcher = NULL, /* no mode switcher */
.rate_switcher = NULL, /* no rate switcher */
.cycle_chars = -1, /* not relevant, no rate switcher */
- .wrapup = NULL, /* no close hook */
+ .wrapup = tsip_wrapup, /* restore comms parameters */
.cycle = 1, /* updates every second */
};