From 2deca0c52cd6cfb4baceb59c8a5458344bada338 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 17 Jul 2009 17:09:20 -0700 Subject: [PATCH] Try harder to get the GPS receiver serial link sync'd up. We cannot assume that the GPS receiver is in any particular state when it boots, so we try to send the serial configuration at several rates and hope that it eventually sees something that it likes. Signed-off-by: Keith Packard --- src/ao_gps.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/ao_gps.c b/src/ao_gps.c index 562899cd..4d278832 100644 --- a/src/ao_gps.c +++ b/src/ao_gps.c @@ -22,16 +22,14 @@ __xdata uint8_t ao_gps_mutex; __xdata struct ao_gps_data ao_gps_data; -const char ao_gps_set_binary[] = { +static const char ao_gps_set_nmea[] = { + '$', 'P', 'S', 'R', 'F', '1', '0', '0', ',', '0', ',', '9', '6', '0', '0', ',', '8', ',', '1', ',', '0', '*', '0', 'C', '\r','\n', +}; - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - +static const char ao_gps_set_sirf[] = { 0xa0, 0xa2, 0x00, 0x09, /* length 9 bytes */ 134, /* Set binary serial port */ 0, 0, 0x25, 0x80, /* 9600 baud */ @@ -57,6 +55,14 @@ const char ao_gps_config[] = { 0, /* Track smoothing (disabled) */ 0x00, 0x8e, 0xb0, 0xb3, + 0xa0, 0xa2, 0x00, 0x08, /* length: 8 bytes */ + 166, /* Set message rate */ + 2, /* enable/disable all messages */ + 0, /* message id (ignored) */ + 0, /* update rate (0 = disable) */ + 0, 0, 0, 0, /* reserved */ + 0x00, 0xa8, 0xb0, 0xb3, + 0xa0, 0xa2, 0x00, 0x02, /* length: 2 bytes */ 143, /* static navigation */ 0, /* disable */ @@ -237,16 +243,21 @@ ao_sirf_parse_41(void) void ao_gps_setup(void) __reentrant { - uint8_t i, j; + uint8_t i, j, k; for (j = 0; j < 2; j++) { #ifdef AO_GPS_TEST ao_serial_set_speed(j); #endif - for (i = 255; i != 0; i--) - ao_serial_putchar(0); - - for (i = 0; i < sizeof (ao_gps_set_binary); i++) - ao_serial_putchar(ao_gps_set_binary[i]); + for (i = 0; i < 128; i++) + ao_serial_putchar(0x55); + for (k = 0; k < 4; k++) + for (i = 0; i < sizeof (ao_gps_set_nmea); i++) + ao_serial_putchar(ao_gps_set_nmea[i]); + for (i = 0; i < 128; i++) + ao_serial_putchar(0x55); + for (k = 0; k < 4; k++) + for (i = 0; i < sizeof (ao_gps_set_sirf); i++) + ao_serial_putchar(ao_gps_set_sirf[i]); } } @@ -286,7 +297,6 @@ static const uint8_t sirf_disable[] = { 27, 50, 52, - 4, }; void -- 2.30.2