IXXAT: does not recover / no exceptions after CAN bus disconneted for a few seconds
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 42/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
從 can/interfaces/ixxat/canlib_vcinpl.py 和 can/notifier.py 中的 traceback 路徑開始,接著檢查 ThreadSafeBus 和 Notifier 如何傳播接收錯誤。重現 IXXAT 中斷連線情境,並判斷應如何回報或復原 warning-limit exception、匯流排狀態、傳送行為以及 listener 錯誤回呼。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
When I unplug the CAN bus (physically pull the connector), after a few seconds, the underlying Ixxat driver is raising an exception raise VCIError("Error warning limit exceeded") that I see in the output but cannot catch in any way.
After that, the bus seems dead (no receive, no transmit). It does not recover after the physical bus is reconnected.
The bus object is a can.TreadSafeBus().
Strangely, the bus's property .state is still can.BusState.ACTIVE, and I can happily call send() (without effect, of course). Unfortunately, it does not return a status code (the error?), nor is an exception thrown.
I tried to catch: can.CanError, can.CanOperationError, can.interfaces.ixxat.exceptions.VCIError
I tried to add a custom Listener on the Notifier with method on_error(), but this is not called (in contrast to on_message_received(), so the Listener basically works).
To Reproduce
some code lines from the CanBus class:
def __init__ ...
can.rc = can.util.load_file_config(config_file)
self._listener = MyListener(receive_handler)
self._bus = can.ThreadSafeBus()
...
loop = asyncio.get_event_loop()
self._notifier = can.Notifier(self._bus, [self._listener], loop=loop)
async def send_can( self, message: can.Message ) -> bool:
print( "Bus state: " + str(self._bus.state))
if self._bus.state == can.BusState.ACTIVE:
self._bus.send( message )
return True
else:
return False
the Listener:
class MyListener(can.Listener):
def __init__(self, receive_handler):
self._receive_handler = receive_handler
def __call__(self, msg: can.Message):
return self.on_message_received(msg)
async def on_message_received(self, msg):
await self._receive_handler(msg)
async def on_error(exc):
print( "!!!!!!!!! Listener exception" )
Expected behavior
My assumptions were:
- nice if the driver would recover on its own once the CAN is reconnected
- nice if I could somehow retrieve the error state in any way (return value, exception, status call). Then I could -- somehow -- actively reset the interface. Don't know how, though...
- is that an Ixxat related issue or a general one?
Additional context
OS and version: Windows 10
Python version: 3.12.4
python-can version: 4.4.2
python-can interface/s (if applicable): IXXAT
Traceback and logs
This is what I get:Other (unknown) CAN error
CAN message flags bAddFlags/bFlags2 0x00 bflags 0x03
Other (unknown) CAN error
CAN message flags bAddFlags/bFlags2 0x00 bflags 0x03
Other (unknown) CAN error
... (lots of these messages)
CAN message flags bAddFlags/bFlags2 0x00 bflags 0x03
Exception in thread can.notifier for bus "unknown":
Traceback (most recent call last):
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
Exception in callback Notifier._on_error(VCIError('Err...mit exceeded'))
handle: <Handle Notifier._on_error(VCIError('Err...mit exceeded'))>
Traceback (most recent call last):
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\notifier.py", line 163, in _on_error
listener.on_error(exc)
TypeError: MyListener.on_error() takes 1 positional argument but 2 were given
self._target(*self._args, **self._kwargs)
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\notifier.py", line 126, in _rx_thread
if msg := bus.recv(self.timeout):
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\thread_safe_bus.py", line 53, in recv
return self.__wrapped__.recv(timeout=timeout, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\bus.py", line 127, in recv
msg, already_filtered = self._recv_internal(timeout=time_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\interfaces\ixxat\canlib.py", line 148, in _recv_internal
return self.bus._recv_internal(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\Lib\site-packages\can\interfaces\ixxat\canlib_vcinpl.py", line 731, in _recv_internal
raise VCIError("Error warning limit exceeded")
can.interfaces.ixxat.exceptions.VCIError: Error warning limit exceeded
... (next bus.send() call:)
Bus state: BusState.ACTIVE
- 主要語言
- Python
- 星號
- 1.6k
- 分支
- 715
- 平均合併
- 2 天 4 小時
- 30 天內合併 PR
- 42
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
hardbyte/python-can 的其他 Issue
-
serial: a frame cut off by the read timeout raises struct.error / TypeError instead of CanOperationError可能已有人在做 @aloneangel45 於 1 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
hardbyte/python-can#2157 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 1/5 1 小時以內 新手友好度 68/100
hardbyte/python-can#1922 · 1 個 reaction ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
hardbyte/python-can#2159 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 35/100
hardbyte/python-can#2121 · 2 個 reaction ·
維護者通常 1 天內回覆
-
Make socket binding exceptions more debugable可能已有人在做 @vonpanda 於 57 天前認領。 未關閉enhancement
難度 3/5 1-2 天 新手友好度 75/100
hardbyte/python-can#2104 ·
維護者通常 1 天內回覆
查看 hardbyte/python-can 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
bad-antics/lateralus-lang#1489 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 66/100
-
難度 1/5 1 小時以內 新手友好度 69/100
anderspitman/awesome-tunneling#330 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
scikit-hep/coffea#1668 ·