Reputation: 123
I have set up two vcan devices and I want to treat them as if they were connected together. I want to be able to use can-utils candump to listen on one line, and send can messages from the other. How can I do that without a physical device?
For clarification, I am writing software to communicate over CAN which I am already capable of, but to facilitate the actual data gathering and further development, I need two can enabled devices to communicate with each other. While a simple solution in the real world, solved by physically connecting devices together, I need a programmatic solution that will work on the computer.
Upvotes: 5
Views: 4098
Reputation: 44
I wanted to add that you could also connect a virtual can interface with a real one.
For example if you have a simulated system using virtual cans and want to connect actual CAN Hardware you could connect those with
sudo cangw -A -s vcan0 -d can0 -e
and
sudo cangw -A -s can0 -d vcan0 -e
Upvotes: 0
Reputation: 657
Add the can gateway kernel module:
sudo modprobe can-gw
Then create gateway rules via cangw, which comes with can-utils, for the respective interfaces.
For example, for routing messages from vcan0 to vcan1:
sudo cangw -A -s vcan0 -d vcan1 -e
and the other way around:
sudo cangw -A -s vcan1 -d vcan0 -e
Now you will be able to see all messages sent on vcan0 also on vcan1 and vice versa.
Upvotes: 14