Unable to send CAN FD frame using python-can (PCAN-USB Pro FD)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python
调研方向
从报告中展示的 can.interface.Bus 中的 pcan bus 设置和 can.Message 构造开始,重点关注 PCAN_USBBUS2 的 FD 和 bitrate 配置。使用 python-can 4.50.0 重现这两个示例,并在 PCAN-View 中比较生成的帧类型和 CanError 行为。完成的标准是,文档中的配置要么发送请求的 CAN FD 帧,要么明确报告参数无效。
由索引模型根据 Issue 内容生成。
描述
Hi everyone,
I’m currently working on a test bench that communicates over CAN and CAN FD using a PCAN-USB Pro FD interface.
Sending standard CAN messages like 0x214 works perfectly from both Python and PCAN-View 👍
But I can't seem to send a CAN FD frame properly through Python. My goal is to send a frame with ID 0x1E38400C, data length = 2, and data = [0xEB, 0x10], using CAN FD (with is_fd=True, bitrate_switch=True, is_extended_id=True) 👎
I can send this same frame via PCAN-View successfully when enabling FD mode. So I know the hardware and channel config are okay.
I’ve tried a few code samples including the official ones from the python-can documentation, but I either get:
-
No error, but the frame is sent as standard CAN (not FD), or
-
can.CanError: A parameter contains an invalid value
Configuration:
- Interface: pcan
- Channel: PCAN_USBBUS2
- Bitrate: 500000
- Data bitrate: 2000000 (Can FD = 2Mb/s) ?
My setup:
OS and version: window11
PCAN-USB Pro FD
Python version: 3.12.9
python-can version: 4.50.0
VScode : 1.100.2
notepad++: 8.8.1
my functions
def periodic_message_can2(can_id=0x1E38400C, interface='pcan', channel='PCAN_USBBUS2'):
try:
bus = can.interface.Bus(interface=interface, channel=channel, fd=True, bitrate=500000, data_bitrate=2000000)
can_data_on = [0xEB, 0x10]
msg = can.Message(
arbitration_id=can_id,
data=can_data_on,
is_extended_id=True,
is_fd=True,
bitrate_switch=True,
dlc=2
)
bus.send_periodic(msg, 1.0)
print(" Message FD envoyé en périodique.")
except can.CanError as e:
print(f" Erreur CAN : {e}")
except Exception as e:
print(f" Erreur générale : {e}")
#OUTPUT for this one : can.CanError: A parameter contains an invalid value
############################################################
#Second function
def periodic_message_can(can_id=0x1E38400C, interface='pcan', channel='PCAN_USBBUS2'):
try:
bus = can.interface.Bus(interface=interface, channel=channel, fd=True)
can_data_on = [0xEB, 0x10]
msg = can.Message(arbitration_id=can_id, data=can_data_on, is_extended_id=True, is_fd=True, dlc=2, is_rx=False)
bus.send_periodic(msg, 1)
except can.CanError as e:
print(f"Erreur CAN : {e}")
except Exception as e:
print(f"Erreur générale : {e}")
#The function executes without any errors, but it looks like my frame is not sent as CAN FD...
When I check this frame in PCAN-View, the “Type” field is empty, which usually indicates it's a standard CAN frame and not an FD one. So even though I set is_fd=True in the code, it seems like it's not actually taking effect.
- 主要语言
- Python
- 星标
- 1.6k
- 派生
- 697
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hardbyte/python-can 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
hardbyte/python-can#2103 ·
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
hardbyte/python-can#2077 · 1 条评论 · 1 个 reaction ·
-
bug
难度 1/5 1 小时以内 新手友好度 68/100
hardbyte/python-can#1922 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
hardbyte/python-can#2102 ·
-
bug
难度 3/5 1-2 天 新手友好度 68/100
hardbyte/python-can#2092 ·
查看 hardbyte/python-can 的全部 Issue
相似的 Issue
-
area: harness bug status: needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 1/5 1 小时以内 新手友好度 80/100
learningequality/kolibri#15351 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Name consistency 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
eellak/triplestore#65 · 1 条评论 ·