class ugcs::vsm::Mavlink_stream¶
Overview¶
Convenience class for interpreting an I/O stream as a stream of Mavlink messages. More…
#include <mavlink_stream.h> class Mavlink_stream: public std::enable_shared_from_this< Mavlink_stream > { public: // typedefs typedef std::shared_ptr<Mavlink_stream> Ptr; typedef std::weak_ptr<Mavlink_stream> Weak_ptr; typedef Mavlink_decoder Decoder; // fields std::string name; // construction Mavlink_stream(Io_stream::Ref stream); Mavlink_stream(const Mavlink_stream&); // methods template <typename... Args> static Ptr Create(Args&&... args); Io_stream::Ref& Get_stream(); Decoder& Get_decoder(); Mavlink_demuxer& Get_demuxer(); void Bind_decoder_demuxer(); void Set_mavlink_v2(bool enable = true); bool Is_mavlink_v2(); void Send_message( const mavlink::Payload_base& payload, uint8_t system_id, uint8_t component_id, const std::chrono::milliseconds& timeout, Operation_waiter::Timeout_handler timeout_handler, const Request_completion_context::Ptr& completion_ctx ); void Send_message( const mavlink::Payload_base& payload, uint8_t system_id, uint8_t component_id, const std::chrono::milliseconds& timeout, Operation_waiter::Timeout_handler timeout_handler, const Request_completion_context::Ptr& completion_ctx, bool mav2 ); void Disable(); void Increment_vehicle_counter(); void Decrement_vehicle_counter(); int Get_vehicle_counter(); };
Detailed Documentation¶
Convenience class for interpreting an I/O stream as a stream of Mavlink messages.
It is assumed, that only one such class at a time is used with a given I/O stream.
Typedefs¶
typedef std::shared_ptr<Mavlink_stream> Ptr
Pointer type.
typedef std::weak_ptr<Mavlink_stream> Weak_ptr
Pointer type.
typedef Mavlink_decoder Decoder
Type of the appropriate Mavlink decoder.
Construction¶
Mavlink_stream(Io_stream::Ref stream)
Construct Mavlink stream using a I/O stream.
Mavlink_stream(const Mavlink_stream&)
Disable copy constructor.
Methods¶
template <typename... Args> static Ptr Create(Args&&... args)
Create an instance.
Io_stream::Ref& Get_stream()
Get underlying I/O stream.
Decoder& Get_decoder()
Get underlying decoder.
Mavlink_demuxer& Get_demuxer()
Get underlying demuxer.
void Bind_decoder_demuxer()
Bind decoder and demuxer, so that output of the decoder is automatically passed to the demuxer.
void Set_mavlink_v2(bool enable = true)
Toggle mavlink protocol v1/v2 for outgoing messages.
bool Is_mavlink_v2()
Return true if this stream supports mavlink2.
void Send_message( const mavlink::Payload_base& payload, uint8_t system_id, uint8_t component_id, const std::chrono::milliseconds& timeout, Operation_waiter::Timeout_handler timeout_handler, const Request_completion_context::Ptr& completion_ctx )
Send Mavlink message to other end asynchronously.
Timeout should be always present, otherwise there is a chance to overflow the write queue if underlying stream is write-blocked. Only non-temporal completion contexts are allowed.
void Send_message( const mavlink::Payload_base& payload, uint8_t system_id, uint8_t component_id, const std::chrono::milliseconds& timeout, Operation_waiter::Timeout_handler timeout_handler, const Request_completion_context::Ptr& completion_ctx, bool mav2 )
Send Mavlink message to other end asynchronously.
Timeout should be always present, otherwise there is a chance to overflow the write queue if underlying stream is write-blocked. Only non-temporal completion contexts are allowed.
void Disable()
Disable the class.
Underlying I/O stream is freed, but not explicitly closed, because this stream could be passed for further processing. Unfinished write operations are aborted.