2015-09-11 10:42:58 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// Trimble GPS driver for ArduPilot.
|
|
|
|
// Code by Michael Oborne
|
2023-05-19 02:02:31 -03:00
|
|
|
// https://receiverhelp.trimble.com/oem-gnss/index.html#Welcome.html?TocPath=_____1
|
|
|
|
|
2016-02-17 21:25:23 -04:00
|
|
|
#pragma once
|
2015-09-11 10:42:58 -03:00
|
|
|
|
|
|
|
#include "AP_GPS.h"
|
2016-04-13 14:20:05 -03:00
|
|
|
#include "GPS_Backend.h"
|
2015-09-11 10:42:58 -03:00
|
|
|
|
2022-01-09 19:15:32 -04:00
|
|
|
#if AP_GPS_GSOF_ENABLED
|
2015-09-11 10:42:58 -03:00
|
|
|
class AP_GPS_GSOF : public AP_GPS_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_GPS_GSOF(AP_GPS &_gps, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port);
|
|
|
|
|
2023-05-10 11:53:30 -03:00
|
|
|
AP_GPS::GPS_Status highest_supported_status(void) override WARN_IF_UNUSED {
|
2017-01-25 20:03:22 -04:00
|
|
|
return AP_GPS::GPS_OK_FIX_3D_RTK_FIXED;
|
2015-09-11 10:42:58 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Methods
|
2023-05-10 11:53:30 -03:00
|
|
|
bool read() override WARN_IF_UNUSED;
|
2015-09-11 10:42:58 -03:00
|
|
|
|
2016-08-01 08:58:23 -03:00
|
|
|
const char *name() const override { return "GSOF"; }
|
|
|
|
|
2015-09-11 10:42:58 -03:00
|
|
|
private:
|
|
|
|
|
2023-11-04 01:22:27 -03:00
|
|
|
// A subset of the port identifiers in the GSOF protocol that are used for serial.
|
|
|
|
// Ethernet, USB, etc are not supported by the GPS driver at this time so they are omitted.
|
|
|
|
// These values are not documented in the API.
|
|
|
|
enum class HW_Port {
|
2023-11-07 11:06:42 -04:00
|
|
|
COM1 = 0, // RS232 serial
|
2023-11-04 01:22:27 -03:00
|
|
|
COM2 = 1, // TTL serial
|
|
|
|
};
|
|
|
|
|
|
|
|
// A subset of the data frequencies in the GSOF protocol that are used for serial.
|
|
|
|
// These values are not documented in the API.
|
|
|
|
enum class Output_Rate {
|
|
|
|
FREQ_10_HZ = 1,
|
|
|
|
FREQ_50_HZ = 15,
|
|
|
|
FREQ_100_HZ = 16,
|
|
|
|
};
|
|
|
|
|
2023-05-10 11:53:30 -03:00
|
|
|
bool parse(const uint8_t temp) WARN_IF_UNUSED;
|
|
|
|
bool process_message() WARN_IF_UNUSED;
|
2023-11-28 01:02:44 -04:00
|
|
|
|
|
|
|
// Send a request to the GPS to set the baud rate on the specified port.
|
|
|
|
// Note - these request functions currently ignore the ACK from the device.
|
|
|
|
// If the device is already sending serial traffic, there is no mechanism to prevent conflict.
|
|
|
|
// According to the manufacturer, the best approach is to switch to ethernet.
|
|
|
|
void requestBaud(const HW_Port portIndex);
|
|
|
|
// Send a request to the GPS to enable a message type on the port at the specified rate.
|
|
|
|
void requestGSOF(const uint8_t messageType, const HW_Port portIndex, const Output_Rate rateHz);
|
|
|
|
|
2023-05-11 15:12:35 -03:00
|
|
|
double SwapDouble(const uint8_t* src, const uint32_t pos) const WARN_IF_UNUSED;
|
|
|
|
float SwapFloat(const uint8_t* src, const uint32_t pos) const WARN_IF_UNUSED;
|
|
|
|
uint32_t SwapUint32(const uint8_t* src, const uint32_t pos) const WARN_IF_UNUSED;
|
|
|
|
uint16_t SwapUint16(const uint8_t* src, const uint32_t pos) const WARN_IF_UNUSED;
|
2015-09-11 10:42:58 -03:00
|
|
|
|
2023-11-04 01:22:27 -03:00
|
|
|
bool validate_baud(const uint8_t baud) const WARN_IF_UNUSED;
|
2023-11-07 11:06:42 -04:00
|
|
|
bool validate_com_port(const uint8_t com_port) const WARN_IF_UNUSED;
|
2023-11-04 01:22:27 -03:00
|
|
|
|
2023-05-11 15:24:33 -03:00
|
|
|
struct Msg_Parser
|
2015-09-11 10:42:58 -03:00
|
|
|
{
|
2023-05-09 14:52:45 -03:00
|
|
|
|
2023-05-11 15:24:33 -03:00
|
|
|
enum class State
|
2015-09-11 10:42:58 -03:00
|
|
|
{
|
|
|
|
STARTTX = 0,
|
|
|
|
STATUS,
|
|
|
|
PACKETTYPE,
|
|
|
|
LENGTH,
|
|
|
|
DATA,
|
|
|
|
CHECKSUM,
|
|
|
|
ENDTX
|
2023-05-09 14:52:45 -03:00
|
|
|
};
|
|
|
|
|
2023-11-28 01:02:37 -04:00
|
|
|
State state;
|
2015-09-11 10:42:58 -03:00
|
|
|
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t packettype;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t data[256];
|
|
|
|
uint8_t checksum;
|
|
|
|
uint8_t endtx;
|
|
|
|
|
|
|
|
uint16_t read;
|
|
|
|
uint8_t checksumcalc;
|
2023-05-11 15:24:33 -03:00
|
|
|
} msg;
|
2015-09-11 10:42:58 -03:00
|
|
|
|
2023-05-11 15:24:33 -03:00
|
|
|
static const uint8_t STX = 0x02;
|
|
|
|
static const uint8_t ETX = 0x03;
|
2023-11-28 01:02:44 -04:00
|
|
|
|
|
|
|
uint8_t packetcount;
|
2023-05-19 02:17:21 -03:00
|
|
|
uint32_t gsofmsg_time;
|
|
|
|
uint8_t gsofmsgreq_index;
|
2023-05-18 22:24:34 -03:00
|
|
|
const uint8_t gsofmsgreq[5] = {1,2,8,9,12};
|
2015-09-11 10:42:58 -03:00
|
|
|
};
|
2022-01-09 19:15:32 -04:00
|
|
|
#endif
|