hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.31k stars 603 forks source link

Resolve AttributeError within NicanError #1806

Closed vijaysubbiah20 closed 5 months ago

vijaysubbiah20 commented 5 months ago

Resolves the below error:

Exception in thread can.notifier for bus "NI-CAN: CAN0":
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\can\notifier.py", line 124, in _rx_thread
    if msg := bus.recv(self.timeout):
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\can\bus.py", line 126, in recv
    msg, already_filtered = self._recv_internal(timeout=time_left)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\can\interfaces\nican.py", line 301, in _recv_internal
    nican.ncWaitForState(
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\can\interfaces\nican.py", line 120, in check_status
    raise error_class(function, result, arguments)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\can\interfaces\nican.py", line 92, in __init__
    message=f"{function} failed: {get_error_message(self.error_code)}",
                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NicanOperationError' object has no attribute 'error_code'
zariiii9003 commented 5 months ago

Thanks!