summaryrefslogtreecommitdiff
path: root/truenorth.c
blob: 167920d4b7a0742ca1739fa91ae35ea2d4d2a803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* $Id$ */
/**
 * 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.
 * This is useful to supplement the heading provided by another GPS
 * unit. A GPS heading is unreliable at slow speed or no speed.
 */
#include "gpsd.h"

#ifdef TNT_ENABLE
/*
 * The True North compass won't start talking unless you ask it to. To
 * wake it up, we query for its ID string just after each speed change
 * in the autobaud hunt.  The initializer will send it codes to start 
 * the flow of data.
 */
static void tnt_wakeup(struct gps_device_t *session)
{
    (void)nmea_send(session->gpsdata.gps_fd, "@X?");
}

static void tnt_initializer(struct gps_device_t *session)
{
    //nmea_send(session->gpsdata.gps_fd, "@BA?"); // Query current rate
    //nmea_send(session->gpsdata.gps_fd, "@BA=8"); // Start HTM packet at 1Hz
    /*
     * Sending this twice seems to make it more reliable!!
     * I think it gets the input on the unit synced up.
     * The intent is to start HTM packet reporting at 1200 per minute.
     */
    (void)nmea_send(session->gpsdata.gps_fd, "@BA=15");
    (void)nmea_send(session->gpsdata.gps_fd, "@BA=15");
}

struct gps_type_t trueNorth = {
    .typename       = "True North",	/* full name of type */
    .trigger        = " TNT1500",	/* how to recognize this */
    .channels       = 0,		/* not an actual GPS at all */
    .wakeup         = tnt_wakeup,	/* wakeup by sending ID query */
    .probe          = NULL,		/* no probe */
    .initializer    = tnt_initializer,	/* no initializer */
    .get_packet     = packet_get,	/* how to get a packet */
    .parse_packet   = nmea_parse_input,	/* how to interpret a packet */
    .rtcm_writer    = NULL,	        /* Don't send */
    .speed_switcher = NULL,		/* no speed switcher */
    .mode_switcher  = NULL,		/* no mode switcher */
    .rate_switcher  = NULL,		/* no wrapup */
    .cycle_chars    = -1,		/* not relevant, no rate switch */
    .wrapup         = NULL,		/* no wrapup */
    .cycle          = 20,		/* updates per second */
};
#endif