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
32namespace lely {
33
34namespace canopen {
35
37enum 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
116class 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
167const ::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
179namespace std {
180
181template <>
182struct is_error_code_enum<::lely::canopen::SdoErrc> : true_type {};
183
184} // namespace std
185
186#endif // LELY_COAPP_SDO_ERROR_HPP_
The type of exception thrown when an SDO abort code is received.
Definition: sdo_error.hpp:116
uint8_t id() const noexcept
Returns the node-ID.
Definition: sdo_error.hpp:136
uint8_t netid() const noexcept
Returns the network-ID.
Definition: sdo_error.hpp:130
uint16_t idx() const noexcept
Returns the object index.
Definition: sdo_error.hpp:142
const ::std::error_code & code() const noexcept
Returns the stored error code.
Definition: sdo_error.hpp:154
uint8_t subidx() const noexcept
Returns the object sub-index.
Definition: sdo_error.hpp:148
This is the public header file of the C++ CANopen application library.
@ TOGGLE
The mask to get/set the toggle bit from an NMT state.
const ::std::error_category & SdoCategory() noexcept
Returns a reference to the error category object for SDO abort codes.
Definition: sdo_error.cpp:165
SdoErrc
The SDO abort codes.
Definition: sdo_error.hpp:37
@ TIMEOUT
SDO protocol timed out.
@ BLK_SIZE
Invalid block size (block mode only).
@ NO_CS
Client/server command specifier not valid or unknown.
@ TYPE_LEN_LO
Data type does not match, length of service parameter too low.
@ PARAM_VAL
Invalid value for parameter (download only).
@ PARAM
General parameter incompatibility reason.
@ NO_VAL
No data available. (NO_DATA is a macro defined in <netdb.h>)
@ NO_SUB
Sub-index does not exist.
@ PARAM_LO
Value of parameter written too low (download only).
@ BLK_SEQ
Invalid sequence number (block mode only).
@ NO_OD
Object dictionary dynamic generation fails or no object dictionary is present (e.g.
@ DATA_DEV
Data cannot be transferred or stored to the application because of the present device state.
@ HARDWARE
Access failed due to a hardware error.
@ PDO_LEN
The number and length of the objects to be mapped would exceed the PDO length.
@ BLK_CRC
CRC error (block mode only).
@ PARAM_HI
Value of parameter written too high (download only).
@ TYPE_LEN
Data type does not match, length of service parameter does not match.
@ PARAM_RANGE
Maximum value is less than minimum value (download only).
@ COMPAT
General internal incompatibility in the device.
@ NO_MEM
Out of memory.
@ NO_OBJ
Object does not exist in the object dictionary.
@ NO_WRITE
Attempt to write a read only object.
@ ERROR
General error.
@ NO_SDO
Resource not available: SDO connection.
@ DATA_CTL
Data cannot be transferred or stored to the application because of local control.
@ TYPE_LEN_HI
Data type does not match, length of service parameter too high.
@ NO_ACCESS
Unsupported access to an object.
@ NO_PDO
Object cannot be mapped to the PDO.
@ DATA
Data cannot be transferred or stored to the application.
@ NO_READ
Attempt to read a write only object.
::std::error_condition make_error_condition(SdoErrc e) noexcept
Creates an error condition corresponding to an SDO abort code.
Definition: sdo_error.cpp:176
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
Definition: sdo_error.cpp:171
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32
STL namespace.