Skip to content

In EtasBus _apply_filters, self._oci_filters is not defined when EtasBus init called with version 4.3.0 #1693

Closed

Description

@kjw8118

Describe the bug

When I generate Bus object with 'etas', it gave me error messages
dev = can.interface.Bus(interface='etas', channel='ETAS://USB/ES582.1:XXXXXX/CAN:1', bitrate=500000)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "'Python Path'\lib\site-packages\can\util.py", line 378, in wrapper
    return f(*args, **kwargs)
  File "'Python Path'\lib\site-packages\can\interface.py", line 135, in Bus
    bus = cls(channel, **kwargs)
  File "'Python Path'\lib\site-packages\can\interfaces\etas\__init__.py", line 21, in __init__
    super().__init__(channel=channel, **kwargs)
  File "'Python Path'\lib\site-packages\can\bus.py", line 99, in __init__
    self.set_filters(can_filters)
  File "'Python Path'\lib\site-packages\can\bus.py", line 404, in set_filters
    self._apply_filters(self._filters)
  File "'Python Path'\lib\site-packages\can\interfaces\etas\__init__.py", line 222, in _apply_filters
    if self._oci_filters:
AttributeError: 'EtasBus' object has no attribute '_oci_filters'. Did you mean: 'set_filters'?

I used etas interface python-can with last version(~4.2.2), and it worked in same code.

To Reproduce

Below line added in EtasBus(can.BusABC) init at 4.3.0. It call EtasBus._apply_filters()
super().__init__(channel=channel, **kwargs)

        if self._oci_filters:
            OCI_RemoveCANFrameFilterEx(self.rxQueue, self._oci_filters, 1)

_apply_filters got 'filters' as parameter but self._oci_filters is checked.
self._oci_filters is defined after calling _apply_filters in EtasBus init.

Expected behavior

Im not sure how self._oci_filters will be working in EtasBus. I think self._oci_filters could be defined before EtasBus.init

Additional context

OS and version: Windows 10 x64
Python version: 3.10.8
python-can version: 4.3.0
python-can interface/s (if applicable): etas

Activity

  1. zariiii9003 commented on Nov 20, 2023

    @zariiii9003
    Collaborator

    Could you try moving this line

    super().__init__(channel=channel, **kwargs)

    to the end of the __init__ method?

  2. zariiii9003 commented on Dec 5, 2023

    @zariiii9003
    Collaborator

    @lumagi You have ETAS interfaces, right? Could you try the fix?

  3. lumagi commented on Dec 5, 2023

    @lumagi
    Collaborator

    Yes, I can try the fix, probably tomorrow. Do I understand correctly, this is a regression from the 4.3.0 release?

  4. zariiii9003 commented on Dec 5, 2023

    @zariiii9003
    Collaborator

    Yep, i think from #1532

  5. lumagi commented on Dec 6, 2023

    @lumagi
    Collaborator

    That's unfortunate, especially since it's my PR :-/
    I didn't get around to testing it today, but I have it on my plate for tomorrow.

  6. added a commit that references this issue on Dec 7, 2023
    f14f36c
  7. lumagi commented on Dec 7, 2023

    @lumagi
    Collaborator

    @zariiii9003 I was able to verify the bug and validate the fix today, see #1704.

  8. added a commit that references this issue on Dec 8, 2023
    033be12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions