Lely core libraries  1.9.2
sdo_error.hpp
Go to the documentation of this file.
1 
22 #ifndef LELY_COAPP_SDO_ERROR_HPP_
23 #define LELY_COAPP_SDO_ERROR_HPP_
24 
25 #include <lely/coapp/coapp.hpp>
26 
27 #include <stdexcept>
28 #include <system_error>
29 
30 #include <cstdint>
31 
32 namespace lely {
33 
34 namespace canopen {
35 
37 enum class SdoErrc : uint32_t {
39  TOGGLE = UINT32_C(0x05030000),
41  TIMEOUT = UINT32_C(0x05040000),
43  NO_CS = UINT32_C(0x05040001),
45  BLK_SIZE = UINT32_C(0x05040002),
47  BLK_SEQ = UINT32_C(0x05040003),
49  BLK_CRC = UINT32_C(0x05040004),
51  NO_MEM = UINT32_C(0x05040005),
53  NO_ACCESS = UINT32_C(0x06010000),
55  NO_READ = UINT32_C(0x06010001),
57  NO_WRITE = UINT32_C(0x06010002),
59  NO_OBJ = UINT32_C(0x06020000),
61  NO_PDO = UINT32_C(0x06040041),
66  PDO_LEN = UINT32_C(0x06040042),
68  PARAM = UINT32_C(0x06040043),
70  COMPAT = UINT32_C(0x06040047),
72  HARDWARE = UINT32_C(0x06060000),
74  TYPE_LEN = UINT32_C(0x06070010),
76  TYPE_LEN_HI = UINT32_C(0x06070012),
78  TYPE_LEN_LO = UINT32_C(0x06070013),
80  NO_SUB = UINT32_C(0x06090011),
82  PARAM_VAL = UINT32_C(0x06090030),
84  PARAM_HI = UINT32_C(0x06090031),
86  PARAM_LO = UINT32_C(0x06090032),
88  PARAM_RANGE = UINT32_C(0x06090036),
90  NO_SDO = UINT32_C(0x060a0023),
92  ERROR = UINT32_C(0x08000000),
94  DATA = UINT32_C(0x08000020),
99  DATA_CTL = UINT32_C(0x08000021),
104  DATA_DEV = UINT32_C(0x08000022),
110  NO_OD = UINT32_C(0x08000023),
112  NO_VAL = UINT32_C(0x08000024)
113 };
114 
116 class SdoError : public ::std::runtime_error {
117  public:
118  SdoError(uint8_t netid, uint8_t id, uint16_t idx, uint8_t subidx,
119  ::std::error_code ec);
120  SdoError(uint8_t netid, uint8_t id, uint16_t idx, uint8_t subidx,
121  ::std::error_code ec, const ::std::string& what_arg);
122  SdoError(uint8_t netid, uint8_t id, uint16_t idx, uint8_t subidx,
123  ::std::error_code ec, const char* what_arg);
124  SdoError(uint8_t netid, uint8_t id, uint16_t idx, uint8_t subidx, int ev,
125  const char* what_arg);
126  SdoError(uint8_t netid, uint8_t id, uint16_t idx, uint8_t subidx, int ev);
127 
129  uint8_t
130  netid() const noexcept {
131  return netid_;
132  }
133 
135  uint8_t
136  id() const noexcept {
137  return id_;
138  }
139 
141  uint16_t
142  idx() const noexcept {
143  return idx_;
144  }
145 
147  uint8_t
148  subidx() const noexcept {
149  return subidx_;
150  }
151 
153  const ::std::error_code&
154  code() const noexcept {
155  return ec_;
156  }
157 
158  private:
159  uint8_t netid_{0};
160  uint8_t id_{0};
161  uint16_t idx_{0};
162  uint8_t subidx_{0};
163  ::std::error_code ec_;
164 };
165 
167 const ::std::error_category& SdoCategory() noexcept;
168 
170 ::std::error_code make_error_code(SdoErrc e) noexcept;
171 
173 ::std::error_condition make_error_condition(SdoErrc e) noexcept;
174 
175 } // namespace canopen
176 
177 } // namespace lely
178 
179 namespace std {
180 
181 template <>
182 struct is_error_code_enum<::lely::canopen::SdoErrc> : true_type {};
183 
184 } // namespace std
185 
186 #endif // LELY_COAPP_SDO_ERROR_HPP_
General parameter incompatibility reason.
Data cannot be transferred or stored to the application because of the present device state...
This is the public header file of the C++ CANopen application library.
Maximum value is less than minimum value (download only).
Invalid value for parameter (download only).
Invalid block size (block mode only).
Attempt to write a read only object.
STL namespace.
Access failed due to a hardware error.
Resource not available: SDO connection.
Unsupported access to an object.
uint16_t idx() const noexcept
Returns the object index.
Definition: sdo_error.hpp:142
Data cannot be transferred or stored to the application because of local control. ...
uint8_t netid() const noexcept
Returns the network-ID.
Definition: sdo_error.hpp:130
The mask to get/set the toggle bit from an NMT state.
Sub-index does not exist.
No data available. (NO_DATA is a macro defined in <netdb.h>)
Data cannot be transferred or stored to the application.
SdoErrc
The SDO abort codes.
Definition: sdo_error.hpp:37
Data type does not match, length of service parameter too high.
Data type does not match, length of service parameter does not match.
CRC error (block mode only).
Invalid sequence number (block mode only).
Object dictionary dynamic generation fails or no object dictionary is present (e.g.
Object cannot be mapped to the PDO.
SDO protocol timed out.
uint8_t id() const noexcept
Returns the node-ID.
Definition: sdo_error.hpp:136
Object does not exist in the object dictionary.
Client/server command specifier not valid or unknown.
uint8_t subidx() const noexcept
Returns the object sub-index.
Definition: sdo_error.hpp:148
Value of parameter written too low (download only).
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
Definition: sdo_error.cpp:171
Data type does not match, length of service parameter too low.
The number and length of the objects to be mapped would exceed the PDO length.
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32
General internal incompatibility in the device.
const ::std::error_code & code() const noexcept
Returns the stored error code.
Definition: sdo_error.hpp:154
const ::std::error_category & SdoCategory() noexcept
Returns a reference to the error category object for SDO abort codes.
Definition: sdo_error.cpp:165
::std::error_condition make_error_condition(SdoErrc e) noexcept
Creates an error condition corresponding to an SDO abort code.
Definition: sdo_error.cpp:176
Attempt to read a write only object.
The type of exception thrown when an SDO abort code is received.
Definition: sdo_error.hpp:116
Value of parameter written too high (download only).