Skip to content

Complete event not set when "blocking_send" set to True #129

@jpvolkmann

Description

@jpvolkmann

Hello,

just started using the isotp and wanted to send a simple message (Single Frame). When "blocking_send" is set to True the send() command times out while if "blocking_send" is set to False everything is working as expected.

I tried to understand the FSM in protocol.py and realized that self.active_send_request.complete(True) never get called on the transmitted request.

Checked especially line 1060ff of protocol.py

I temporarily fixed it by adding a check for a active_send_reguest but not sure if this will break anything else.

        immediate_rx_msg_required = False
        if self.tx_state == self.TxState.IDLE:
            **if self.active_send_request and self.active_send_request.generator.depleted():
                self.active_send_request.complete(True)
                self.active_send_request = None**        

            read_tx_queue = True  # Read until we get non-empty frame to send
            while read_tx_queue:

Do I use something wrong?

The code is integrated in some other class:

    def connect(self):
        self._bus = can.Bus(
            interface=self._interface,
            channel=self._channel,
            bitrate=self._bitrate,
            fd=self._can_fd,
            fd_bitrate=self._can_fd_bitrate,
            can_termination=self._can_termination,
        )
        # self._bus.set_filters([{"can_id": self._filter_id, "can_mask": 0xFFFF}])

        addr = isotp.Address(
            isotp.AddressingMode.Normal_29bits,
            rxid=self._filter_id,
            txid=self._arbitration_id,
        )
        params = {
            "blocking_send": True, 
            "can_fd": True, 
            "tx_data_length": 64,
        }
        self._stack = isotp.CanStack(
            self._bus, address=addr, error_handler=self._error_handler, params=params
        )

        self._stack.start()
        self.is_connected = True


    def write(self, command):
        msg_bytes = bytes(command)
        self._stack.send(msg_bytes, send_timeout=self.timeout)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions