#!/bin/bash

. lib.sh

ids="$(seq 0 20 300)"


main() {
    lastid=0
    for i in $ids; do
	sshgw "for i in \$(seq $lastid $i); do cangw -A -s can0 -d can1 -f \$(printf %x \$i):7ff; done"
	lastid=$((i+1))
	latester -d can0 -d can1 -d can2 -c $COUNT -i 0 $(traffic_and_length 2) -n len-$i
    done
}

ADDITIONAL_PLOTS=log

plot_cmds() {
    if [[ "$1" = "" ]]; then
	range=0:0.2
	echo "set logscale y"
    else
	range=0.01:100
	echo "set logscale xy"
    fi
    cat <<EOF
set title "Different lengths of filter list, only the last one matches"
set grid xtics mxtics ytics mytics lw 1, lw 0.5
set xlabel "GW latency [ms]"
set ylabel "Latency profile [frames]"
plot [$range] [1:$COUNT] \\
EOF
    lt=1
    for i in $ids; do
	echo_plot "\"len-$i-hist.txt\" with lp lt $lt title \"List length $((i+1))\""
        lt=$((lt+1))
    done
}
    
test_end