You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to send a CANFD message with a PCAN interface with PCAN USB-FD. I am not getting that sent message on my HW. I am using the below script to send messages.
importtimeimportcandefinitialize_can_bus(channel, bitrate):
try:
# Initialize the CAN interface for nominal bitrate 500kbit/sec and data bitrate 2Mbit/seccan_interface='pcan'can_bus=can.interface.Bus(channel=channel, bustype=can_interface, bitrate=bitrate,
fd=True,
f_clock_mhz=40,nom_brp=5, nom_tseg1=11, nom_tseg2=4, nom_sjw=4, data_brp=4, data_tseg1=3, data_tseg2=1, data_sjw=1)
# Log initialization detailsprint(f"CAN bus initialized successfully on channel {channel} with bitrate {bitrate}.")
returncan_busexceptcan.CanErrorase:
print(f"Error initializing CAN bus on channel {channel} with bitrate {bitrate}: {e}")
returnNone# Main scriptif__name__=="__main__":
channel='PCAN_USBBUS1'bitrates= [2000000] # 500k, 1M, and 2M bitratesforbitrateinbitrates:
print(f"Attempting to initialize CAN bus on channel {channel} with bitrate {bitrate}...")
can_bus=initialize_can_bus(channel, bitrate)
ifcan_busisnotNone:
# Prepare a CAN messagecan_message=can.Message(arbitration_id=0x600, data=[0x22, 0x22, 0, 0, 0, 0, 0, 0], is_extended_id=False, is_fd=True,bitrate_switch=True)
# Send the CAN messagetry:
can_bus.send(can_message)
print("CAN-FD message sent successfully.")
exceptcan.CanErrorase:
print(f"Error sending CAN-FD message: {e}")
# Allow time for message transmissiontime.sleep(1)
# Close the CAN buscan_bus.shutdown()
print("CAN bus shutdown.\n")
Output:
Attempting to initialize CAN bus on channel PCAN_USBBUS1 with bitrate 2000000...
uptime library not available, timestamps are relative to boot time and not to Epoch UTC
CAN bus initialized successfully on channel PCAN_USBBUS1 with bitrate 2000000.
CAN-FD message sent successfully.
CAN bus shutdown.
But not receive this message in my HW and red LED is blinking in PCAN USB-FD device.
Additional context
OS and version: Windows 10
Python version: Python 3.9.0
python-can version: python-can 4.3.1
python-can interface/s (if applicable): pcan
The text was updated successfully, but these errors were encountered:
I am trying to send a CANFD message with a PCAN interface with PCAN USB-FD. I am not getting that sent message on my HW. I am using the below script to send messages.
Output:
Attempting to initialize CAN bus on channel PCAN_USBBUS1 with bitrate 2000000...
uptime library not available, timestamps are relative to boot time and not to Epoch UTC
CAN bus initialized successfully on channel PCAN_USBBUS1 with bitrate 2000000.
CAN-FD message sent successfully.
CAN bus shutdown.
But not receive this message in my HW and red LED is blinking in PCAN USB-FD device.
Additional context
OS and version: Windows 10
Python version: Python 3.9.0
python-can version: python-can 4.3.1
python-can interface/s (if applicable): pcan
The text was updated successfully, but these errors were encountered: