diff --git a/tests/software_tests/can/test_addressing_information.py b/tests/software_tests/can/test_addressing_information.py index ef230bb2..27c48a09 100644 --- a/tests/software_tests/can/test_addressing_information.py +++ b/tests/software_tests/can/test_addressing_information.py @@ -249,6 +249,7 @@ def test_get_ai_data_bytes_number(self, mock_ai_mapping, addressing_format): mock_ai_mapping.__getitem__.assert_called_once_with(addressing_format) +@pytest.mark.integration class TestCanAddressingInformationIntegration: """Integration tests for `CanAddressingInformation` class.""" diff --git a/tests/software_tests/transport_interface/test_can_transport_interface.py b/tests/software_tests/transport_interface/test_can_transport_interface.py index 979e24ba..e6cda8a1 100644 --- a/tests/software_tests/transport_interface/test_can_transport_interface.py +++ b/tests/software_tests/transport_interface/test_can_transport_interface.py @@ -969,6 +969,7 @@ async def test_async_receive_packet(self, timeout): transmission_time=self.mock_datetime.fromtimestamp.return_value) +@pytest.mark.integration class TestPyCanTransportInterfaceIntegration: """Integration tests for `PyCanTransportInterface` class.""" @@ -980,13 +981,35 @@ class TestPyCanTransportInterfaceIntegration: rx_physical={"can_id": 0x641}, tx_physical={"can_id": 0x642}, rx_functional={"can_id": 0x6FE}, - tx_functional={"can_id": 0x6FF}, - ), - } + tx_functional={"can_id": 0x6FF}), + }, + { + "can_bus_manager": Mock(spec=BusABC), + "addressing_information": CanAddressingInformation( + addressing_format=CanAddressingFormat.MIXED_29BIT_ADDRESSING, + tx_physical={"target_address": 0x1B, "source_address": 0xFF, "address_extension": 0x87}, + rx_physical={"target_address": 0xFF, "source_address": 0x1B, "address_extension": 0x87}, + tx_functional={"target_address": 0xAC, "source_address": 0xFE, "address_extension": 0xFF}, + rx_functional={"target_address": 0xFE, "source_address": 0xAC, "address_extension": 0xFF}), + "n_as_timeout": 0.1, + "n_ar_timeout": 987, + "n_bs_timeout": 43, + "n_br": 5.3, + "n_cs": 0.92, + "n_cr_timeout": 98.32, + }, ]) def test_init(self, init_kwargs): py_can_ti = PyCanTransportInterface(**init_kwargs) + assert py_can_ti.bus_manager == init_kwargs["can_bus_manager"] + assert py_can_ti.addressing_information == init_kwargs["addressing_information"] assert py_can_ti.n_as_measured is None assert py_can_ti.n_ar_measured is None assert py_can_ti.n_bs_measured is None assert py_can_ti.n_cr_measured is None + assert py_can_ti.n_as_timeout == init_kwargs.get("n_as_timeout", AbstractCanTransportInterface.N_AS_TIMEOUT) + assert py_can_ti.n_ar_timeout == init_kwargs.get("n_ar_timeout", AbstractCanTransportInterface.N_AR_TIMEOUT) + assert py_can_ti.n_bs_timeout == init_kwargs.get("n_bs_timeout", AbstractCanTransportInterface.N_BS_TIMEOUT) + assert py_can_ti.n_br == init_kwargs.get("n_br", AbstractCanTransportInterface.DEFAULT_N_BR) + assert py_can_ti.n_cs == init_kwargs.get("n_cs", AbstractCanTransportInterface.DEFAULT_N_CS) + assert py_can_ti.n_cr_timeout == init_kwargs.get("n_cr_timeout", AbstractCanTransportInterface.N_CR_TIMEOUT) diff --git a/uds/segmentation/can_segmenter.py b/uds/segmentation/can_segmenter.py index b854cc2b..ac2b58e4 100644 --- a/uds/segmentation/can_segmenter.py +++ b/uds/segmentation/can_segmenter.py @@ -16,7 +16,7 @@ class CanSegmenter(AbstractSegmenter): - """Segmenter class that provides utilities for segmentation and desegmentation on CAN bus.""" + """Segmenter class that provides utilities for segmentation and desegmentation specific for CAN bus.""" def __init__(self, *, addressing_information: AbstractCanAddressingInformation, @@ -26,7 +26,7 @@ def __init__(self, *, """ Configure CAN Segmenter. - :param addressing_information: Addressing Information configuration of a CAN entity. + :param addressing_information: Addressing Information configuration of a CAN node. :param dlc: Base CAN DLC value to use for creating CAN Packets. :param use_data_optimization: Information whether to use CAN Frame Data Optimization in created CAN Packets during segmentation. @@ -75,7 +75,7 @@ def tx_packets_functional_ai(self) -> PacketAIParamsAlias: @property def addressing_information(self) -> AbstractCanAddressingInformation: - """Addressing Information configuration of a CAN entity.""" + """Addressing Information configuration of a CAN node.""" return self.__addressing_information @addressing_information.setter diff --git a/uds/transport_interface/abstract_transport_interface.py b/uds/transport_interface/abstract_transport_interface.py index 488465a1..204ac508 100644 --- a/uds/transport_interface/abstract_transport_interface.py +++ b/uds/transport_interface/abstract_transport_interface.py @@ -90,7 +90,7 @@ async def async_send_packet(self, Transmit UDS packet asynchronously. :param packet: A packet to send. - :param loop: An asyncio event loop used for observing messages. + :param loop: An asyncio event loop to use for scheduling this task. :return: Record with historic information about transmitted UDS packet. """ @@ -103,9 +103,10 @@ async def async_receive_packet(self, Receive UDS packet asynchronously. :param timeout: Maximal time (in milliseconds) to wait. - :param loop: An asyncio event loop used for observing messages. + :param loop: An asyncio event loop to use for scheduling this task. :raise TimeoutError: Timeout was reached. + :raise asyncio.TimeoutError: Timeout was reached. :return: Record with historic information about received UDS packet. """ diff --git a/uds/transport_interface/can_transport_interface.py b/uds/transport_interface/can_transport_interface.py index 06580c0f..38b646a3 100644 --- a/uds/transport_interface/can_transport_interface.py +++ b/uds/transport_interface/can_transport_interface.py @@ -38,7 +38,7 @@ class AbstractCanTransportInterface(AbstractTransportInterface): DEFAULT_N_BR: TimeMilliseconds = 0 """Default value of :ref:`N_Br ` time parameter.""" DEFAULT_N_CS: Optional[TimeMilliseconds] = None - """Default value of :ref:`N_Cs ` time parameter.""" + """Default value of :ref:`N_Cs ` time parameter.""" def __init__(self, can_bus_manager: Any, @@ -70,9 +70,9 @@ def __init__(self, self.n_as_timeout = kwargs.pop("n_as_timeout", self.N_AS_TIMEOUT) self.n_ar_timeout = kwargs.pop("n_ar_timeout", self.N_AR_TIMEOUT) self.n_bs_timeout = kwargs.pop("n_bs_timeout", self.N_BS_TIMEOUT) + self.n_cr_timeout = kwargs.pop("n_cr_timeout", self.N_CR_TIMEOUT) self.n_br = kwargs.pop("n_br", self.DEFAULT_N_BR) self.n_cs = kwargs.pop("n_cs", self.DEFAULT_N_CS) - self.n_cr_timeout = kwargs.pop("n_cr_timeout", self.N_CR_TIMEOUT) self.__segmenter = CanSegmenter(addressing_information=addressing_information, **kwargs) @property @@ -236,6 +236,8 @@ def n_cs(self, value: Optional[TimeMilliseconds]): Set the value of N_Cs time parameter to use. :param value: The value to set. + - None - use timing compatible with STmin value received in a preceding Flow Control packet + - int/float type - timing value to be used regardless of a received STmin value :raise TypeError: Provided value is not int or float. :raise ValueError: Provided value is out of range. @@ -453,7 +455,7 @@ def _teardown_notifier(self, suppress_warning: bool = False) -> None: "`PyCanTransportInterface.receive_packet methods`) shall not be used together.", category=UserWarning) - def _teardown_async_notifier(self, suppress_warning: bool = False): + def _teardown_async_notifier(self, suppress_warning: bool = False) -> None: """ Stop and remove CAN frame notifier for asynchronous communication.