Skip to content

Running CarSimulator on WSL (Windows Subsystem for Linux)

Dominik Gruber edited this page Feb 4, 2022 · 2 revisions

In case your main workstation is a Windows machine, you can run the CarSimulator in WSL.

To install WSL, see this documentation: https://docs.microsoft.com/en-us/windows/wsl/install

CarSimulator was tested on WSL2 using Ubuntu 20.04

Install SocketCAN drivers

This is the hard part. Since the default Ubuntu Kernel does not have SocketCAN supported compiled in, you need to recompile the kernel.

  • Checkout the WSL Linux Kernel: https://github.com/microsoft/WSL2-Linux-Kernel
  • cd WSL2-Linux-Kernel
  • Switch to the best fitting tag of your current Kernel
    • perform a uname -r to find out your current kernel version
  • cat /proc/config.gz | gunzip > .config
  • make prepare modules_prepare
  • make menuconfig
    • Menu will open with your current kernel configuration
    • In Network check everything regarding CAN
  • make modules
  • make -j $(nproc)
    • compile the kernel
  • cp vmlinux /mnt/c/Users/{USER_ID}/kernel/
  • In your windows user directory create a file named .wslconfig
    • Fill the newly created file:
[wsl2]
kernel=C:\\Users\\{USER_ID}\\kernel\\vmlinux
  • In an admin powershell now restart the WSL via ````wsl --shutdown```
  • Reconnect to the WSL
  • sudo ip link add dev vcan0 type vxcan
  • sudo ip link set up vcan0
  • sudo ip link set dev vxcan0 up
  • apt install can-utils

Compile CarSimulator

Compiling CarSimulator works in more or less the same way as on RaspberryPi.

Install necessary packages

# sudo apt-get install git build-essential lua5.2 liblua5.2-0 liblua5.2-dev libsocketcan-dev`

Get CarSimulator sources and build

# git clone https://github.com/AVL-DiTEST-DiagDev/car-simulator.git`
# cd car-simulator`
# make`

Run CarSimulator

While still in the CarSimulator directory create a directory 'lua_configs'

# mkdir lua_configs

and put your simulation files there. For example the one from the example directory

# cp example\ luas/example.lua lua_configs

Finally start the CarSimulator:

# ./dist/Debug/GNU-Linux/amos-ss17-proj4 vcan0

Test if the setup is working

Open two additional wsl console windows. One to Send and one to receive. Execute the following commands respectively.

First the receive part:

# isotprecv -s 7e0 -d 7e8 vcan0

In the second window send a message:

# isotpsend -s 7e0 -d 7e8 vcan0
01 46

You should now receive a response in the other window and see some log messages from the CarSimulator.

Clone this wiki locally