mavsdk::Shell Class Reference ​
#include: shell.hpp
Allow to communicate with the vehicle's system shell.
Under the hood this uses MAVLink SERIAL_CONTROL. The default device is SERIAL_CONTROL_DEV_SHELL. Callers can pass another SERIAL_CONTROL_DEV on Send (and observe the device on Receive) when the same framing is used for non-nsh serial bridges (for example TELEM2).
Data Structures ​
struct Receive
Public Types ​
| Type | Description |
|---|---|
| enum Device | MAVLink SERIAL_CONTROL_DEV values used by the shell plugin. |
| enum Result | Possible results returned for shell requests. |
| std::function< void(Result)> ResultCallback | Callback type for asynchronous Shell calls. |
| std::function< void(Receive)> ReceiveCallback | Callback type for subscribe_receive. |
| Handle< Receive > ReceiveHandle | Handle type for subscribe_receive. |
Public Member Functions ​
| Type | Name | Description |
|---|---|---|
| Â | Shell (System & system) | Constructor. Creates the plugin for a specific System. |
| Â | Shell (std::shared_ptr< System > system) | Constructor. Creates the plugin for a specific System. |
| Â | ~Shell () override | Destructor (internal use only). |
| Â | Shell (const Shell & other) | Copy constructor. |
| Result | send (std::string command, Device device)const | Send a command line. |
| ReceiveHandle | subscribe_receive (const ReceiveCallback & callback) | Receive feedback from a sent command line. |
| void | unsubscribe_receive (ReceiveHandle handle) | Unsubscribe from subscribe_receive. |
| const Shell & | operator= (const Shell &)=delete | Equality operator (object is not copyable). |
Constructor & Destructor Documentation ​
Shell() ​
mavsdk::Shell::Shell(System &system)Constructor. Creates the plugin for a specific System.
The plugin is typically created as shown below:
auto shell = Shell(system);Parameters
- System& system - The specific system associated with this plugin.
Shell() ​
mavsdk::Shell::Shell(std::shared_ptr< System > system)Constructor. Creates the plugin for a specific System.
The plugin is typically created as shown below:
auto shell = Shell(system);Parameters
- std::shared_ptr< System > system - The specific system associated with this plugin.
~Shell() ​
mavsdk::Shell::~Shell() overrideDestructor (internal use only).
Shell() ​
mavsdk::Shell::Shell(const Shell &other)Copy constructor.
Parameters
- const Shell& other -
Member Typdef Documentation ​
typedef ResultCallback ​
using mavsdk::Shell::ResultCallback = std::function<void(Result)>Callback type for asynchronous Shell calls.
typedef ReceiveCallback ​
using mavsdk::Shell::ReceiveCallback = std::function<void(Receive)>Callback type for subscribe_receive.
typedef ReceiveHandle ​
using mavsdk::Shell::ReceiveHandle = Handle<Receive>Handle type for subscribe_receive.
Member Enumeration Documentation ​
enum Device ​
MAVLink SERIAL_CONTROL_DEV values used by the shell plugin.
| Value | Description |
|---|---|
Telem1 | SERIAL_CONTROL_DEV_TELEM1. |
Telem2 | SERIAL_CONTROL_DEV_TELEM2. |
Gps1 | SERIAL_CONTROL_DEV_GPS1. |
Gps2 | SERIAL_CONTROL_DEV_GPS2. |
Shell | SERIAL_CONTROL_DEV_SHELL (default). |
Serial0 | SERIAL_CONTROL_SERIAL0. |
Serial1 | SERIAL_CONTROL_SERIAL1. |
Serial2 | SERIAL_CONTROL_SERIAL2. |
Serial3 | SERIAL_CONTROL_SERIAL3. |
Serial4 | SERIAL_CONTROL_SERIAL4. |
Serial5 | SERIAL_CONTROL_SERIAL5. |
Serial6 | SERIAL_CONTROL_SERIAL6. |
Serial7 | SERIAL_CONTROL_SERIAL7. |
Serial8 | SERIAL_CONTROL_SERIAL8. |
Serial9 | SERIAL_CONTROL_SERIAL9. |
enum Result ​
Possible results returned for shell requests.
| Value | Description |
|---|---|
Unknown | Unknown result. |
Success | Request succeeded. |
NoSystem | No system is connected. |
ConnectionError | Connection error. |
NoResponse | Response was not received. |
Busy | Shell busy (transfer in progress). |
InvalidArgument | Invalid device / argument. |
Member Function Documentation ​
send() ​
Result mavsdk::Shell::send(std::string command, Device device) constSend a command line.
This function is blocking.
Parameters
- std::string command -
- Device device -
Returns
 Result - Result of request.
subscribe_receive() ​
ReceiveHandle mavsdk::Shell::subscribe_receive(const ReceiveCallback &callback)Receive feedback from a sent command line.
This subscription needs to be made before a command line is sent, otherwise, no response will be sent.
Parameters
- const ReceiveCallback& callback -
Returns
 ReceiveHandle -
unsubscribe_receive() ​
void mavsdk::Shell::unsubscribe_receive(ReceiveHandle handle)Unsubscribe from subscribe_receive.
Parameters
- ReceiveHandle handle -
operator=() ​
const Shell & mavsdk::Shell::operator=(const Shell &)=deleteEquality operator (object is not copyable).
Parameters
- const Shell& -
Returns
 const Shell & -

