10#include <wpi/hardware/bus/CANPort.hpp>
11#include <wpi/units/dimensionless.hpp>
82 default:
return "Invalid Value";
144 std::string_view _name;
146 static constexpr std::string_view GetCANPortName(wpi::CANPort canPort)
149 case wpi::CANPort::CAN_S0:
return "can_s0";
150 case wpi::CANPort::CAN_S1:
return "can_s1";
151 case wpi::CANPort::CAN_S2:
return "can_s2";
152 case wpi::CANPort::CAN_S3:
return "can_s3";
153 case wpi::CANPort::CAN_S4:
return "can_s4";
154 case wpi::CANPort::CAN_D0:
return "can_d0";
155 case wpi::CANPort::CAN_D1:
return "can_d1";
156 case wpi::CANPort::CAN_D2:
return "can_d2";
157 case wpi::CANPort::CAN_D3:
return "can_d3";
158 case wpi::CANPort::CAN_D4:
return "can_d4";
159 case wpi::CANPort::CAN_D5:
return "can_d5";
160 case wpi::CANPort::CAN_D6:
return "can_d6";
161 case wpi::CANPort::CAN_D7:
return "can_d7";
162 case wpi::CANPort::CAN_D8:
return "can_d8";
163 case wpi::CANPort::CAN_D9:
return "can_d9";
164 case wpi::CANPort::CAN_D10:
return "can_d10";
165 case wpi::CANPort::CAN_D11:
return "can_d11";
166 case wpi::CANPort::CAN_D12:
return "can_d12";
167 case wpi::CANPort::CAN_D13:
return "can_d13";
168 case wpi::CANPort::CAN_D14:
return "can_d14";
169 case wpi::CANPort::CAN_D15:
return "can_d15";
170 case wpi::CANPort::CAN_D16:
return "can_d16";
171 case wpi::CANPort::CAN_D17:
return "can_d17";
172 case wpi::CANPort::CAN_D18:
return "can_d18";
173 case wpi::CANPort::CAN_D19:
return "can_d19";
174 default:
throw std::invalid_argument{
"Unexpected Systemcore CAN port " + std::to_string((
int)canPort)};
195 constexpr CANBus(std::string_view canbus =
"") :
208 CANBus{GetCANPortName(canPort)}
247struct std::hash<
ctre::phoenix6::CANBus> {
250 return std::hash<std::string_view>{}(canbus.GetName());
254#include <wpi/util/struct/Struct.hpp>
258struct wpi::util::Struct<
ctre::phoenix6::CANBusStatus> final {
259 static constexpr std::string_view
GetTypeName() {
return "ctre_CANBusStatus"; }
262 return wpi::util::GetStructSize<int32_t>() +
263 wpi::util::GetStructSize<float>() +
264 5 * wpi::util::GetStructSize<uint32_t>() +
265 2 * wpi::util::GetStructSize<uint16_t>() +
266 wpi::util::GetStructSize<int32_t>();
270 return "int32 Status;"
271 "float BusUtilization;"
272 "uint32 BusErrorCount;"
273 "uint32 ArbitrationLostCount;"
274 "uint32 RestartCount;"
275 "uint32 BusOffCount;"
276 "uint32 TxFullCount;"
279 "enum{ErrorActive=0,ErrorWarning=1,ErrorPassive=2,BusOff=3,Stopped=4,Sleeping=5} int32 State";
286static_assert(wpi::util::StructSerializable<ctre::phoenix6::CANBusStatus>);
its the or e mails sent from or on behalf of the Company are free of trojan timebombs or other harmful components Some jurisdictions do not allow the exclusion of certain types of warranties or limitations on applicable statutory rights of a so some or all of the above exclusions and limitations may not apply to You But in such a case the exclusions and limitations set forth in this section shall be applied to the greatest extent enforceable under applicable law To the extent any warranty exists under law that cannot be the Company shall be solely responsible for such warranty Severability and Waiver Severability If any provision of this Agreement is held to be unenforceable or such provision will be changed and interpreted to accomplish the objectives of such provision to the greatest extent possible under applicable law and the remaining provisions will continue in full force and effect Waiver Except as provided the failure to exercise a right or to require performance of an obligation under this Agreement shall not affect a party s ability to exercise such right or require such performance at any time thereafter nor shall the waiver of a breach constitute waiver of any subsequent breach Product Claims The Company does not make any warranties concerning the Software United States Legal Compliance You represent and warrant or that has been designated by the United States government as a terrorist supporting at its sole to modify or replace this Agreement at any time If a revision is material we will provide at least days notice prior to any new terms taking effect What constitutes a material change will be determined at the sole discretion of the Company By continuing to access or use the Software after any revisions become You agree to be bound by the revised terms If You do not agree to the new You are no longer authorized to use the Software Governing Law The laws of the State of United States of excluding its conflicts of law shall govern this Agreement and your use of the Software Your use of the Software may also be subject to other state
Definition CTRE_LICENSE.txt:308
Class for getting information about an available CAN bus.
Definition CANBus.hpp:142
CANBusStatus GetStatus() const
Gets the status of the CAN bus, including the bus utilization and the error counters.
constexpr friend bool operator==(CANBus const &, CANBus const &)=default
constexpr CANBus(wpi::CANPort canPort)
Creates a new CAN bus for one of the native Systemcore/Motioncore buses.
Definition CANBus.hpp:207
constexpr CANBus(std::string_view canbus="")
Creates a new CAN bus with the given name.
Definition CANBus.hpp:195
friend std::ostream & operator<<(std::ostream &os, CANBus const &canbus)
constexpr friend auto operator<=>(CANBus const &, CANBus const &)=default
bool IsNetworkFD() const
Gets whether the CAN bus is a CAN FD network.
constexpr std::string_view GetName() const
Get the name used to construct this CAN bus.
Definition CANBus.hpp:216
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14
Contains status information about a CAN bus.
Definition CANBus.hpp:92
uint32_t ArbitrationLostCount
Arbitration lost count.
Definition CANBus.hpp:109
ctre::phoenix::StatusCode Status
Status code response of getting the data.
Definition CANBus.hpp:96
uint32_t RestartCount
Restart count.
Definition CANBus.hpp:113
CANState State
CAN state.
Definition CANBus.hpp:133
uint32_t BusErrorCount
Bus error count.
Definition CANBus.hpp:105
uint32_t BusOffCount
Bus off count.
Definition CANBus.hpp:117
uint16_t REC
Receive Error Counter (REC).
Definition CANBus.hpp:125
uint32_t TxFullCount
Transmit buffer full count.
Definition CANBus.hpp:121
uint16_t TEC
Transmit Error Counter (TEC).
Definition CANBus.hpp:129
friend std::ostream & operator<<(std::ostream &os, CANBusStatus const &status)
std::string ToString() const
wpi::units::unit_t< wpi::units::scalar, float > BusUtilization
CAN bus utilization, from 0.0 to 1.0.
Definition CANBus.hpp:101
Possible states of the CAN bus.
Definition CANBus.hpp:22
static constexpr int BusOff
The controller is in the "Bus Off" state after detecting too many errors.
Definition CANBus.hpp:41
static constexpr int Stopped
The controller has been manually stopped.
Definition CANBus.hpp:45
constexpr CANState()
Definition CANBus.hpp:55
constexpr auto operator<=>(CANState other) const
Definition CANBus.hpp:63
friend std::ostream & operator<<(std::ostream &os, CANState state)
constexpr std::string_view ToString() const
Gets the string representation of this enum.
Definition CANBus.hpp:73
constexpr CANState(int value)
Definition CANBus.hpp:51
static constexpr int ErrorPassive
The controller is in the "Error Passive" state and has detected many errors.
Definition CANBus.hpp:37
static constexpr int ErrorActive
The controller is in normal operation.
Definition CANBus.hpp:29
static constexpr int ErrorWarning
The controller has detected errors and is approaching the Error Passive state.
Definition CANBus.hpp:33
constexpr bool operator==(CANState other) const
Definition CANBus.hpp:59
static constexpr int Sleeping
The controller has entered low-power sleep mode.
Definition CANBus.hpp:49
int value
Unique integer value of this CANState.
Definition CANBus.hpp:24
size_t operator()(ctre::phoenix6::CANBus const &canbus) const noexcept
Definition CANBus.hpp:248
static constexpr std::string_view GetTypeName()
Definition CANBus.hpp:259
static constexpr std::string_view GetSchema()
Definition CANBus.hpp:268
static ctre::phoenix6::CANBusStatus Unpack(std::span< uint8_t const > data)
static constexpr size_t GetSize()
Definition CANBus.hpp:260
static void Pack(std::span< uint8_t > data, ctre::phoenix6::CANBusStatus const &value)