MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
commands_system.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #include <mip/mip_result.hpp>
6 #include <mip/mip_interface.hpp>
7 
8 #include <stdint.h>
9 #include <stddef.h>
10 
11 namespace mip {
12 namespace C {
13 struct mip_interface;
14 } // namespace C
15 
16 namespace commands_system {
17 
24 
26 // Descriptors
28 
29 enum
30 {
32 
33  CMD_ENUMERATE = 0x01,
34  CMD_COM_MODE = 0x10,
37 
41 };
42 
44 // Shared Type Definitions
46 
47 static constexpr const uint8_t MIP_SYSTEM_COMMAND_COMM_MODE_PASSTHRU = 0x00;
48 static constexpr const uint8_t MIP_SYSTEM_COMMAND_COMM_MODE_NORMAL = 0x01;
49 static constexpr const uint8_t MIP_SYSTEM_COMMAND_COMM_MODE_IMU = 0x02;
50 static constexpr const uint8_t MIP_SYSTEM_COMMAND_COMM_MODE_GPS = 0x03;
51 
53 // Mip Fields
55 
69 
70 struct CommMode
71 {
73  FunctionSelector function = static_cast<FunctionSelector>(0);
74  uint8_t mode = 0;
75 
77  static constexpr const uint8_t DESCRIPTOR_SET = ::mip::commands_system::DESCRIPTOR_SET;
78  static constexpr const uint8_t FIELD_DESCRIPTOR = ::mip::commands_system::CMD_COM_MODE;
80  static constexpr const char* NAME = "CommMode";
81  static constexpr const char* DOC_NAME = "CommMode";
82  static constexpr const bool HAS_FUNCTION_SELECTOR = true;
83 
84  auto asTuple() const
85  {
86  return std::make_tuple(mode);
87  }
88 
89  auto asTuple()
90  {
91  return std::make_tuple(std::ref(mode));
92  }
93 
95  {
96  CommMode cmd;
97  cmd.function = function;
98  return cmd;
99  }
100 
102  void insert(Serializer& serializer) const;
103  void extract(Serializer& serializer);
104 
105  struct Response
106  {
108  uint8_t mode = 0;
109 
111  static constexpr const uint8_t DESCRIPTOR_SET = ::mip::commands_system::DESCRIPTOR_SET;
114  static constexpr const char* NAME = "CommMode::Response";
115  static constexpr const char* DOC_NAME = "CommMode Response";
116  static constexpr const bool HAS_FUNCTION_SELECTOR = false;
117 
118  auto asTuple() const
119  {
120  return std::make_tuple(mode);
121  }
122 
123  auto asTuple()
124  {
125  return std::make_tuple(std::ref(mode));
126  }
127 
129  void insert(Serializer& serializer) const;
130  void extract(Serializer& serializer);
131 
132  };
133 };
135 TypedResult<CommMode> readCommMode(C::mip_interface& device, uint8_t* modeOut);
137 
140 
145 } // namespace commands_system
146 } // namespace mip
147 
mip
A collection of C++ classes and functions covering the full mip api.
Definition: commands_3dm.c:11
mip::commands_system::CMD_HARDWARE_CONTROL_2
@ CMD_HARDWARE_CONTROL_2
Definition: commands_system.hpp:36
mip::commands_system::CMD_HARDWARE_CONTROL
@ CMD_HARDWARE_CONTROL
Definition: commands_system.hpp:35
mip_descriptors.hpp
mip::commands_system::defaultCommMode
TypedResult< CommMode > defaultCommMode(C::mip_interface &device)
Definition: commands_system.cpp:90
mip::commands_system::CommMode::insert
void insert(Serializer &serializer) const
Serialization.
Definition: commands_system.cpp:23
microstrain::Serializer
Serializes or deserializes data to/from a byte buffer.
Definition: serializer.hpp:125
mip::commands_system::CommMode::extract
void extract(Serializer &serializer)
Definition: commands_system.cpp:33
mip::commands_system::CommMode::asTuple
auto asTuple()
Definition: commands_system.hpp:89
mip::commands_system::CMD_ENUMERATE
@ CMD_ENUMERATE
Definition: commands_system.hpp:33
mip::commands_system::CommMode::Response::asTuple
auto asTuple() const
Definition: commands_system.hpp:118
mip::C::mip_interface
struct mip::C::mip_interface mip_interface
State of the interface for communicating with a MIP device.
mip::commands_system::CommMode::Response::DOC_NAME
static constexpr const char * DOC_NAME
Definition: commands_system.hpp:115
mip::commands_system::CommMode::Response::FIELD_DESCRIPTOR
static constexpr const uint8_t FIELD_DESCRIPTOR
Definition: commands_system.hpp:112
mip::commands_system::CommMode::create_sld_all
static CommMode create_sld_all(::mip::FunctionSelector function)
Definition: commands_system.hpp:94
mip::commands_system::CommMode::Response::insert
void insert(Serializer &serializer) const
Serialization.
Definition: commands_system.cpp:44
mip::commands_system::CommMode::asTuple
auto asTuple() const
Definition: commands_system.hpp:84
mip::commands_system::REPLY_COM_MODE
@ REPLY_COM_MODE
Definition: commands_system.hpp:38
mip::commands_system::writeCommMode
TypedResult< CommMode > writeCommMode(C::mip_interface &device, uint8_t mode)
Definition: commands_system.cpp:55
mip::FunctionSelector
FunctionSelector
Definition: mip_descriptors.hpp:68
mip::commands_system::CommMode::Response
Definition: commands_system.hpp:105
mip::commands_system::CommMode::Response::asTuple
auto asTuple()
Definition: commands_system.hpp:123
mip::commands_system::CommMode::Response::HAS_FUNCTION_SELECTOR
static constexpr const bool HAS_FUNCTION_SELECTOR
Definition: commands_system.hpp:116
mip::commands_system::CommMode::Response::NAME
static constexpr const char * NAME
Definition: commands_system.hpp:114
mip::commands_system::CommMode::NAME
static constexpr const char * NAME
Definition: commands_system.hpp:80
mip::commands_system::CommMode::HAS_FUNCTION_SELECTOR
static constexpr const bool HAS_FUNCTION_SELECTOR
Definition: commands_system.hpp:82
mip::commands_system::CommMode::FIELD_DESCRIPTOR
static constexpr const uint8_t FIELD_DESCRIPTOR
Definition: commands_system.hpp:78
mip::commands_system::REPLY_HARDWARE_CONTROL_2
@ REPLY_HARDWARE_CONTROL_2
Definition: commands_system.hpp:40
mip::commands_system::CMD_COM_MODE
@ CMD_COM_MODE
Definition: commands_system.hpp:34
mip::C::mip_interface
State of the interface for communicating with a MIP device.
Definition: mip_interface.h:44
mip::commands_system::REPLY_HARDWARE_CONTROL
@ REPLY_HARDWARE_CONTROL
Definition: commands_system.hpp:39
mip::commands_system::CommMode::DOC_NAME
static constexpr const char * DOC_NAME
Definition: commands_system.hpp:81
mip::commands_system::CommMode::function
FunctionSelector function
Parameters.
Definition: commands_system.hpp:73
mip::commands_system::CommMode::DESCRIPTOR
static constexpr const CompositeDescriptor DESCRIPTOR
Definition: commands_system.hpp:79
mip_interface.hpp
mip::commands_system::CommMode::Response::mode
uint8_t mode
Parameters.
Definition: commands_system.hpp:108
mip::commands_system::readCommMode
TypedResult< CommMode > readCommMode(C::mip_interface &device, uint8_t *modeOut)
Definition: commands_system.cpp:67
mip::commands_system::CommMode::Response::extract
void extract(Serializer &serializer)
Definition: commands_system.cpp:49
mip::commands_system::CommMode::Response::DESCRIPTOR
static constexpr const CompositeDescriptor DESCRIPTOR
Definition: commands_system.hpp:113
mip::commands_system::CommMode::DESCRIPTOR_SET
static constexpr const uint8_t DESCRIPTOR_SET
Descriptors.
Definition: commands_system.hpp:77
mip::commands_system::CommMode::Response::DESCRIPTOR_SET
static constexpr const uint8_t DESCRIPTOR_SET
Descriptors.
Definition: commands_system.hpp:111
mip::CompositeDescriptor
Convenience struct holding both descriptor set and field descriptor.
Definition: mip_descriptors.hpp:22
mip::commands_system::DESCRIPTOR_SET
@ DESCRIPTOR_SET
Definition: commands_system.hpp:31
mip::commands_system::CommMode
Definition: commands_system.hpp:70
mip::TypedResult
A CmdResult that knows the corresponding command type.
Definition: mip_descriptors.hpp:100
common.hpp
mip_result.hpp
mip::commands_system::CommMode::mode
uint8_t mode
Definition: commands_system.hpp:74