:py:mod:`phoenix6.canbus` ========================= .. py:module:: phoenix6.canbus Module Contents --------------- Attributes ~~~~~~~~~~ .. autoapisummary:: phoenix6.canbus.USE_WPILIB .. py:data:: USE_WPILIB :value: 'True' .. py:class:: CANBusStatus Contains status information about a CAN bus. .. py:attribute:: status :type: phoenix6.status_code.StatusCode Status code response of getting the data .. py:attribute:: bus_utilization :type: float :value: '0' CAN bus utilization, from 0.0 to 1.0 .. py:attribute:: bus_off_count :type: int :value: '0' Bus off count .. py:attribute:: tx_full_count :type: int :value: '0' Transmit buffer full count .. py:attribute:: rec :type: int :value: '0' Receive Error Counter (REC) .. py:attribute:: tec :type: int :value: '0' Transmit Error Counter (TEC) .. py:class:: CANBus(canbus: str = '', hoot_filepath: str | None = None) Class for getting information about an available CAN bus. A CANBus can optionally be constructed with an associated hoot file, which loads it for replay (equivalent to calling HootReplay.load_file). Only one hoot log may be replayed at a time, so 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 roboRIO CAN bus, use CANBus.roborio(str | None) instead. :param canbus: Name of the CAN bus. Possible CAN bus strings are: - "rio" for the native roboRIO CAN bus - 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: - "rio" on roboRIO - "can0" on Linux - "*" on Windows :type canbus: str, optional :param hoot_filepath: Path and name of the hoot file to load :type hoot_filepath: str | None, optional .. py:property:: name :type: str Get the name used to construct this CAN bus. :returns: Name of the CAN bus :rtype: str .. py:method:: roborio(hoot_filepath: str | None = None) -> CANBus :staticmethod: Creates a new CAN bus for the native roboRIO bus. The CANBus can optionally be constructed with an associated hoot file, which loads it for replay (equivalent to calling HootReplay.load_file). Only one hoot log may be replayed at a time, so 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. :param hoot_filepath: Path and name of the hoot file to load :type hoot_filepath: str | None, optional :returns: The native roboRIO CAN bus :rtype: CANBus .. py:method:: is_network_fd() -> bool Gets whether the CAN bus is a CAN FD network. :returns: True if the CAN bus is CAN FD :rtype: bool .. py:method:: get_status() -> CANBusStatus 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 :rtype: CANBusStatus