PX4 Firmware
PX4 Autopilot Software http://px4.io
mavlink_parameters.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2012-2018 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file mavlink_parameters.h
36  * Mavlink parameters manager definition.
37  *
38  * @author Anton Babushkin <anton.babushkin@me.com>
39  * @author Lorenz Meier <lorenz@px4.io>
40  * @author Beat Kueng <beat@px4.io>
41  */
42 
43 #pragma once
44 
45 #include <parameters/param.h>
46 
47 #include "mavlink_bridge_header.h"
48 #include <uORB/Publication.hpp>
50 #include <uORB/Subscription.hpp>
55 #include <drivers/drv_hrt.h>
56 
57 class Mavlink;
58 
60 {
61 public:
62  explicit MavlinkParametersManager(Mavlink *mavlink);
63  ~MavlinkParametersManager() = default;
64 
65  /**
66  * Handle sending of messages. Call this regularly at a fixed frequency.
67  * @param t current time
68  */
69  void send(const hrt_abstime t);
70 
71  unsigned get_size();
72 
73  void handle_message(const mavlink_message_t *msg);
74 
75 private:
76  int _send_all_index{-1};
77 
78  /* do not allow top copying this class */
81 
82 protected:
83  /// send a single param if a PARAM_REQUEST_LIST is in progress
84  /// @return true if a parameter was sent
85  bool send_one();
86 
87  /**
88  * Handle any open param send transfer
89  */
90  bool send_params();
91 
92  /**
93  * Send UAVCAN params
94  */
95  bool send_uavcan();
96 
97  /**
98  * Send untransmitted params
99  */
100  bool send_untransmitted();
101 
102  int send_param(param_t param, int component_id = -1);
103 
104  // Item of a single-linked list to store requested uavcan parameters
108  };
109 
110  /**
111  * Request the next uavcan parameter
112  */
114 
115  /**
116  * Enqueue one uavcan parameter reqest. We store 10 at max.
117  */
119 
120  /**
121  * Drop the first reqest from the list
122  */
123  void dequeue_uavcan_request();
124 
125  _uavcan_open_request_list_item *_uavcan_open_request_list{nullptr}; ///< Pointer to the first item in the linked list
126  bool _uavcan_waiting_for_request_response{false}; ///< We have reqested a parameter and wait for the response
127  uint16_t _uavcan_queued_request_items{0}; ///< Number of stored parameter requests currently in the list
128 
131 
133 
135 
139 
141 };
High-resolution timer with callouts and timekeeping.
Global flash based parameter store.
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
Definition: px4io.c:89
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
uint32_t param_t
Parameter handle.
Definition: param.h:98