ReduxLib C++ 2024.3.2
Loading...
Searching...
No Matches
CANBus.h
1// Copyright (c) Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the 3-clause BSD license.
3
4#pragma once
5#include <stdint.h>
6
7namespace redux::canand {
8/**
9 * Class representing CAN buses that may exist on a robot.
10 *
11 * <b>Currently, only the Rio's onboard CAN bus is supported.</b>
12 *
13*/
14class CANBus {
15 public:
16
17 /**
18 * Constructs a new CAN bus from a descriptor value. 0 is the Rio's onboard bus.
19 * @param descriptorId the CAN bus descriptor value.
20 */
21 inline CANBus(uint8_t descriptorId) { fd = descriptorId; }
22 virtual ~CANBus() = default;
23
24 /**
25 * Returns the descriptor ID associated with the CAN bus object.
26 * Generally not needed to be used directly.
27 * @return the descriptor ID.
28 */
29 inline uint8_t GetDescriptor() { return fd; }
30
31 /**
32 * Returns whether two CANBus objects refer to the same bus.
33 * @param other other CANBus object to compare against
34 * @return whether or not they refer to the same bus
35 */
36 inline bool Equals(CANBus other) { return GetDescriptor() == other.GetDescriptor(); }
37 private:
38 uint8_t fd;
39};
40}
Definition: CANBus.h:14
CANBus(uint8_t descriptorId)
Definition: CANBus.h:21
uint8_t GetDescriptor()
Definition: CANBus.h:29
bool Equals(CANBus other)
Definition: CANBus.h:36
Definition: CanandMessage.h:10