uds.can.first_frame =================== .. py:module:: uds.can.first_frame .. autoapi-nested-parse:: Implementation specific for First Frame CAN packets. This module contains implementation specific for :ref:`First Frame ` packets - that includes :ref:`First Frame Data Length (FF_DL) ` parameter. Classes ------- .. autoapisummary:: uds.can.first_frame.CanFirstFrameHandler Module Contents --------------- .. py:class:: CanFirstFrameHandler Helper class that provides utilities for First Frame CAN Packets. .. py:attribute:: FIRST_FRAME_N_PCI :type: int :value: 1 First Frame N_PCI value. .. py:attribute:: MAX_SHORT_FF_DL_VALUE :type: int :value: 4095 Maximum value of :ref:`First Frame Data Length (FF_DL) ` for which short format of FF_DL is used. .. py:attribute:: MAX_LONG_FF_DL_VALUE :type: int :value: 4294967295 Maximum value of :ref:`First Frame Data Length (FF_DL) `. .. py:attribute:: SHORT_FF_DL_BYTES_USED :type: int :value: 2 Number of CAN Frame data bytes used to carry CAN Packet Type and First Frame Data Length (FF_DL). This value is valid only for the short format using FF_DL <= 4095. .. py:attribute:: LONG_FF_DL_BYTES_USED :type: int :value: 6 Number of CAN Frame data bytes used to carry CAN Packet Type and First Frame Data Length (FF_DL). This value is valid only for the long format using FF_DL > 4095. .. py:method:: create_valid_frame_data(*, addressing_format, payload, dlc, ff_dl, target_address = None, address_extension = None) :classmethod: Create a data field of a CAN frame that carries a valid First Frame packet. .. note:: This method can only be used to create a valid (compatible with ISO 15765 - Diagnostic on CAN) output. Use :meth:`~uds.can.first_frame.CanFirstFrameHandler.create_any_frame_data` to create data bytes for a First Frame with any (also incompatible with ISO 15765) parameters values. :param addressing_format: CAN addressing format used by a considered First Frame. :param payload: Payload of a diagnostic message that is carried by a considered CAN packet. :param dlc: DLC value of a CAN frame that carries a considered CAN Packet. :param ff_dl: Value of First Frame Data Length parameter that is carried by a considered CAN packet. :param target_address: Target Address value carried by this CAN Packet. The value must only be provided if `addressing_format` uses Target Address parameter. :param address_extension: Address Extension value carried by this CAN packet. The value must only be provided if `addressing_format` uses Address Extension parameter. :raise InconsistentArgumentsError: Provided `payload` contains incorrect number of bytes to fit them into a First Frame data field using provided parameters. :return: Raw bytes of CAN frame data for the provided First Frame packet information. .. py:method:: create_any_frame_data(*, addressing_format, payload, dlc, ff_dl, long_ff_dl_format = False, target_address = None, address_extension = None) :classmethod: Create a data field of a CAN frame that carries a First Frame packet. .. note:: You can use this method to create First Frame data bytes with any (also inconsistent with ISO 15765) parameters values. It is recommended to use :meth:`~uds.can.first_frame.CanFirstFrameHandler.create_valid_frame_data` to create data bytes for a First Frame with valid (compatible with ISO 15765) parameters values. :param addressing_format: CAN addressing format used by a considered First Frame. :param payload: Payload of a diagnostic message that is carried by a considered CAN packet. :param dlc: DLC value of a CAN frame that carries a considered CAN Packet. :param ff_dl: Value of First Frame Data Length parameter that is carried by a considered CAN packet. :param long_ff_dl_format: Information whether to use long or short format of First Frame Data Length. :param target_address: Target Address value carried by this CAN Packet. The value must only be provided if `addressing_format` uses Target Address parameter. :param address_extension: Address Extension value carried by this CAN packet. The value must only be provided if `addressing_format` uses Address Extension parameter. :raise InconsistentArgumentsError: Provided `payload` contains incorrect number of bytes to fit them into a First Frame data field using provided parameters. :return: Raw bytes of CAN frame data for the provided First Frame packet information. .. py:method:: is_first_frame(addressing_format, raw_frame_data) :classmethod: Check if provided data bytes encodes a First Frame packet. .. warning:: The method does not validate the content (e.g. FF_DL parameter) of the packet. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a CAN frame to check. :return: True if provided data bytes carries First Frame, False otherwise. .. py:method:: decode_payload(addressing_format, raw_frame_data) :classmethod: Extract a value of payload from First Frame data bytes. .. warning:: The method does not validate the content of the provided frame data bytes. There is no guarantee of the proper output when frame data in invalid format (incompatible with ISO 15765) is provided. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a considered CAN frame. :return: Payload bytes of a diagnostic message carried by a considered First Frame. .. py:method:: decode_ff_dl(addressing_format, raw_frame_data) :classmethod: Extract a value of First Frame Data Length from First Frame data bytes. .. warning:: The method does not validate the content of the provided frame data bytes. There is no guarantee of the proper output when frame data in invalid format (incompatible with ISO 15765) is provided. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a considered CAN frame. :raise NotImplementedError: There is missing implementation for the provided First Frame Data Length format. Please create an issue in our `Issues Tracking System `_ with detailed description if you face this error. :return: Extracted value of First Frame Data Length. .. py:method:: get_payload_size(addressing_format, dlc, long_ff_dl_format = False) :classmethod: Get the size of a payload that can fit into First Frame data bytes. :param addressing_format: CAN addressing format that considered CAN packet uses. :param dlc: DLC value of a CAN frame that carries a considered CAN Packet. :param long_ff_dl_format: Information whether to use long or short format of First Frame Data Length. :raise ValueError: First Frame packet cannot use provided attributes according to ISO 15765. :return: The maximum number of payload bytes that could fit into a considered First Frame. .. py:method:: validate_frame_data(addressing_format, raw_frame_data) :classmethod: Validate whether data field of a CAN Packet carries a properly encoded First Frame. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a CAN frame to validate. :raise ValueError: Provided frame data of a CAN frames does not carry a First Frame CAN packet. .. py:method:: validate_ff_dl(ff_dl, long_ff_dl_format = None, dlc = None, addressing_format = None) :classmethod: Validate a value of First Frame Data Length. :param ff_dl: First Frame Data Length value to validate. :param long_ff_dl_format: Information whether long or short format of First Frame Data Length is used. - None - do not perform compatibility check with the FF_DL format - True - perform compatibility check with long FF_DL format - False - perform compatibility check with short FF_DL format :param dlc: Value of DLC to use for First Frame Data Length value validation. Leave None if you do not want to validate whether First Frame shall be used in this case. :param addressing_format: Value of CAN Addressing Format to use for First Frame Data Length value validation. Leave None if you do not want to validate whether First Frame shall be used in this case. :raise TypeError: Provided value of First Frame Data Length is not int type. :raise ValueError: Provided value of First Frame Data Length is out of range (0 <= value <= MAX FF_DL). :raise InconsistentArgumentsError: Single Frame shall be used instead of First Frame to transmit provided number of payload bytes represented by FF_DL value. .. py:method:: __extract_ff_dl_data_bytes(addressing_format, raw_frame_data) :classmethod: Extract data bytes that carries CAN Packet Type and First Frame Data Length parameters. .. warning:: This method does not check whether provided `raw_frame_data` actually contains First Frame. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a considered CAN frame. :return: Extracted data bytes with CAN Packet Type and First Frame Data Length parameters. .. py:method:: __encode_valid_ff_dl(ff_dl, dlc, addressing_format) :classmethod: Create First Frame data bytes with CAN Packet Type and First Frame Data Length parameters. .. note:: This method can only be used to create a valid (compatible with ISO 15765 - Diagnostic on CAN) output. First Frame Data Length value validation (whether it is too low according to ISO 15765) is not performed though. :param ff_dl: Value to put into a slot of First Frame Data Length. :param dlc: Value of DLC to use for First Frame Data Length value validation. :param addressing_format: Value of CAN Addressing Format to use for First Frame Data Length value validation. :return: First Frame data bytes containing CAN Packet Type and First Frame Data Length parameters. .. py:method:: __encode_any_ff_dl(ff_dl, long_ff_dl_format = False) :classmethod: Create First Frame data bytes with CAN Packet Type and First Frame Data Length parameters. .. note:: This method can be used to create any (also incompatible with ISO 15765 - Diagnostic on CAN) output. :param ff_dl: Value to put into a slot of First Frame Data Length. :param long_ff_dl_format: Information whether to use long or short format of First Frame Data Length. :raise ValueError: Provided First Frame Data Length value is out of the parameter values range. :raise InconsistentArgumentsError: Provided First Frame Data Length value cannot fit into the short format. :return: First Frame data bytes containing CAN Packet Type and First Frame Data Length parameters.