drivers.c

来自「gpsd, a popular GPS daemon.」· C语言 代码 · 共 927 行 · 第 1/3 页

C
927
字号
    }}#endif /* ALLOW_RECONFIGURE */static struct gps_type_t garmin = {    .type_name      = "Garmin Serial",	/* full name of type */    .trigger	    = "$PGRMC,",	/* Garmin private */    .channels       = 12,		/* not used by this driver */    .probe_wakeup   = NULL,		/* no wakeup to be done before hunt */    .probe_detect   = NULL,		/* no probe */    .probe_subtype  = NULL,		/* no further querying */#ifdef ALLOW_RECONFIGURE    .configurator   = garmin_nmea_configurator,/* enable what we need */#endif /*ALLOW_RECONFIGURE */    .get_packet     = generic_get,	/* use generic packet getter */    .parse_packet   = nmea_parse_input,	/* how to interpret a packet */    .rtcm_writer    = NULL,		/* some do, some don't, skip for now */    .speed_switcher = NULL,		/* no speed switcher */    .mode_switcher  = NULL,		/* no mode switcher */    .rate_switcher  = NULL,		/* no sample-rate switcher */    .cycle_chars    = -1,		/* not relevant, no rate switch */#ifdef ALLOW_RECONFIGURE    .revert	    = NULL,		/* no setting-reversion method */#endif /*ALLOW_RECONFIGURE */    .wrapup	    = NULL,		/* no wrapup */    .cycle	    = 1,		/* updates every second */};#endif /* GARMIN_ENABLE && NMEA_ENABLE */#ifdef ASHTECH_ENABLE/************************************************************************** * * Ashtech (then Thales, now Magellan Professional) Receivers * **************************************************************************/#ifdef ALLOW_RECONFIGUREstatic void ashtech_configure(struct gps_device_t *session, unsigned int seq){    if (seq == 0){	/* turn WAAS on. can't hurt... */	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,WAS,ON");	/* reset to known output state */	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,ALL,A,OFF");	/* then turn on some useful sentences */#ifdef ASHTECH_NOTYET	/* we could parse these, but they're oversize so they get dropped */	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,POS,A,ON");	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,SAT,A,ON");#else	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,GGA,A,ON");	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,GSA,A,ON");	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,GSV,A,ON");	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,RMC,A,ON");#endif	(void)nmea_send(session->gpsdata.gps_fd, "$PASHS,NME,ZDA,A,ON");    }}#endif /* ALLOW_RECONFIGURE */static void ashtech_ping(struct gps_device_t *session){	(void)nmea_send(session->gpsdata.gps_fd, "$PASHQ,RID");}static struct gps_type_t ashtech = {    .type_name      = "Ashtech",	/* full name of type */    .trigger	    = "$PASHR,RID,",	/* Ashtech receivers respond thus */    .channels       = 24,		/* not used, GG24 has 24 channels */    .probe_wakeup   = ashtech_ping,	/* no wakeup to be done before hunt */    .probe_detect   = NULL,		/* no probe */    .probe_subtype  = NULL,		/* to be sent unconditionally */#ifdef ALLOW_RECONFIGURE    .configurator   = ashtech_configure, /* change its sentence set */#endif /* ALLOW_RECONFIGURE */    .get_packet     = generic_get,	/* how to get a packet */    .parse_packet   = nmea_parse_input,	/* how to interpret a packet */    .rtcm_writer    = pass_rtcm,	/* write RTCM data straight */    .speed_switcher = NULL,		/* no speed switcher */    .mode_switcher  = NULL,		/* no mode switcher */    .rate_switcher  = NULL,		/* no sample-rate switcher */    .cycle_chars    = -1,		/* not relevant, no rate switch */#ifdef ALLOW_RECONFIGURE    .revert	    = NULL,		/* no setting-reversion method */#endif /* ALLOW_RECONFIGURE */    .wrapup	    = NULL,		/* no wrapup */    .cycle	    = 1,		/* updates every second */};#endif /* ASHTECH_ENABLE */#ifdef FV18_ENABLE/************************************************************************** * * FV18 -- uses 2 stop bits, needs to be told to send GSAs * **************************************************************************/#ifdef ALLOW_RECONFIGUREstatic void fv18_configure(struct gps_device_t *session, unsigned int seq){    /*     * Tell an FV18 to send GSAs so we'll know if 3D is accurate.     * Suppress GLL and VTG.  Enable ZDA so dates will be accurate for replay.     */    if (seq == 0)	(void)nmea_send(session->gpsdata.gps_fd,		    "$PFEC,GPint,GSA01,DTM00,ZDA01,RMC01,GLL00,VTG00,GSV05");}#endif /* ALLOW_RECONFIGURE */static struct gps_type_t fv18 = {    .type_name      = "San Jose Navigation FV18",	/* full name of type */    .trigger	    = "$PFEC,GPint,",	/* FV18s should echo the probe */    .channels       = 12,		/* not used by this driver */    .probe_wakeup   = NULL,		/* no wakeup to be done before hunt */    .probe_detect   = NULL,		/* no probe */    .probe_subtype  = NULL,		/* to be sent unconditionally */#ifdef ALLOW_RECONFIGURE    .configurator   = fv18_configure,	/* change its sentence set */#endif /* ALLOW_RECONFIGURE */    .get_packet     = generic_get,	/* how to get a packet */    .parse_packet   = nmea_parse_input,	/* how to interpret a packet */    .rtcm_writer    = pass_rtcm,	/* write RTCM data straight */    .speed_switcher = NULL,		/* no speed switcher */    .mode_switcher  = NULL,		/* no mode switcher */    .rate_switcher  = NULL,		/* no sample-rate switcher */    .cycle_chars    = -1,		/* not relevant, no rate switch */#ifdef ALLOW_RECONFIGURE    .revert	    = NULL,		/* no setting-reversion method */#endif /* ALLOW_RECONFIGURE */    .wrapup	    = NULL,		/* no wrapup */    .cycle	    = 1,		/* updates every second */};#endif /* FV18_ENABLE */#ifdef GPSCLOCK_ENABLE/************************************************************************** * * Furuno Electric GPSClock (GH-79L4) * **************************************************************************//* * Based on http://www.tecsys.de/fileadmin/user_upload/pdf/gh79_1an_intant.pdf */static void gpsclock_probe_subtype(struct gps_device_t *session, unsigned int seq){    /*     * Michael St. Laurent <mikes@hartwellcorp.com> reports that you have to     * ignore the trailing PPS edge when extracting time from this chip.     */    if (seq == 0) {	gpsd_report(LOG_INF, "PPS trailing edge will be ignored");	session->driver.nmea.ignore_trailing_edge = true;    }}static struct gps_type_t gpsclock = {    .type_name      = "Furuno Electric GH-79L4",	/* full name of type */    .trigger	    = "$PFEC,GPssd",	/* GPSclock should echo the probe */    .channels       = 12,		/* not used by this driver */    .probe_wakeup   = NULL,		/* no wakeup to be done before hunt */    .probe_detect   = NULL,		/* no probe */    .probe_subtype  = gpsclock_probe_subtype, /* to be sent unconditionally */#ifdef ALLOW_RECONFIGURE    .configurator   = NULL,		/* change its sentence set */#endif /* ALLOW_RECONFIGURE */    .get_packet     = generic_get,	/* how to get a packet */    .parse_packet   = nmea_parse_input,	/* how to interpret a packet */    .rtcm_writer    = pass_rtcm,	/* write RTCM data straight */    .speed_switcher = NULL,		/* no speed switcher */    .mode_switcher  = NULL,		/* no mode switcher */    .rate_switcher  = NULL,		/* sample rate is fixed */    .cycle_chars    = -1,		/* sample rate is fixed */#ifdef ALLOW_RECONFIGURE    .revert	    = NULL,		/* no setting-reversion method */#endif /* ALLOW_RECONFIGURE */    .wrapup	    = NULL,		/* no wrapup */    .cycle	    = 1,		/* updates every second */};#endif /* GPSCLOCK_ENABLE */#ifdef TRIPMATE_ENABLE/************************************************************************** * * TripMate -- extended NMEA, gets faster fix when primed with lat/long/time * **************************************************************************//* * Some technical FAQs on the TripMate: * http://vancouver-webpages.com/pub/peter/tripmate.faq * http://www.asahi-net.or.jp/~KN6Y-GTU/tripmate/trmfaqe.html * The TripMate was discontinued sometime before November 1998 * and was replaced by the Zodiac EarthMate. */static void tripmate_probe_subtype(struct gps_device_t *session, unsigned int seq){    /* TripMate requires this response to the ASTRAL it sends at boot time */    if (seq == 0)	(void)nmea_send(session->gpsdata.gps_fd, "$IIGPQ,ASTRAL");}#ifdef ALLOW_RECONFIGUREstatic void tripmate_configurator(struct gps_device_t *session, unsigned int seq){    /* stop it sending PRWIZCH */    if (seq == 0)	(void)nmea_send(session->gpsdata.gps_fd, "$PRWIILOG,ZCH,V,,");}#endif /* ALLOW_RECONFIGURE */static struct gps_type_t tripmate = {    .type_name     = "Delorme TripMate",	/* full name of type */    .trigger       ="ASTRAL",			/* tells us to switch */    .channels      = 12,			/* consumer-grade GPS */    .probe_wakeup  = NULL,			/* no wakeup before hunt */    .probe_detect  = NULL,			/* no probe */    .probe_subtype = tripmate_probe_subtype,	/* send unconditionally */#ifdef ALLOW_RECONFIGURE    .configurator  = tripmate_configurator,	/* send unconditionally */#endif /* ALLOW_RECONFIGURE */    .get_packet    = generic_get,		/* how to get a packet */    .parse_packet  = nmea_parse_input,		/* how to interpret a packet */    .rtcm_writer   = pass_rtcm,			/* send RTCM data straight */    .speed_switcher= NULL,			/* no speed switcher */    .mode_switcher = NULL,			/* no mode switcher */    .rate_switcher = NULL,			/* no sample-rate switcher */    .cycle_chars   = -1,			/* no rate switch */#ifdef ALLOW_RECONFIGURE    .revert	   = NULL,			/* no setting-reversion method */#endif /* ALLOW_RECONFIGURE */    .wrapup	   = NULL,			/* no wrapup */    .cycle	   = 1,				/* updates every second */};#endif /* TRIPMATE_ENABLE */#ifdef EARTHMATE_ENABLE/************************************************************************** * * Zodiac EarthMate textual mode * * Note: This is the pre-2003 version using Zodiac binary protocol. * It has been replaced with a design that uses a SiRF chipset. * **************************************************************************/static struct gps_type_t earthmate;/* * There is a good HOWTO at <http://www.hamhud.net/ka9mva/earthmate.htm>. */static void earthmate_close(struct gps_device_t *session){    /*@i@*/session->device_type = &earthmate;}static void earthmate_probe_subtype(struct gps_device_t *session, unsigned int seq){    if (seq == 0) {	(void)gpsd_write(session, "EARTHA\r\n", 8);	(void)usleep(10000);	/*@i@*/session->device_type = &zodiac_binary;	zodiac_binary.wrapup = earthmate_close;	if (zodiac_binary.probe_subtype) zodiac_binary.probe_subtype(session, seq);    }}/*@ -redef @*/static struct gps_type_t earthmate = {    .type_name     = "Delorme EarthMate (pre-2003, Zodiac chipset)",    .trigger       = "EARTHA",			/* Earthmate trigger string */    .channels      = 12,			/* not used by NMEA parser */    .probe_wakeup  = NULL,			/* no wakeup to be done before hunt */    .probe_detect  = NULL,			/* no probe */    .probe_subtype = earthmate_probe_subtype,	/* switch us to Zodiac mode */#ifdef ALLOW_RECONFIGURE    .configurator  = NULL,			/* no configuration here */#endif /* ALLOW_RECONFIGURE */    .get_packet    = generic_get,		/* how to get a packet */    .parse_packet  = nmea_parse_input,		/* how to interpret a packet */    .rtcm_writer   = NULL,			/* don't send RTCM data */    .speed_switcher= NULL,			/* no speed switcher */    .mode_switcher = NULL,			/* no mode switcher */    .rate_switcher = NULL,			/* no sample-rate switcher */    .cycle_chars   = -1,			/* no rate switch */#ifdef ALLOW_RECONFIGURE    .revert	   = NULL,			/* no setting-reversion method */#endif /* ALLOW_RECONFIGURE */    .wrapup	   = NULL,			/* no wrapup code */    .cycle	   = 1,				/* updates every second */};/*@ -redef @*/#endif /* EARTHMATE_ENABLE */#endif /* NMEA_ENABLE */#ifdef TNT_ENABLE/************************************************************************** * True North Technologies - Revolution 2X Digital compass * * More info: http://www.tntc.com/ * * This is a digital compass which uses magnetometers to measure the * strength of the earth's magnetic field. Based on these measurements * it provides a compass heading using NMEA formatted output strings.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?