Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Unable to send CAN FD frame using python-can (PCAN-USB Pro FD)

未關閉
#1,943 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 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 中比較產生的 frame 類型和 CanError 行為。完成的標準是,文件中的設定要麼傳送要求的 CAN FD frame,要麼明確回報參數無效。

由索引模型根據 Issue 內容生成。

描述

bug

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
分支
700
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

hardbyte/python-can 的其他 Issue

查看 hardbyte/python-can 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。