Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kjw8118 opened this issue Nov 17, 2023 · 6 comments · Fixed by #1704
Labels

Comments

@kjw8118
Copy link

kjw8118 commented Nov 17, 2023

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

@kjw8118 kjw8118 added the bug label Nov 17, 2023
@zariiii9003
Copy link
Collaborator

Could you try moving this line

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

to the end of the __init__ method?

@zariiii9003
Copy link
Collaborator

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

@lumagi
Copy link
Collaborator

lumagi commented Dec 5, 2023

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

@zariiii9003
Copy link
Collaborator

Yep, i think from #1532

@lumagi
Copy link
Collaborator

lumagi commented Dec 6, 2023

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.

lumagi added a commit to lumagi/python-can that referenced this issue Dec 7, 2023
super.__init__ calls set_filters, which is only permissible
after the corresponding structures have been created in the child
constructor. Hence, super.__init__ must be called after the child has
finished initialization. Fixes hardbyte#1693
@lumagi
Copy link
Collaborator

lumagi commented Dec 7, 2023

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

zariiii9003 pushed a commit that referenced this issue Dec 8, 2023
super.__init__ calls set_filters, which is only permissible
after the corresponding structures have been created in the child
constructor. Hence, super.__init__ must be called after the child has
finished initialization. Fixes #1693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants