- Both Grasshopper computer and Raspberry Pi connect to a router.
- Check IP address of the Raspberry Pi.
- Connect Grasshopper computer and Raspberry Pi via a Ethernet cable directly and follow the cofiguration below to set up a network:
Device IP Mask Gateway Grasshopper computer 192.168.0.2 255.255.255.0 0.0.0.0 Raspberry Pi 192.168.0.1 255.255.255.0 0.0.0.0
- Networking plugin:
gHowl
can be downloaded from here. And check this instruction to install the plugin.
Here we assume that Raspberry Pi is hosted at 10.100.2.97
sudo apt-get install can-utils
cd CanbusController
pip3 install -r requirements.txt
-
Plug in CANDO and start interface.
sudo ip link set can0 up type can bitrate 1000000
-
Start
UdpServer2CANbus.py
service.Here, we assume the ip of Raspberry Pi is
192.168.0.1
, and the ip address of Grasshopper computer is192.168.0.2
./UdpServer2CANbus.py -i 192.168.0.1 -p 5005 -gi 192.168.0.2 -gp 5005 -c can0
-
You can see CAN bus raw data by:
candump can0
-
Drag slider bars (in Grasshopper) then you will see something similar to this:
- Setup SocketCAN interface on
can0
with bitrate 1 Mbps.sudo ip link set can0 up type can bitrate 1000000
- Record CAN log.
candump -L can0 > can.log
We use JSON format to transmit data between Grasshopper and Raspberry Pi.
{
"data": [
{
"position": {
"x": 0, // row
"y": 0 // column
},
"height": 10
},
{
"position": {
"x": 0,
"y": 1
},
"height": 20
}
]
}
A row-major order is adapted in this system.
A ID in a 0x100
)
Device | ID | Mask |
---|---|---|
Raspberry Pi | 0x000 | 0xF00 |
We assume the ip address of Grasshopper computer is 192.168.0.2
.
cd CanbusController/test
./Json2UdpClient.py -i 192.168.0.2 -f grasshopper_output.json
- Start service
cd CanbusController ./Json2UdpClient.py -i 192.168.0.2 -f grasshopper_output.json -c vcan0
- Play recorded CAN bus data on
vcan0
.cd CanbusController/test canplayer vcan0=vcan0 -I ./CanbusController/test/can2udp.log
- Setup SocketCAN interface on
can0
with bitrate 1 Mbps.sudo ip link set can0 up type can bitrate 1000000
- Play CAN log.
canplayer can0=vcan0 -I ./CanbusController/test/udp2can.log