diff --git a/tests/integration/node-can.sh b/tests/integration/node-can.sh index 3a2de91cc..e997adb65 100755 --- a/tests/integration/node-can.sh +++ b/tests/integration/node-can.sh @@ -21,29 +21,100 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . ################################################################################## +# To set up vcan interface use the following commands +# sudo modprobe vcan +# sudo ip link add dev vcan0 type vcan +# sudo ip link set vcan0 up SCRIPT=$(realpath $0) SCRIPTPATH=$(dirname ${SCRIPT}) source ${SCRIPTPATH}/../../tools/villas-helper.sh -CONFIG_FILE=${SCRIPTPATH}/../../etc/examples/nodes/can.conf +CONFIG_FILE=$(mktemp) INPUT_FILE=$(mktemp) OUTPUT_FILE=$(mktemp) CAN_OUT_FILE=$(mktemp) -CAN_IF=vcan0 NUM_SAMPLES=${NUM_SAMPLES:-10} NUM_VALUES=${NUM_VALUES:-3} -# Check if vcan0 interface is present -if [[ ! $(ip link show "${CAN_IF}" up) ]]; then - echo "Did not find any vcan interface ${CAN_IF} or interface is not up" +CAN_IF=$(ip link show type vcan | head -n1 | awk '{match($2, /(.*):/,a)}END{print a[1]}') + +if [[ ! ${CAN_IF} ]]; then + echo "Did not find any vcan interface" exit 99 fi -#sudo modprobe vcan -#sudo ip link add dev vcan0 type vcan -#sudo ip link set vcan0 up +# Check if vcan0 interface is present +if [[ ! $(ip link show "${CAN_IF}" up) ]]; then + echo "Interface ${CAN_IF} is not up" + exit 99 +fi + +cat > ${CONFIG_FILE} << EOF +nodes = { + can_node1 = { + type = "can" + interface_name = "${CAN_IF}" + sample_rate = 500000 + + in = { + signals = ( + { + name = "sigin1", + unit = "Volts", + type = "float", + enabled = true, + can_id = 66, + can_size = 4, + can_offset = 0 + }, + { + name = "sigin2", + unit = "Volts", + type = "float", + enabled = true, + can_id = 66, + can_size = 4, + can_offset = 4 + }, + { + name = "sigin3", + unit = "Volts", + type = "float", + enabled = true, + can_id = 67, + can_size = 8, + can_offset = 0 + } + ) + } + + out = { + signals = ( + { + type = "float", + can_id = 66, + can_size = 4, + can_offset = 0 + }, + { + type = "float", + can_id = 66, + can_size = 4, + can_offset = 4 + }, + { + type = "float", + can_id = 67, + can_size = 8, + can_offset = 0 + } + ) + } + } +} +EOF # Generate test data VILLAS_LOG_PREFIX=$(colorize "[Signal]") \