CTRE Phoenix 6 C++ 24.3.0
CANBus.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10#include <string>
11
12namespace ctre {
13namespace phoenix6 {
14
15/**
16 * \brief Static class for getting information about available CAN buses.
17 */
18class CANBus {
19public:
20 /**
21 * \brief Contains status information about a CAN bus.
22 */
23 struct CANBusStatus {
24 /**
25 * \brief Status code response of getting the data
26 */
27 ctre::phoenix::StatusCode Status;
28
29 /**
30 * \brief CAN bus utilization, from 0.0 to 1.0
31 */
33 /**
34 * \brief Bus off count
35 */
36 uint32_t BusOffCount;
37 /**
38 * \brief Transmit buffer full count
39 */
40 uint32_t TxFullCount;
41 /**
42 * \brief Receive Error Counter (REC)
43 */
44 uint32_t REC;
45 /**
46 * \brief Transmit Error Counter (TEC)
47 */
48 uint32_t TEC;
49 };
50
51 /**
52 * \brief Gets whether the CAN bus is a CAN FD network.
53 *
54 * \param canbus Name of the CAN bus
55 * \returns True if the CAN bus is CAN FD
56 */
57 static bool IsNetworkFD(std::string const &canbus);
58 /**
59 * \brief Gets the status of the CAN bus, including the
60 * bus utilization and the error counters.
61 *
62 * \param canbus Name of the CAN bus
63 * \returns Status of the CAN bus
64 */
65 static CANBusStatus GetStatus(std::string const &canbus);
66};
67
68}
69}
Static class for getting information about available CAN buses.
Definition: CANBus.hpp:18
static bool IsNetworkFD(std::string const &canbus)
Gets whether the CAN bus is a CAN FD network.
static CANBusStatus GetStatus(std::string const &canbus)
Gets the status of the CAN bus, including the bus utilization and the error counters.
Definition: string_util.hpp:15
Contains status information about a CAN bus.
Definition: CANBus.hpp:23
uint32_t TxFullCount
Transmit buffer full count.
Definition: CANBus.hpp:40
ctre::phoenix::StatusCode Status
Status code response of getting the data.
Definition: CANBus.hpp:27
float BusUtilization
CAN bus utilization, from 0.0 to 1.0.
Definition: CANBus.hpp:32
uint32_t BusOffCount
Bus off count.
Definition: CANBus.hpp:36
uint32_t REC
Receive Error Counter (REC)
Definition: CANBus.hpp:44
uint32_t TEC
Transmit Error Counter (TEC)
Definition: CANBus.hpp:48