ReduxLib C++ 2026.1.2
Loading...
Searching...
No Matches
CanandcolorFaults.h
1// Copyright (c) Bagholders of Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the Mozilla Public License v2.0.
3
4#pragma once
5#include <cinttypes>
6
8
9/**
10 * Canandcolor fault flags (active or sticky).
11 *
12 * Use Canandcolor::GetActiveFaults() and Canandcolor::GetStickyFaults() to retrieve these.
13 */
15 public:
16 /**
17 * @param field fault bitfield
18 * @param valid true if valid
19 */
20 constexpr CanandcolorFaults(uint8_t field, bool valid) :
21 powerCycle(field & 0b1),
22 canIDConflict(field & 0b10),
23 canGeneralError(field & 0b100),
24 outOfTemperatureRange(field & 0b1000),
25 hardwareFaultProximity(field & 0b10000),
26 hardwareFaultColor(field & 0b100000),
27 i2cBusRecovery(field & 0b1000000),
28 faultsValid(valid) {};
29
30 /** The power cycle flag is set on device boot until sticky faults are cleared. */
32 /** CAN ID conflict detected. */
34 /** CAN general error detected (often wiring/intermittent bus issues). */
36 /** Temperature out of expected range. */
38 /** Proximity sensor hardware fault. */
40 /** Color sensor hardware fault. */
42 /** I2C bus recovery occurred. */
44 /** Whether this fault set is valid (i.e. a status frame has been received). */
46};
47
48} // namespace redux::sensors::canandcolor
Definition CanandcolorFaults.h:14
bool canGeneralError
Definition CanandcolorFaults.h:35
bool i2cBusRecovery
Definition CanandcolorFaults.h:43
bool hardwareFaultProximity
Definition CanandcolorFaults.h:39
bool outOfTemperatureRange
Definition CanandcolorFaults.h:37
bool canIDConflict
Definition CanandcolorFaults.h:33
bool hardwareFaultColor
Definition CanandcolorFaults.h:41
bool powerCycle
Definition CanandcolorFaults.h:31
bool faultsValid
Definition CanandcolorFaults.h:45
constexpr CanandcolorFaults(uint8_t field, bool valid)
Definition CanandcolorFaults.h:20
Definition Canandcolor.h:19