slcan doesn't receive corresponding response after sending can message.
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
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- networking
Hướng nghiên cứu
Bắt đầu với can.interfaces.slcan.slcanBus.send và recv, sau đó kiểm tra các lệnh gọi _write và _read được triển khai được báo cáo sử dụng. Tái tạo thiết lập hai thiết bị với các dây CAN được kết nối và ngắt kết nối, kiểm tra các phản hồi truyền và hành vi nhận đồng thời. Hoàn tất khi các lần gửi thành công báo cáo ACKs, các lần gửi thất bại báo cáo BEL/NACK, và các thao tác gửi/nhận không tranh chấp hoặc bị chặn không đúng cách.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
While calling slcanBus.send, the corresponding response isn't read. This makes it report false success even on failed messages.
To Reproduce
Setup two can devices, both configured to send ack on successful can message receive. Disconnect the can wires after some time.
Expected behavior
Expected to receive ack when wire is connected (slcan should report successful transmission)
Expected to receive nack(bel) when wire is disconnected (slcan should report failed transmission)
Additional context
OS and version: Ubuntu 24.04.3 LTS
Python version: Python 3.11.14
python-can version: 4.6.1
python-can interface/s: slcan with custom slcan device (esp32s3)
import can
from can.interfaces.slcan import slcanBus
import threading
class SLCANBusWithErrorCheck(slcanBus):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._tx_lock = threading.Lock()
def send(self, msg, timeout=None):
if timeout != self.serialPortOrig.write_timeout:
self.serialPortOrig.write_timeout = timeout
if msg.is_remote_frame:
if msg.is_extended_id:
sendStr = f"R{msg.arbitration_id:08X}{msg.dlc:d}"
else:
sendStr = f"r{msg.arbitration_id:03X}{msg.dlc:d}"
else:
if msg.is_extended_id:
sendStr = f"T{msg.arbitration_id:08X}{msg.dlc:d}"
else:
sendStr = f"t{msg.arbitration_id:03X}{msg.dlc:d}"
sendStr += msg.data.hex().upper()
with self._tx_lock:
# Drain any leftover bytes from a previous error before sending
self.serialPortOrig.reset_input_buffer()
self._buffer.clear()
self._write(sendStr)
response = self._read(timeout=max(timeout or 0, 2.0))
if response is None:
raise can.CanError("TX timeout - no response from adapter")
if self._ERROR.decode() in response:
raise can.CanError("TX failed - BEL received (no ACK on bus)")
def recv(self, timeout=None):
if self._tx_lock.locked():
return None
return super().recv(timeout=timeout)
I know following are the errors in the provided solution:
- If we are mid receive, then any call to send can create race condition (clear the serial buffers mid receive)
- the timeout logic is also incorrect (additional 2.0 second for timeout < 2.0 second, patch for some other problem)
- Receive fails immediately if transmission is going on
Any solution i came up for these problems seemed patchy as best. So, expecting it to solve inside of python-can itself or provide a better solution than locking.
- Ngôn ngữ chính
- Python
- Star
- 1.6k
- Fork
- 697
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
hardbyte/python-can#2077 · 1 bình luận · 1 reaction ·
-
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 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
hardbyte/python-can#2102 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
hardbyte/python-can#2092 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
hardbyte/python-can#2091 ·
Tất cả issue của hardbyte/python-can
Issue tương tự
-
bug ci good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
documentation
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
inmanta/inmanta-core#10835 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
sponsored
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100