# can_config_template.sh: Template for configuring HIL Tester CAN interfaces
# @copyright: Highly Confidential and Proprietary Information. Copyright (c) Zoox
#
# Date Created: February 7, 2020
# Author: emiddleton
#
# Author's note: Adjust to your system requirements. The info below defaults for
# doorBot

# Configure BDY_CAN1
ip link set can0 name BDY_CAN1
ip link set BDY_CAN1 type can bitrate 500000 restart-ms 100
ip link set BDY_CAN1 txqueuelen 4096

# Configure BDY_CAN2
ip link set can1 name BDY_CAN2
ip link set BDY_CAN2 type can bitrate 500000 restart-ms 100
ip link set BDY_CAN2 txqueuelen 4096

# Bring up all the interfaces
ifconfig BDY_CAN1 up
ifconfig BDY_CAN2 up

# DEPRECATED FOR NOW, BUT SAVING THIS BECAUSE WE MAY
#   REINSTATE THIS AND IT IS SUPER CONVENIENT TO HAVE IT HERE
#   the problem has not been root caused, but occasionally
#   the entire linux IP stack would crash and leave us unable
#   to do anything remotely.

# Configure BDY_CAN2. THIS IS A VIRTUAL CAN BUS
# It is setup to be gatewayed from BDY1 entirely transparently
# modprobe vcan
# modprobe can-gw
# ip link add dev BDY_CAN2 type vcan
# cangw -A -s BDY_CAN2 -d BDY_CAN1 -e
# cangw -A -s BDY_CAN1 -d BDY_CAN2 -e

