|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
TSIP patchHere's an updated version of my patch to the TSIP support to get my
SVeeSix working. It does several things: - add a device probe routine that forces 9600O81 (TSIP spec) - SVeeSix appears to ignore packets it considers invalid rather than returning an error, so falling back from compact superpacket to regular superpacket didn't work. This adds a timeout for getting a superpacket response and falls back. - packet.c tests for TSIP packet length, but TSIP packets are not always the same length due to "stuffing" of the DLE (0x10) byte. This subtracts off "stuffed" DLE bytes in the packet for length comparison. - I/O Option Flags were not set the same in a couple of places, and were being set to values that SVeeSix apparently didn't recognize (so it ignored all settings in the request); the values are also not documented in the TSIP documentation I found. I made them the same and it works for me. - Some packets the SVeeSix puts out were not recognized; stub them out to drop the errors. Let me know how this looks. -- Chris Adams <cmadams@...> Systems and Network Administrator - HiWAAY Internet Services I don't speak for anybody but myself - that's enough trouble. diff -ur gpsd-trunk/driver_tsip.c gpsd-cmadams2/driver_tsip.c --- gpsd-trunk/driver_tsip.c 2009-11-07 12:11:50.000000000 -0600 +++ gpsd-cmadams2/driver_tsip.c 2009-11-07 22:21:25.000000000 -0600 @@ -11,6 +11,14 @@ #endif /* S_SPLINT_S */ #include <math.h> #include "gpsd_config.h" + +#if defined (HAVE_SYS_SELECT_H) +#include <sys/select.h> +#endif +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif + #include "gpsd.h" #include "bits.h" @@ -51,6 +59,57 @@ return 0; } +/* tsip_detect() + * + * see if it looks like a TSIP device (speaking 96008O1) is listening and + * return 1 if found, 0 if not + */ +static bool tsip_detect(struct gps_device_t *session) +{ + char buf[BUFSIZ]; + unsigned int n, ret = 0; + int myfd; + fd_set fdset; + struct timeval to; + + gpsd_report(LOG_PROG, "Probing TSIP\n"); + + gpsd_set_speed(session, 9600, 'O', 1); + + /* request firmware revision and look for a valid response */ + putbyte(buf, 0, 0x10); + putbyte(buf, 1, 0x1f); + putbyte(buf, 2, 0x10); + putbyte(buf, 3, 0x03); + myfd = session->gpsdata.gps_fd; + if (write(myfd, buf, 4) == 4) { + for (n = 0; n < 3; n++) { + FD_ZERO(&fdset); + FD_SET(myfd, &fdset); + to.tv_sec = 1; + to.tv_usec = 0; + if (select(myfd + 1, &fdset, NULL, NULL, &to) != 1) + break; + if (generic_get(session) >= 0) { + if(session->packet.type == TSIP_PACKET) { + gpsd_report(LOG_RAW, "tsip_detect found\n"); + ret = 1; + break; + } + } + } + } + + if (ret == 0) + /* return serial port to original settings */ + gpsd_set_speed(session, + session->gpsdata.dev.baudrate, + session->gpsdata.dev.parity, + session->gpsdata.dev.stopbits); + + return ret; +} + static gps_mask_t tsip_analyze(struct gps_device_t *session) { int i, j, len, count; @@ -209,6 +268,8 @@ buf[len] = '\0'; gpsd_report(LOG_PROG, "GPS System Message: %s\n",buf); break; + case 0x49: /* Almanac Health Page */ + break; case 0x4a: /* Single-Precision Position LLA */ if (len != 20) break; @@ -246,12 +307,16 @@ putbyte(buf,0,0x2c); /* Position: SP, MSL */ putbyte(buf,1,0x00); /* Velocity: none (via SP) */ putbyte(buf,2,0x00); /* Time: GPS */ - putbyte(buf,3,0x2c); /* Aux: dBHz, raw, signal, satpos */ + putbyte(buf,3,0x08); /* Aux: dBHz */ (void)tsip_write(session, 0x35, buf, 4); session->driver.tsip.superpkt = true; } #endif /* USE_SUPERPACKET */ break; + case 0x4c: /* Operating Parameters Report */ + break; + case 0x54: /* One Satellite Bias */ + break; case 0x55: /* IO Options */ if (len != 4) break; @@ -271,6 +336,7 @@ putbyte(buf,0,0x23); putbyte(buf,1,0x01); /* enabled */ (void)tsip_write(session, 0x8e, buf, 2); + session->driver.tsip.req_compact = now; } #endif /* USE_SUPERPACKET */ break; @@ -324,6 +390,8 @@ d1 = getbed(buf,17); /* Time of Measurement */ gpsd_report(LOG_PROG, "Raw Measurement Data %d %f %f %f %f\n",getub(buf,0),f1,f2,f3,d1); break; + case 0x5b: /* Satellite Ephemeris Status */ + break; case 0x5c: /* Satellite Tracking Status */ if (len != 24) break; @@ -357,6 +425,8 @@ session->gpsdata.satellites_visible = i; } break; + case 0x5e: /* Additional Fix Status Report */ + break; case 0x6d: /* All-In-View Satellite Selection */ u1 = getub(buf,0); /* nsvs/dimension */ count = (int)((u1 >> 4) & 0x0f); @@ -720,7 +790,7 @@ break; } - mask |= LATLON_SET | ALTITUDE_SET | STATUS_SET | MODE_SET | CLEAR_SET | REPORT_SET; + mask |= LATLON_SET | ALTITUDE_SET | MODE_SET | CLEAR_SET | REPORT_SET; gpsd_report(LOG_DATA, "SP-TPS 0xac " "time=%.2f lat=%.2f lon=%.2f alt=%.2f mask=%s\n", session->gpsdata.fix.time, @@ -788,6 +858,20 @@ session->driver.tsip.last_46 = now; } +#if USE_SUPERPACKET + if ((session->driver.tsip.req_compact > 0) && + ((now - session->driver.tsip.req_compact) > 2)) { + /* Compact Superpacket requested but no response */ + session->driver.tsip.req_compact = 0; + gpsd_report(LOG_WARN, "No Compact Super Packet, use LFwEI\n"); + + /* Request LFwEI Super Packet */ + putbyte(buf,0,0x20); + putbyte(buf,1,0x01); /* enabled */ + (void)tsip_write(session, 0x8e, buf, 2); + } +#endif /* USE_SUPERPACKET */ + return mask; } @@ -836,6 +920,7 @@ } if (event == event_configure) { unsigned char buf[100]; + union int_float i_f; switch (session->packet.counter) { case 0: @@ -856,9 +941,29 @@ (void)tsip_write(session, 0x1f, NULL, 0); /* Request Current Time */ (void)tsip_write(session, 0x21, NULL, 0); + /* Set Operating Parameters */ + /* - dynamic code: land */ + putbyte(buf, 0, 0x01); + /* - elevation mask */ + i_f.f = 5.0 * DEG_2_RAD; + putbelong(buf, 1, i_f.i); + /* - signal level mask */ + i_f.f = 6.0; + putbelong(buf, 5, i_f.i); + /* - PDOP mask */ + i_f.f = 8.0; + putbelong(buf ,9, i_f.i); + /* - PDOP switch */ + i_f.f = 6.0; + putbelong(buf, 13, i_f.i); + (void)tsip_write(session, 0x2c, buf, 17); + /* Set Position Fix Mode (auto 2D/3D) */ + putbyte(buf,0,0x00); + (void)tsip_write(session, 0x22, buf, 1); /* Request GPS Systems Message */ (void)tsip_write(session, 0x28, NULL, 0); /* Request Current Datum Values */ + (void)tsip_write(session, 0x37, NULL, 0); putbyte(buf,0,0x15); (void)tsip_write(session, 0x8e, buf, 1); /* Request Navigation Configuration */ @@ -966,7 +1071,7 @@ .packet_type = TSIP_PACKET, /* associated lexer packet type */ .trigger = NULL, /* no trigger */ .channels = TSIP_CHANNELS, /* consumer-grade GPS */ - .probe_detect = NULL, /* no probe */ + .probe_detect = tsip_detect, /* probe for 9600O81 device */ .get_packet = generic_get, /* use the generic packet getter */ .parse_packet = tsip_parse_input, /* parse message packets */ .rtcm_writer = NULL, /* doesn't accept DGPS corrections */ diff -ur gpsd-trunk/packet.c gpsd-cmadams2/packet.c --- gpsd-trunk/packet.c 2009-11-07 12:11:50.000000000 -0600 +++ gpsd-cmadams2/packet.c 2009-11-07 14:33:51.000000000 -0600 @@ -1136,7 +1136,21 @@ #endif /* ONCORE_ENABLE */ #if defined(TSIP_ENABLE) || defined(GARMIN_ENABLE) else if (lexer->state == TSIP_RECOGNIZED) { + unsigned int pos, dlecnt; size_t packetlen = lexer->inbufptr - lexer->inbuffer; +#ifdef TSIP_ENABLE + /* don't count stuffed DLEs in the length */ + dlecnt = 0; + for (pos = 0; pos < packetlen; pos ++) + if (lexer->inbuffer[pos] == DLE) + dlecnt ++; + if (dlecnt > 2) { + dlecnt -= 2; + dlecnt /= 2; + gpsd_report(LOG_RAW, "Unstuffed %d DLEs\n", dlecnt); + packetlen -= dlecnt; + } +#endif /* TSIP_ENABLE */ if ( packetlen < 5) { lexer->state = GROUND_STATE; } else { @@ -1204,11 +1218,17 @@ * 0x45, Software Version Information, data length 10 * 0x46, Health of Receiver, data length 2 * 0x48, GPS System Messages + * 0x49, Almanac Health Page * 0x4a, LLA Position, data length 20 * 0x4b, Machine Code Status, data length 3 + * 0x4c, Operating Parameters Report + * 0x54, One Satellite Bias * 0x56, Velocity Fix (ENU), data length 20 + * 0x57, Last Computed Fix Report * 0x5a, Raw Measurements + * 0x5b, Satellite Ephemeris Status * 0x5c, Satellite Tracking Status, data length 24 + * 0x5e, Additional Fix Status Report * 0x6d, All-In-View Satellite Selection, data length 16+numSV * 0x82, Differential Position Fix Mode, data length 1 * 0x83, Double Precision XYZ, data length 36 @@ -1230,7 +1250,7 @@ /* pass */; else if ((0x41 == pkt_id) && ((0x0e == packetlen) || (0x0f == packetlen))) /* pass */; - else if ((0x42 == pkt_id) && (0x14 == packetlen )) + else if ((0x42 == pkt_id) && (0x14 == packetlen)) /* pass */; else if ((0x43 == pkt_id) && (0x18 == packetlen)) /* pass */; @@ -1240,18 +1260,30 @@ /* pass */; else if ((0x48 == pkt_id) && (0x1a == packetlen)) /* pass */; + else if ((0x49 == pkt_id) && (0x24 == packetlen)) + /* pass */; else if ((0x4a == pkt_id) && (0x18 == packetlen)) /* pass */; else if ((0x4b == pkt_id) && (0x07 == packetlen)) /* pass */; + else if ((0x4c == pkt_id) && (0x15 == packetlen)) + /* pass */; + else if ((0x54 == pkt_id) && (0x10 == packetlen)) + /* pass */; else if ((0x55 == pkt_id) && (0x08 == packetlen)) /* pass */; else if ((0x56 == pkt_id) && (0x18 == packetlen)) /* pass */; + else if ((0x57 == pkt_id) && (0x0c == packetlen)) + /* pass */; else if ((0x5a == pkt_id) && ((0x1d <= packetlen) && (0x1f >= packetlen))) /* pass */; + else if ((0x5b == pkt_id) && (0x24 == packetlen)) + /* pass */; else if ((0x5c == pkt_id) && ((0x1c <= packetlen) && (0x1e >= packetlen))) /* pass */; + else if ((0x5e == pkt_id) && (0x06 == packetlen)) + /* pass */; else if ((0x5f == pkt_id) && (70 == packetlen)) /* pass */; else if ((0x6d == pkt_id) && ((0x14 <= packetlen) && (0x20 >= packetlen))) _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: TSIP patchOnce upon a time, Chris Adams <cmadams@...> said:
> Here's an updated version of my patch to the TSIP support to get my > SVeeSix working. It does several things: Is there anything else I need to do with this? It'd be nice to see this upstream. -- Chris Adams <cmadams@...> Systems and Network Administrator - HiWAAY Internet Services I don't speak for anybody but myself - that's enough trouble. _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: TSIP patchChris Adams <cmadams@...>:
> Once upon a time, Chris Adams <cmadams@...> said: > > Here's an updated version of my patch to the TSIP support to get my > > SVeeSix working. It does several things: > > Is there anything else I need to do with this? It'd be nice to see this > upstream. I understand, but I'm not our TSIP driver expert. ckuethe, would you please review this patch and merge as appropriate? -- <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 |
| Free embeddable forum powered by Nabble | Forum Help |