How to create virtual CAN port on linux? (C++) How to create virtual CAN port on linux? (C++) linux linux

How to create virtual CAN port on linux? (C++)


You need SocketCAN driver, that is available on modern Linux distributions like Ubuntu etc. SocketCAN provides a virtual CAN port driver:

sudo modprobe vcansudo ip link add dev vcan0 type vcansudo ip link set up vcan0

Now you can send and receive CAN frames over vcan0 device. Wikipedia article provides simple code example on how to use SocketCAN.

You'll also need can-utils for testing purposes.

You'll find more information about SocketCAN and its usage on eLinux.org