Can't send CAN messages with RevPi Con CAN

Topics about the Hardware of Revolution Pi
Post Reply
andreacg80
Posts: 1
Joined: 01 Mar 2023, 12:26
Answers: 0

Can't send CAN messages with RevPi Con CAN

Post by andreacg80 »

Dear Kunbus Team,

My company has purchased Revolution Pi Connect SE and RevPi con CAN modules, one of each. We are currently making test plans of each module. Right now, we are testing RevPi Con CAN. Our purpose is to control RevPi Con CAN via Python script so it sends CAN messages to the bus. However, we still haven't been able to succeed in doing so. We are using the python-can library, as mentioned in the documentation of the tutorial "How to Control RevPi Con CAN", https://revolutionpi.com/tutorials/uebe ... ansteuern/

We are using the "can0" channel and the "socketcan" interface as explained in the tutorial mentioned above.

The implemented code is as follows:
import can
import os
import time

#Setting up the can0 channel and its bitrate
os.system("sudo ip link set can0 type can loopback on")
time.sleep(0.1)
os.system("sudo ip link set can0 up type can bitrate 500000")
time.sleep(0.1)

#Establishing configuration parameters
can.rc['interface'] = 'socketcan'
can.rc['channel'] = 'can0'

#Sending a test message
with can.Bus() as bus:
msg = can.Message(
arbitration_id=0x650,
data=[0, 0, 0, 0, 0, 0, 1, 1],
is_extended_id=False
)
try:
bus.send(msg)
print(f"Message {msg.data} sent on {bus.channel_info}")
except can.CanError:
print("Message NOT sent")

I have attached the images showing the physical setup of our system as URLs below this paragraph. To test the communication, we are using the Innomaker USB2CAN module, which is connected at one end to RevPi Con CAN via CAN HIGH (yellow cable in the pictures) and CAN LOW (blue cable in the pictures), and at the other end to a computer with the BUSMASTER software. We did not manage to send messages from RevPi con CAN to the USB2CAN module, so BUSMASTER doesn't show us any received messages.
URLs
Setup: https://ibb.co/x2Gvky7
RevPi con CAN wiring: https://ibb.co/ZVd6fvL
USB2CAN Module: https://ibb.co/vQDTxRf

We have wired the RevPi Con CAN module as explained in the documentation "How to Connect RevPi Con CAN to the CAN Bus". https://revolutionpi.com/tutorials/uebe ... chliessen/

We have searched through all the Revolution Pi forum for the solution and been doing a exhaustive research through the Internet, but we have not been able to find the cause of the problem. Could you please give us some feedback on the mistake we are making?

Thank you so much for your attention.

Best regards,
Andrea
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: Can't send CAN messages with RevPi Con CAN

Post by nicolaiB »

Hi Andrea,

I'm no can expert, but something I've spotted in your script:
os.system("sudo ip link set can0 type can loopback on")
Why do you enable the loopback mode if you want to transmit over wire? With loopback enabled RX and TX will be connected internally and no data is transmitted over the wire.

Hope this helps,

Nicolai
Post Reply