CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_GPS/AP_GPS_GSOF.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
//
17
// Trimble GPS driver for ArduPilot.
18
// Code by Michael Oborne
19
// https://receiverhelp.trimble.com/oem-gnss/index.html#Welcome.html?TocPath=_____1
20
21
#pragma once
22
23
#include "AP_GPS.h"
24
#include "GPS_Backend.h"
25
#include <AP_GSOF/AP_GSOF.h>
26
27
#if AP_GPS_GSOF_ENABLED
28
class AP_GPS_GSOF : public AP_GPS_Backend, public AP_GSOF
29
{
30
public:
31
AP_GPS_GSOF(AP_GPS &_gps, AP_GPS::Params &_params, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port);
32
33
AP_GPS::GPS_Status highest_supported_status(void) override WARN_IF_UNUSED {
34
return AP_GPS::GPS_OK_FIX_3D_RTK_FIXED;
35
}
36
37
// Methods
38
bool read() override WARN_IF_UNUSED;
39
40
const char *name() const override { return "GSOF"; }
41
42
private:
43
44
// A subset of the port identifiers in the GSOF protocol that are used for serial.
45
// Ethernet, USB, etc are not supported by the GPS driver at this time so they are omitted.
46
// These values are not documented in the API.
47
enum class HW_Port {
48
COM1 = 0, // RS232 serial
49
COM2 = 1, // TTL serial
50
};
51
52
// A subset of the data frequencies in the GSOF protocol that are used for serial.
53
// These values are not documented in the API.
54
enum class Output_Rate {
55
FREQ_10_HZ = 1,
56
FREQ_50_HZ = 15,
57
FREQ_100_HZ = 16,
58
};
59
60
// Send a request to the GPS to set the baud rate on the specified port.
61
// Note - these request functions currently ignore the ACK from the device.
62
// If the device is already sending serial traffic, there is no mechanism to prevent conflict.
63
// According to the manufacturer, the best approach is to switch to ethernet.
64
void requestBaud(const HW_Port portIndex);
65
// Send a request to the GPS to enable a message type on the port at the specified rate.
66
void requestGSOF(const uint8_t messageType, const HW_Port portIndex, const Output_Rate rateHz);
67
68
bool validate_baud(const uint8_t baud) const WARN_IF_UNUSED;
69
bool validate_com_port(const uint8_t com_port) const WARN_IF_UNUSED;
70
71
void pack_state_data();
72
73
uint8_t packetcount;
74
uint32_t gsofmsg_time;
75
uint8_t gsofmsgreq_index;
76
uint16_t next_req_gsof;
77
AP_GSOF::MsgTypes requested_msgs;
78
};
79
#endif
80
81