Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_GPS/AP_GPS_SIRF.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415//16// SiRF Binary GPS driver for ArduPilot and ArduPilotMega.17// Code by Michael Smith.18//19#pragma once2021#include <AP_Common/AP_Common.h>22#include <AP_HAL/AP_HAL.h>2324#include "AP_GPS.h"25#include "GPS_Backend.h"2627#if AP_GPS_SIRF_ENABLED2829#define SIRF_SET_BINARY "$PSRF100,0,38400,8,1,0*3C\r\n"3031class AP_GPS_SIRF : public AP_GPS_Backend {32public:33AP_GPS_SIRF(AP_GPS &_gps, AP_GPS::Params &_params, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port);3435bool read() override;3637static bool _detect(struct SIRF_detect_state &state, uint8_t data);3839const char *name() const override { return "SIRF"; }4041private:42struct PACKED sirf_geonav {43uint16_t fix_invalid;44uint16_t fix_type;45uint16_t week;46uint32_t time;47uint16_t year;48uint8_t month;49uint8_t day;50uint8_t hour;51uint8_t minute;52uint16_t second;53uint32_t satellites_used;54int32_t latitude;55int32_t longitude;56int32_t altitude_ellipsoid;57int32_t altitude_msl;58int8_t map_datum;59int16_t ground_speed;60int16_t ground_course;61int16_t res1;62int16_t climb_rate;63uint16_t heading_rate;64uint32_t horizontal_position_error;65uint32_t vertical_position_error;66uint32_t time_error;67int16_t horizontal_velocity_error;68int32_t clock_bias;69uint32_t clock_bias_error;70int32_t clock_drift;71uint32_t clock_drift_error;72uint32_t distance;73uint16_t distance_error;74uint16_t heading_error;75uint8_t satellites;76uint8_t hdop;77uint8_t mode_info;78};79enum sirf_protocol_bytes {80PREAMBLE1 = 0xa0,81PREAMBLE2 = 0xa2,82POSTAMBLE1 = 0xb0,83POSTAMBLE2 = 0xb3,84MSG_GEONAV = 0x2985};86enum sirf_fix_type {87FIX_3D = 0x6,88FIX_MASK = 0x789};909192// State machine state93uint8_t _step;94uint16_t _checksum;95bool _gather;96uint16_t _payload_length;97uint16_t _payload_counter;98uint8_t _msg_id;99100// Message buffer101union {102DEFINE_BYTE_ARRAY_METHODS103sirf_geonav nav;104} _buffer;105106bool _parse_gps(void);107void _accumulate(uint8_t val);108109static const uint8_t _initialisation_blob[];110};111#endif112113114