From 3881c652c1cab0d206e753fe0089c79ed11ad62d Mon Sep 17 00:00:00 2001 From: pip Date: Tue, 22 Feb 2011 12:15:25 +0000 Subject: [PATCH] Simplified the binary code a little, added a 300ms delay after sending a FULL COLD RESTART to the GPS (IF we do that is), fixed some spelling mistakes. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2843 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/Modules/GPS/GPS.c | 12 +++++++++--- flight/Modules/GPS/GTOP_BIN.c | 21 +++++++-------------- flight/Modules/GPS/inc/gps_mode.h | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 39ee1e532..353debebe 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -139,6 +139,12 @@ static void gpsTask(void *parameters) #ifdef FULL_COLD_RESTART // tell the GPS to do a FULL COLD restart PIOS_COM_SendStringNonBlocking(gpsPort, "$PMTK104*37\r\n"); + timeOfLastCommandMs = timeNowMs; + while (timeNowMs - timeOfLastCommandMs < 300) // delay for 300ms to let the GPS sort itself out + { + vTaskDelay(xDelay); // Block task until next update + timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS;; + } #endif #ifdef DISABLE_GPS_TRESHOLD @@ -151,7 +157,7 @@ static void gpsTask(void *parameters) #endif #ifdef ENABLE_GPS_ONESENTENCE_GTOP - // switch to single sentance mode + // switch to single sentence mode PIOS_COM_SendStringNonBlocking(gpsPort, "$PGCMD,21,2*6C\r\n"); #endif @@ -187,7 +193,7 @@ static void gpsTask(void *parameters) } #else - // NMEA or SINGLE-SENTANCE GPS mode + // NMEA or SINGLE-SENTENCE GPS mode // This blocks the task until there is something on the buffer while (PIOS_COM_ReceiveBufferUsed(gpsPort) > 0) @@ -281,7 +287,7 @@ static void gpsTask(void *parameters) #endif #ifdef ENABLE_GPS_ONESENTENCE_GTOP - // switch to single sentance mode + // switch to single sentence mode PIOS_COM_SendStringNonBlocking(gpsPort,"$PGCMD,21,2*6C\r\n"); #endif diff --git a/flight/Modules/GPS/GTOP_BIN.c b/flight/Modules/GPS/GTOP_BIN.c index ba48fcceb..cd24b98a0 100644 --- a/flight/Modules/GPS/GTOP_BIN.c +++ b/flight/Modules/GPS/GTOP_BIN.c @@ -152,8 +152,12 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati if (rx_packet->header != 0x2404 || rx_packet->end_word != 0x0A0D || - rx_packet->asterisk != 0x2A) - { // no valid packet found - yet + rx_packet->asterisk != 0x2A || + (rx_packet->data.ns_indicator != 1 && rx_packet->data.ns_indicator != 2) || + (rx_packet->data.ew_indicator != 1 && rx_packet->data.ew_indicator != 2) || + (rx_packet->data.fix_quality > 2) || + (rx_packet->data.fix_type < 1 || rx_packet->data.fix_type > 3) ) + { // invalid packet if (parsing_errors) *parsing_errors++; memmove(gps_rx_buffer, gps_rx_buffer + 1, gps_rx_buffer_wr - 1); gps_rx_buffer_wr--; @@ -176,18 +180,7 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati } // checksum appears correct - - if ( (rx_packet->data.ns_indicator != 1 && rx_packet->data.ns_indicator != 2) || - (rx_packet->data.ew_indicator != 1 && rx_packet->data.ew_indicator != 2) || - (rx_packet->data.fix_quality > 2) || - (rx_packet->data.fix_type < 1 || rx_packet->data.fix_type > 3) ) - { // found some invalid params - discard the packet - if (parsing_errors) *parsing_errors++; - memmove(gps_rx_buffer, gps_rx_buffer + 1, gps_rx_buffer_wr - 1); - gps_rx_buffer_wr--; - continue; - } - + // // we now have a valid complete binary packet, update the GpsData and GpsTime objects // correct the endian order of the parameters diff --git a/flight/Modules/GPS/inc/gps_mode.h b/flight/Modules/GPS/inc/gps_mode.h index 445bbc276..43e5b0398 100644 --- a/flight/Modules/GPS/inc/gps_mode.h +++ b/flight/Modules/GPS/inc/gps_mode.h @@ -38,7 +38,7 @@ // you MUST have one of these uncommented - and ONLY one //#define ENABLE_GPS_BINARY_GTOP // uncomment this if we are using GTOP BINARY mode -//#define ENABLE_GPS_ONESENTENCE_GTOP // uncomment this if we are using GTOP SINLGE SENTENCE mode +//#define ENABLE_GPS_ONESENTENCE_GTOP // uncomment this if we are using GTOP SINGLE SENTENCE mode #define ENABLE_GPS_NMEA // uncomment this if we are using NMEA mode // ****************