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

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

#include <ctre/phoenix6/CANBus.hpp>

Classes

struct  CANBusStatus
 Contains status information about a CAN bus. More...

Public Member Functions

constexpr CANBus (std::string_view canbus="")
 Creates a new CAN bus with the given name.
 CANBus (std::string_view canbus, char const *hootFilepath)
 Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).
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.

Static Public Member Functions

static constexpr CANBus Systemcore (int canbus)
 Creates a new CAN bus for one of the native Systemcore buses.
static CANBus Systemcore (int canbus, char const *hootFilepath)
 Creates a new CAN bus for one of the native Systemcore buses, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).
static constexpr CANBus Motioncore (int port)
 Creates a new CAN bus for one of the Motioncore ports.
static CANBus Motioncore (int port, char const *hootFilepath)
 Creates a new CAN bus for one of the Motioncore ports, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).

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 CAN buses, use Systemcore instead.

For the Motioncore CAN buses, use Motioncore instead.

Parameters
canbusName of the CAN bus. Possible CAN bus strings are:
  • "can_s0" to "can_s24" for the native Systemcore/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_s1" on Systemcore
    • "can0" on Linux
    • "*" on Windows

◆ CANBus() [2/2]

ctre::phoenix6::CANBus::CANBus ( std::string_view canbus,
char const * hootFilepath )
inline

Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).

Only one hoot log may be replayed at a time. As a result, only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

For the native Systemcore CAN buses, use Systemcore instead.

For the Motioncore CAN buses, use Motioncore instead.

Parameters
canbusName of the CAN bus. Possible CAN bus strings are:
  • "can_s0" to "can_s24" for the native Systemcore/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_s1" on Systemcore
    • "can0" on Linux
    • "*" on Windows
hootFilepathPath and name of the hoot file to load

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

◆ Motioncore() [1/2]

constexpr CANBus ctre::phoenix6::CANBus::Motioncore ( int port)
inlinestaticconstexpr

Creates a new CAN bus for one of the Motioncore ports.

Parameters
portThe Motioncore port, from 0-19
Returns
A Motioncore CAN bus

◆ Motioncore() [2/2]

CANBus ctre::phoenix6::CANBus::Motioncore ( int port,
char const * hootFilepath )
inlinestatic

Creates a new CAN bus for one of the Motioncore ports, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).

Only one hoot log may be replayed at a time. As a result, only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

Parameters
portThe Motioncore port, from 0-19
hootFilepathPath and name of the hoot file to load
Returns
A Motioncore CAN bus

◆ Systemcore() [1/2]

constexpr CANBus ctre::phoenix6::CANBus::Systemcore ( int canbus)
inlinestaticconstexpr

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

For the Motioncore CAN buses, use Motioncore instead.

Parameters
canbusIndex of the Systemcore bus, from 0-4
Returns
A native Systemcore CAN bus

◆ Systemcore() [2/2]

CANBus ctre::phoenix6::CANBus::Systemcore ( int canbus,
char const * hootFilepath )
inlinestatic

Creates a new CAN bus for one of the native Systemcore buses, and loads an associated hoot file for replay (equivalent to HootReplay::LoadFile).

Only one hoot log may be replayed at a time. As a result, only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

For the Motioncore CAN buses, use Motioncore instead.

Parameters
canbusIndex of the Systemcore bus, from 0-4
hootFilepathPath and name of the hoot file to load
Returns
A native Systemcore CAN bus

◆ 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: