123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- #pragma once
- #include "AP_GPS.h"
- #include "GPS_Backend.h"
- class AP_GPS_NMEA : public AP_GPS_Backend
- {
- friend class AP_GPS_NMEA_Test;
- public:
- using AP_GPS_Backend::AP_GPS_Backend;
-
-
-
- bool read() override;
- static bool _detect(struct NMEA_detect_state &state, uint8_t data);
- const char *name() const override { return "NMEA"; }
- private:
-
- enum _sentence_types {
- _GPS_SENTENCE_RMC = 32,
- _GPS_SENTENCE_GGA = 64,
- _GPS_SENTENCE_VTG = 96,
- _GPS_SENTENCE_HDT = 128,
- _GPS_SENTENCE_OTHER = 0
- };
-
-
-
-
-
-
- bool _decode(char c);
-
-
-
-
-
-
- static int32_t _parse_decimal_100(const char *p);
-
-
-
-
-
-
-
-
- uint32_t _parse_degrees();
-
-
-
-
-
-
-
-
- bool _term_complete();
-
- bool _have_new_message(void);
- uint8_t _parity;
- bool _is_checksum_term;
- char _term[15];
- uint8_t _sentence_type;
- uint8_t _term_number;
- uint8_t _term_offset;
- uint16_t _sentence_length;
- bool _gps_data_good;
-
-
-
- int32_t _new_time;
- int32_t _new_date;
- int32_t _new_latitude;
- int32_t _new_longitude;
- int32_t _new_altitude;
- int32_t _new_speed;
- int32_t _new_course;
- float _new_gps_yaw;
- uint16_t _new_hdop;
- uint8_t _new_satellite_count;
- uint8_t _new_quality_indicator;
- uint32_t _last_RMC_ms = 0;
- uint32_t _last_GGA_ms = 0;
- uint32_t _last_VTG_ms = 0;
- uint32_t _last_HDT_ms = 0;
-
-
-
-
-
- static const char _SiRF_init_string[];
- static const char _MTK_init_string[];
- static const char _ublox_init_string[];
-
- static const char _initialisation_blob[];
- };
- #define AP_GPS_NMEA_HEMISPHERE_INIT_STRING \
- "$JATT,NMEAHE,0\r\n" \
- "$JASC,GPGGA,5\r\n" \
- "$JASC,GPRMC,5\r\n" \
- "$JASC,GPVTG,5\r\n" \
- "$JASC,GPHDT,5\r\n" \
- "$JMODE,SBASR,YES\r\n"
|