:py:mod:`phoenix6.signal_logger` ================================ .. py:module:: phoenix6.signal_logger Module Contents --------------- Attributes ~~~~~~~~~~ .. autoapisummary:: phoenix6.signal_logger.USE_WPILIB phoenix6.signal_logger.T .. py:data:: USE_WPILIB :value: 'True' .. py:data:: T .. py:class:: SignalLogger Static class for controlling the Phoenix 6 signal logger. This logs all the signals from the CAN buses into .hoot files. Each file name starts with the CANivore serial number or "can_s0" to "can_s4" for the Systemcore CAN buses, followed by the timestamp. In the header of a hoot file, the CANivore name and firmware version are logged in plain text. During an FRC match, the log file will be renamed to include the event name, match type, and match number at the start of the file name. The match type will be 'P' for practice matches, 'Q' for qualification matches, and 'E' for elimination matches. During Hoot Replay, the signal logger always runs while replay is running. All custom signals written during replay will be automatically placed under `hoot_replay/`. Additionally, the log will contain all status signals and custom signals from the original log. .. py:method:: set_path(path: str) -> phoenix6.status_code.StatusCode :staticmethod: Sets the destination for logging, restarting logger if the path changed. If this is not called or the path is left empty, the default path will be used. The default path on the Systemcore is a logs folder on the first USB flash drive found, or /home/systemcore/logs if none is available. The default path on all other platforms is a logs folder in the current working directory. Typical use for this routine is to use a removable USB flash drive for logging. This is ignored during Hoot Replay, where the hoot log will always be written to a subfolder next to the log being replayed. :param path: Folder path for the log files; path must exist :type path: str :returns: Status of setting the path and restarting the log :rtype: StatusCode .. py:method:: start() -> phoenix6.status_code.StatusCode :staticmethod: Starts logging status signals. Starts regardless of auto logging status. This is ignored during Hoot Replay, where logging is automatically started when Hoot Replay starts running or restarts. :returns: Status of starting the logger :rtype: StatusCode .. py:method:: stop() -> phoenix6.status_code.StatusCode :staticmethod: Stops logging status signals. Stops regardless of auto logging status. This is ignored during Hoot Replay, where logging is automatically stopped when Hoot Replay is stopped or reaches the end of the file. :returns: Status of stopping the logger :rtype: StatusCode .. py:method:: enable_auto_logging(enable: bool) -> phoenix6.status_code.StatusCode :staticmethod: Enables or disables auto logging. Auto logging is enabled by default on the Systemcore and disabled by default on other systems. When auto logging is enabled, logging is started by any of the following (whichever occurs first): - It has been at least 1 second since program startup (allowing for calls to self.set_path), and the robot is enabled. - It has been at least 5 seconds since program startup (allowing for calls to self.set_path), and the Driver Station is connected to the robot (if on a Systemcore). After auto logging has started the log once, logging will not be automatically stopped or restarted by auto logging. :param enable: Whether to enable auto logging :type enable: bool :returns: Status of auto logging enable/disable :rtype: StatusCode .. py:method:: add_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, schema: bytes | str) -> phoenix6.status_code.StatusCode :staticmethod: Adds the schema to the log file. In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct values instead. The schema name should typically exactly match the name of the type (without any extra prefix or suffix). For protobuf, first register all relevant file descriptors by file name (such as "geometry2d.proto"). Then, for each top-level type being used, add a separate empty schema with the full name of the type (such as "wpi.proto.ProtobufPose2d"). :param name: Name of the schema :type name: str :param schema_type: Type of the schema, such as struct or protobuf :type schema_type: HootSchemaType :param schema: Schema bytes or string to write :type data: bytes :returns: Status of adding the schema :rtype: StatusCode .. py:method:: has_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType) -> bool :staticmethod: Checks if the schema has already been added to the log files. :param name: Name of the schema :type name: str :param schema_type: Type of the schema, such as struct or protobuf :type schema_type: HootSchemaType :returns: Whether the schema has been added to the log files :rtype: bool .. py:method:: write_schema_value(name: str, schema: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, data: bytes, latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the schema-serialized bytes to the log file. In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct values instead. The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with self.add_schema before calling this API. :param name: Name of the signal :type name: str :param schema: Name of the associated schema :type schema: str :param schema_type: Type of the associated schema, such as struct or protobuf :type schema_type: HootSchemaType :param data: Serialized data bytes :type data: bytes :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_struct(name: str, struct: type[T], value: T, latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :classmethod: Writes the WPILib Struct to the log file. :param name: Name of the signal :type name: str :param struct: Type of struct to serialize :type struct: type[T] :param value: Value to write :type value: T :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_struct_array(name: str, struct: type[T], values: list[T], latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :classmethod: Writes the array of WPILib Structs to the log file. :param name: Name of the signal :type name: str :param struct: Type of struct to serialize :type struct: type[T] :param values: Values to write :type values: list[T] :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_raw(name: str, data: bytes, latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the raw data bytes to the log file. :param name: Name of the signal :type name: str :param data: Raw data bytes :type data: bytes :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_boolean(name: str, value: bool, latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the boolean to the log file. :param name: Name of the signal :type name: str :param value: Value to write :type data: bool :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_integer(name: str, value: int, units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the integer to the log file. :param name: Name of the signal :type name: str :param value: Value to write :type data: int :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_float(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the float to the log file. :param name: Name of the signal :type name: str :param value: Value to write :type data: float :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_double(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the double to the log file. :param name: Name of the signal :type name: str :param value: Value to write :type data: float :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_string(name: str, value: str, latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the string to the log file. :param name: Name of the signal :type name: str :param value: Value to write :type data: bool :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_boolean_array(name: str, value: list[bool], latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the array of booleans to the log file. :param name: Name of the signal :type name: str :param value: Array of values to write :type value: list[bool] :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_integer_array(name: str, value: list[int], units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the array of integers to the log file. :param name: Name of the signal :type name: str :param value: Array of values to write :type value: list[int] :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_float_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the array of floats to the log file. :param name: Name of the signal :type name: str :param value: Array of values to write :type value: list[float] :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_double_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the array of doubles to the log file. :param name: Name of the signal :type name: str :param value: Array of values to write :type value: list[float] :param units: Units of the signal :type units: str :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode .. py:method:: write_string_array(name: str, value: list[str], latency_seconds: phoenix6.units.second = 0) -> phoenix6.status_code.StatusCode :staticmethod: Writes the array of strings to the log file. :param name: Name of the signal :type name: str :param value: Array of values to write :type value: list[str] :param latency_seconds: Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log :type latency_seconds: second :returns: Status of writing the data :rtype: StatusCode