Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/AP_Periph/GCS_MAVLink.h
9592 views
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
bool handle_guided_request(AP_Mission::Mission_Command &cmd) override { return true; }
32
MAV_RESULT handle_preflight_reboot(const mavlink_command_int_t &packet, const mavlink_message_t &msg) override;
33
34
protected:
35
36
// Periph information:
37
uint8_t base_mode() const override { return MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; }
38
MAV_STATE vehicle_system_status() const override { return MAV_STATE_CALIBRATING; }
39
40
void send_nav_controller_output() const override {};
41
void send_pid_tuning() override {};
42
virtual uint8_t send_available_mode(uint8_t index) const override { return 0; }
43
};
44
45
/*
46
* a GCS singleton used for many example sketches and tools
47
*/
48
49
extern const AP_HAL::HAL& hal;
50
51
class GCS_Periph : public GCS
52
{
53
public:
54
55
using GCS::GCS;
56
57
protected:
58
59
GCS_MAVLINK_Periph *new_gcs_mavlink_backend(AP_HAL::UARTDriver &uart) override {
60
return NEW_NOTHROW GCS_MAVLINK_Periph(uart);
61
}
62
63
private:
64
// the following define expands to a pair of methods to retrieve a
65
// pointer to an object of the correct subclass for the link at
66
// offset ofs. These are of the form:
67
// GCS_MAVLINK_XXXX *chan(const uint8_t ofs) override;
68
// const GCS_MAVLINK_XXXX *chan(const uint8_t ofs) override const;
69
GCS_MAVLINK_CHAN_METHOD_DEFINITIONS(GCS_MAVLINK_Periph);
70
71
MAV_TYPE frame_type() const override { return MAV_TYPE_GENERIC; }
72
uint32_t custom_mode() const override { return 3; } // magic number
73
};
74
#endif // HAL_GCS_ENABLED
75
76