IXXAT: does not recover / no exceptions after CAN bus disconneted for a few seconds
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- embedded-iot, networking
Hướng nghiên cứu
Bắt đầu với các đường dẫn traceback trong can/interfaces/ixxat/canlib_vcinpl.py và can/notifier.py, sau đó xem xét cách ThreadSafeBus và Notifier truyền các lỗi nhận. Tái hiện kịch bản ngắt kết nối IXXAT và xác định warning-limit exception, trạng thái bus, hành vi gửi và callback lỗi của listener nên được báo cáo hoặc khôi phục như thế nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 1.6k
- Fork
- 715
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của hardbyte/python-can
-
serial: a frame cut off by the read timeout raises struct.error / TypeError instead of CanOperationErrorCó thể đã có người làm @aloneangel45 đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hardbyte/python-can#2157 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
hardbyte/python-can#1922 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
hardbyte/python-can#2159 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
hardbyte/python-can#2121 · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Make socket binding exceptions more debugableCó thể đã có người làm @vonpanda đã nhận 57 ngày trước. Đang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 75/100
hardbyte/python-can#2104 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của hardbyte/python-can
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
anderspitman/awesome-tunneling#330 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4676 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 18 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
pandas-dev/pandas-stubs#2155 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
essreduce
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 1 ngày