CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
ctre::phoenix6::CANBus Class Reference

Class for getting information about an available CAN bus. More...

#include <ctre/phoenix6/CANBus.hpp>

Public Member Functions

constexpr CANBus (std::string_view canbus="")
 Creates a new CAN bus with the given name.
constexpr CANBus (wpi::CANPort canPort)
 Creates a new CAN bus for one of the native Systemcore/Motioncore buses.
constexpr std::string_view GetName () const
 Get the name used to construct this CAN bus.
bool IsNetworkFD () const
 Gets whether the CAN bus is a CAN FD network.
CANBusStatus GetStatus () const
 Gets the status of the CAN bus, including the bus utilization and the error counters.

Friends

std::ostream & operator<< (std::ostream &os, CANBus const &canbus)
constexpr friend bool operator== (CANBus const &, CANBus const &)=default
constexpr friend auto operator<=> (CANBus const &, CANBus const &)=default

Detailed Description

Class for getting information about an available CAN bus.

Constructor & Destructor Documentation

◆ CANBus() [1/2]

ctre::phoenix6::CANBus::CANBus ( std::string_view canbus = "")
inlineconstexpr

Creates a new CAN bus with the given name.

For the native Systemcore/Motioncore CAN buses, use CANBus(wpi::CANPort) instead.

Parameters
canbusName of the CAN bus. Possible CAN bus strings are:
  • "can_s0" to "can_s4" for the native Systemcore CAN buses
  • "can_d0" to "can_d19" for the Motioncore CAN buses
  • CANivore name or serial number
  • SocketCAN interface (non-FRC Linux only)
  • "*" for any CANivore seen by the program
  • empty string (default) to select the default for the system:
    • "can_s2" on Systemcore
    • "can0" on Linux
    • "*" on Windows

◆ CANBus() [2/2]

ctre::phoenix6::CANBus::CANBus ( wpi::CANPort canPort)
inlineconstexpr

Creates a new CAN bus for one of the native Systemcore/Motioncore buses.

For the CANivore and non-FRC SocketCAN interfaces, use CANBus(std::string_view) instead.

Parameters
canPortThe Systemcore/Motioncore CAN port

Member Function Documentation

◆ GetName()

std::string_view ctre::phoenix6::CANBus::GetName ( ) const
inlineconstexpr

Get the name used to construct this CAN bus.

Returns
Name of the CAN bus

◆ GetStatus()

CANBusStatus ctre::phoenix6::CANBus::GetStatus ( ) const

Gets the status of the CAN bus, including the bus utilization and the error counters.

This can block for up to 0.001 seconds (1 ms).

Returns
Status of the CAN bus

◆ IsNetworkFD()

bool ctre::phoenix6::CANBus::IsNetworkFD ( ) const

Gets whether the CAN bus is a CAN FD network.

Returns
True if the CAN bus is CAN FD

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
CANBus const & canbus )
friend

◆ operator<=>

friend auto operator<=> ( CANBus const & ,
CANBus const &  )
friend

◆ operator==

friend bool operator== ( CANBus const & ,
CANBus const &  )
friend

The documentation for this class was generated from the following file: