uds.can.packet.consecutive_frame ================================ .. py:module:: uds.can.packet.consecutive_frame .. autoapi-nested-parse:: Implementation of handlers for :ref:`Consecutive Frame ` CAN packet. Attributes ---------- .. autoapisummary:: uds.can.packet.consecutive_frame.CONSECUTIVE_FRAME_N_PCI uds.can.packet.consecutive_frame.SN_BYTES_USED Functions --------- .. autoapisummary:: uds.can.packet.consecutive_frame.is_consecutive_frame uds.can.packet.consecutive_frame.validate_consecutive_frame_data uds.can.packet.consecutive_frame.create_consecutive_frame_data uds.can.packet.consecutive_frame.generate_consecutive_frame_data uds.can.packet.consecutive_frame.extract_consecutive_frame_payload uds.can.packet.consecutive_frame.get_consecutive_frame_min_dlc uds.can.packet.consecutive_frame.get_consecutive_frame_max_payload_size uds.can.packet.consecutive_frame.extract_sequence_number uds.can.packet.consecutive_frame.encode_sequence_number Module Contents --------------- .. py:data:: CONSECUTIVE_FRAME_N_PCI :type: int :value: 2 :ref:`N_PCI ` value of :ref:`Consecutive Frame `. .. py:data:: SN_BYTES_USED :type: int :value: 1 Number of CAN Frame data bytes used to carry CAN Packet Type and Sequence Number (SN) in a Consecutive Frame. .. py:function:: is_consecutive_frame(addressing_format, raw_frame_data) Check if provided data bytes contain a Consecutive Frame packet. .. warning:: The method does not validate the content of the provided frame data bytes. It only checks :ref:`CAN Packet Type (N_PCI) ` parameter for Consecutive Frame N_PCI value. :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 Consecutive Frame, False otherwise. .. py:function:: validate_consecutive_frame_data(addressing_format, raw_frame_data) Validate whether data field of a CAN Packet carries a properly encoded Consecutive Frame. :param addressing_format: CAN Addressing Format used. :param raw_frame_data: Raw data bytes of a CAN frame to validate. :raise ValueError: The value of N_PCI in provided data is not Consecutive Frame N_PCI. :raise InconsistencyError: Provided data does not carry any payload. .. py:function:: create_consecutive_frame_data(addressing_format, payload, sequence_number, dlc = None, filler_byte = DEFAULT_FILLER_BYTE, target_address = None, address_extension = None) Create a data field of a CAN frame that carries a valid Consecutive Frame packet. .. note:: This method can only be used to create a valid (compatible with ISO 15765 - Diagnostic on CAN) output. Use :func:`~uds.can.packet.first_frame.generate_consecutive_frame_data` to generate data bytes with any (also incompatible with ISO 15765) parameters values. :param addressing_format: CAN addressing format used. :param payload: Payload to carry. :param sequence_number: Sequence Number value to set. :param dlc: DLC value of a CAN frame. - None - use CAN Data Frame Optimization (CAN ID value will be automatically determined) - int type value - DLC value to set. CAN Data Padding will be used to fill the unused data bytes. :param filler_byte: Filler Byte value to use for CAN Frame Data Padding. :param target_address: Target Address value carried by this CAN Packet. The value must only be provided if `addressing_format` requires CAN frame data field to contain Target Address parameter. :param address_extension: Address Extension value carried by this CAN packet. The value must only be provided if `addressing_format` requires CAN frame data field to contain Address Extension parameter. :raise InconsistencyError: Provided parameters cannot be used together to create a valid Consecutive Frame data. :return: Raw data bytes of a CAN frame. .. py:function:: generate_consecutive_frame_data(addressing_format, payload, sequence_number, dlc, filler_byte = DEFAULT_FILLER_BYTE, target_address = None, address_extension = None) Generate CAN frame data field that carries any combination of Consecutive Frame packet data parameters. .. note:: Crosscheck of provided values is not performed so you might use this function to create data fields that are not compatible with Diagnostic on CAN standard (ISO 15765). :param addressing_format: CAN addressing format used. :param payload: Payload to carry. :param dlc: DLC value of a CAN frame. :param sequence_number: Sequence Number value to set. :param filler_byte: Filler Byte value to use for CAN Frame Data Padding. :param target_address: Target Address value carried by this CAN Packet. The value must only be provided if `addressing_format` requires CAN frame data field to contain Target Address parameter. :param address_extension: Address Extension value carried by this CAN packet. The value must only be provided if `addressing_format` requires CAN frame data field to contain Address Extension parameter. :raise InconsistencyError: Provided `payload` contains invalid number of bytes. :return: Raw data bytes of a CAN frame. .. py:function:: extract_consecutive_frame_payload(addressing_format, raw_frame_data) Extract diagnostic message payload from Consecutive Frame data bytes. .. warning:: The output might contain filler bytes (they are not part of diagnostic message payload) that were added during :ref:`CAN Frame Data Padding `. The presence of filler bytes in :ref:`Consecutive Frame ` cannot be determined basing solely on the information contained in a Consecutive 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 (with potential Filler Bytes) carried by the provided Consecutive Frame data. .. py:function:: get_consecutive_frame_min_dlc(addressing_format, payload_length = 1) Get the minimum value of a CAN frame DLC to carry a Consecutive Frame packet. :param addressing_format: CAN addressing format used. :param payload_length: Number of payload bytes to carry. :raise TypeError: Provided value of Payload Length is not int type. :raise ValueError: Provided value of Payload Length is out of range. :return: The lowest value of DLC for a Consecutive Frame that would carry provided payload size. .. py:function:: get_consecutive_frame_max_payload_size(addressing_format, dlc = None) Get the maximum payload size that could be carried by a Consecutive Frame. :param addressing_format: CAN addressing format used. :param dlc: DLC value of a CAN frame that carries a considered CAN Packet. Leave None to get the result for the greatest possible DLC value. :raise InconsistencyError: Provided dlc cannot be used for Consecutive Frame with in the provided CAN Addressing Format. :return: The maximum number of payload bytes that could be carried in a Consecutive Frame. .. py:function:: extract_sequence_number(addressing_format, raw_frame_data) Extract the value of Sequence Number from Consecutive 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: Extracted value of Sequence Number. .. py:function:: encode_sequence_number(sequence_number) Create valid Consecutive Frame data bytes that contain Sequence Number and N_PCI values. :param sequence_number: Order value of a Consecutive Frame. :return: Consecutive Frame data bytes containing CAN Packet Type and Sequence Number parameters.