Line |
Branch |
Exec |
Source |
1 |
|
|
/**************************************************************************** |
2 |
|
|
* |
3 |
|
|
* Copyright (c) 2018 MAVlink Development Team. All rights reserved. |
4 |
|
|
* Author: Hannes Diethelm, <hannes.diethelm@gmail.com> |
5 |
|
|
* Trent Lukaczyk, <aerialhedgehog@gmail.com> |
6 |
|
|
* Jaycee Lock, <jaycee.lock@gmail.com> |
7 |
|
|
* Lorenz Meier, <lm@inf.ethz.ch> |
8 |
|
|
* |
9 |
|
|
* Redistribution and use in source and binary forms, with or without |
10 |
|
|
* modification, are permitted provided that the following conditions |
11 |
|
|
* are met: |
12 |
|
|
* |
13 |
|
|
* 1. Redistributions of source code must retain the above copyright |
14 |
|
|
* notice, this list of conditions and the following disclaimer. |
15 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
16 |
|
|
* notice, this list of conditions and the following disclaimer in |
17 |
|
|
* the documentation and/or other materials provided with the |
18 |
|
|
* distribution. |
19 |
|
|
* 3. Neither the name PX4 nor the names of its contributors may be |
20 |
|
|
* used to endorse or promote products derived from this software |
21 |
|
|
* without specific prior written permission. |
22 |
|
|
* |
23 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24 |
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
25 |
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
26 |
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
27 |
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28 |
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
29 |
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
30 |
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
31 |
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
33 |
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34 |
|
|
* POSSIBILITY OF SUCH DAMAGE. |
35 |
|
|
* |
36 |
|
|
****************************************************************************/ |
37 |
|
|
|
38 |
|
|
/** |
39 |
|
|
* @file generic_port.hpp |
40 |
|
|
* |
41 |
|
|
* @brief Generic interface definition |
42 |
|
|
* |
43 |
|
|
* Abstract port definition |
44 |
|
|
* |
45 |
|
|
* @author Hannes Diethelm, <hannes.diethelm@gmail.com> |
46 |
|
|
* @author Trent Lukaczyk, <aerialhedgehog@gmail.com> |
47 |
|
|
* @author Jaycee Lock, <jaycee.lock@gmail.com> |
48 |
|
|
* @author Lorenz Meier, <lm@inf.ethz.ch> |
49 |
|
|
* |
50 |
|
|
*/ |
51 |
|
|
|
52 |
|
|
#pragma once |
53 |
|
|
|
54 |
|
|
#if __linux__ || __APPLE__ |
55 |
|
|
// ------------------------------------------------------------------------------ |
56 |
|
|
// Includes |
57 |
|
|
// ------------------------------------------------------------------------------ |
58 |
|
|
|
59 |
|
|
#include <mavlink/common/mavlink.h> |
60 |
|
|
// #include <common/mavlink.h> |
61 |
|
|
|
62 |
|
|
// ------------------------------------------------------------------------------ |
63 |
|
|
// Defines |
64 |
|
|
// ------------------------------------------------------------------------------ |
65 |
|
|
|
66 |
|
|
// ------------------------------------------------------------------------------ |
67 |
|
|
// Prototypes |
68 |
|
|
// ------------------------------------------------------------------------------ |
69 |
|
|
|
70 |
|
|
// ---------------------------------------------------------------------------------- |
71 |
|
|
// Generic Port Manager Class |
72 |
|
|
// ---------------------------------------------------------------------------------- |
73 |
|
|
|
74 |
|
|
/// @brief Generic Port Class (This is an abstract port definition to handle both serial and UDP ports) |
75 |
|
|
class Generic_Port |
76 |
|
|
{ |
77 |
|
|
public: |
78 |
|
|
/// @brief Variable to de-initialize node if cable is pulled |
79 |
|
|
bool cabelCheck = false; |
80 |
|
|
/// @brief Default constructor |
81 |
|
✗ |
Generic_Port() = default; |
82 |
|
|
/// @brief Destructor |
83 |
|
✗ |
virtual ~Generic_Port() = default; |
84 |
|
|
/// @brief Copy constructor |
85 |
|
|
Generic_Port(const Generic_Port&) = delete; |
86 |
|
|
/// @brief Move constructor |
87 |
|
|
Generic_Port(Generic_Port&&) = delete; |
88 |
|
|
/// @brief Copy assignment operator |
89 |
|
|
Generic_Port& operator=(const Generic_Port&) = delete; |
90 |
|
|
/// @brief Move assignment operator |
91 |
|
|
Generic_Port& operator=(Generic_Port&&) = delete; |
92 |
|
|
|
93 |
|
|
/// @brief Read Mavlink message |
94 |
|
|
/// @param[in] message Mavlink message to read |
95 |
|
|
virtual int read_message(mavlink_message_t& message) = 0; |
96 |
|
|
|
97 |
|
|
/// @brief Write Mavlink message |
98 |
|
|
/// @param[in] message Mavlink message to write |
99 |
|
|
virtual int write_message(const mavlink_message_t& message) = 0; |
100 |
|
|
|
101 |
|
|
/// @brief Is running |
102 |
|
|
virtual bool is_running() = 0; |
103 |
|
|
|
104 |
|
|
/// @brief Start |
105 |
|
|
virtual void start() = 0; |
106 |
|
|
|
107 |
|
|
/// @brief Stop |
108 |
|
|
virtual void stop() = 0; |
109 |
|
|
}; |
110 |
|
|
|
111 |
|
|
#endif |
112 |
|
|
|