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/Tools/AP_Periph/GCS_MAVLink.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
#pragma once
16
17
#include <GCS_MAVLink/GCS.h>
18
#if HAL_GCS_ENABLED
19
20
/*
21
* GCS backend used for many examples and tools
22
*/
23
class GCS_MAVLINK_Periph : public GCS_MAVLINK
24
{
25
public:
26
27
using GCS_MAVLINK::GCS_MAVLINK;
28
29
private:
30
31
uint32_t telem_delay() const override { return 0; }
32
bool handle_guided_request(AP_Mission::Mission_Command &cmd) override { return true; }
33
MAV_RESULT handle_preflight_reboot(const mavlink_command_int_t &packet, const mavlink_message_t &msg) override;
34
uint8_t sysid_my_gcs() const override;
35
36
protected:
37
38
// Periph information:
39
MAV_MODE base_mode() const override { return (MAV_MODE)MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; }
40
MAV_STATE vehicle_system_status() const override { return MAV_STATE_CALIBRATING; }
41
42
void send_nav_controller_output() const override {};
43
void send_pid_tuning() override {};
44
virtual uint8_t send_available_mode(uint8_t index) const override { return 0; }
45
};
46
47
/*
48
* a GCS singleton used for many example sketches and tools
49
*/
50
51
extern const AP_HAL::HAL& hal;
52
53
class GCS_Periph : public GCS
54
{
55
public:
56
57
using GCS::GCS;
58
59
protected:
60
61
uint8_t sysid_this_mav() const override;
62
63
GCS_MAVLINK_Periph *new_gcs_mavlink_backend(GCS_MAVLINK_Parameters &params,
64
AP_HAL::UARTDriver &uart) override {
65
return NEW_NOTHROW GCS_MAVLINK_Periph(params, uart);
66
}
67
68
private:
69
// the following define expands to a pair of methods to retrieve a
70
// pointer to an object of the correct subclass for the link at
71
// offset ofs. These are of the form:
72
// GCS_MAVLINK_XXXX *chan(const uint8_t ofs) override;
73
// const GCS_MAVLINK_XXXX *chan(const uint8_t ofs) override const;
74
GCS_MAVLINK_CHAN_METHOD_DEFINITIONS(GCS_MAVLINK_Periph);
75
76
MAV_TYPE frame_type() const override { return MAV_TYPE_GENERIC; }
77
uint32_t custom_mode() const override { return 3; } // magic number
78
};
79
#endif // HAL_GCS_ENABLED
80
81