#!/bin/bash

. lib.sh

ids="0 $(seq 127 128 2047)"


main() {
    if [ "$kvers" = 3.0.4-rt14-00008-gb2052fd -a "$load" = eth -a $traffic != oneatatime ]; then echo "Skipping eth test"; SKIPPED=1; return; fi
    if [ "$kvers" = 3.4.33-rt47-00004-gc58c9ae -a "$load" = eth -a $traffic != oneatatime ]; then echo "Skipping eth test"; SKIPPED=1; return; fi
    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:0.8
	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