Lely core libraries 2.3.4
err.hpp
Go to the documentation of this file.
1
24#ifndef LELY_IO2_CAN_ERR_HPP_
25#define LELY_IO2_CAN_ERR_HPP_
26
27#include <lely/io2/can/err.h>
28
29namespace lely {
30namespace io {
31
33enum class CanState : int {
41 SLEEPING = CAN_STATE_SLEEPING,
43 STOPPED = CAN_STATE_STOPPED
44};
45
47enum class CanError : int {
49 BIT = CAN_ERROR_BIT,
51 STUFF = CAN_ERROR_STUFF,
53 CRC = CAN_ERROR_CRC,
55 FORM = CAN_ERROR_FORM,
57 ACK = CAN_ERROR_ACK,
59 OTHER = CAN_ERROR_OTHER,
60 NONE = 0
61};
62
63constexpr CanError
64operator~(CanError rhs) {
65 return static_cast<CanError>(~static_cast<int>(rhs));
66}
67
68constexpr CanError
69operator&(CanError lhs, CanError rhs) {
70 return static_cast<CanError>(static_cast<int>(lhs) & static_cast<int>(rhs));
71}
72
73constexpr CanError
74operator^(CanError lhs, CanError rhs) {
75 return static_cast<CanError>(static_cast<int>(lhs) ^ static_cast<int>(rhs));
76}
77
78constexpr CanError
79operator|(CanError lhs, CanError rhs) {
80 return static_cast<CanError>(static_cast<int>(lhs) | static_cast<int>(rhs));
81}
82
83inline CanError&
84operator&=(CanError& lhs, CanError rhs) {
85 return lhs = lhs & rhs;
86}
87
88inline CanError&
89operator^=(CanError& lhs, CanError rhs) {
90 return lhs = lhs ^ rhs;
91}
92
93inline CanError&
94operator|=(CanError& lhs, CanError rhs) {
95 return lhs = lhs | rhs;
96}
97
98} // namespace io
99} // namespace lely
100
101#endif // !LELY_IO2_CAN_ERR_HPP_
@ CAN_STATE_BUSOFF
The bus off state (TX/RX error count >= 256).
Definition err.h:34
@ CAN_STATE_PASSIVE
The error passive state (TX/RX error count < 256).
Definition err.h:32
@ CAN_STATE_ACTIVE
The error active state (TX/RX error count < 128).
Definition err.h:30
A CANopen value.
Definition val.hpp:42
CanError
The error flags of a CAN bus, which are not mutually exclusive.
Definition err.hpp:47
@ OTHER
One or more other errors.
@ FORM
A form error.
@ ACK
An acknowledgment error.
@ CRC
A CRC sequence error.
@ STUFF
A bit stuffing error.
@ BIT
A single bit error.
CanState
The states of a CAN node, depending on the TX/RX error count.
Definition err.hpp:33
@ STOPPED
The device is stopped.
@ ACTIVE
The error active state (TX/RX error count < 128).
@ BUSOFF
The bus off state (TX/RX error count >= 256).
@ SLEEPING
The device is in sleep mode.
@ PASSIVE
The error passive state (TX/RX error count < 256).
This header file is part of the I/O library; it contains CAN bus error definitions.