chiark / gitweb /
can reprogram santafe
[trains.git] / hostside / fun-randmore
1 #!/bin/sh
2 set -e
3 s=$1
4 while true; do
5         echo
6         which=$(hexdump </dev/urandom -n1 -e '"%d"')
7         if [ $which -ge 64 -a $which -lt 192 ]; then
8                 b1=$(hexdump </dev/urandom -n1 -e '"%d"')
9                 squ=$(($b1 * $b1))
10                 speed=$(($squ / 516))
11                 b2=$(hexdump </dev/urandom -n1 -e '"%d"')
12                 dirn=$(($b2 / 128))
13                 echo which=$which b1=$b1 speed=$speed b2=$b2 dirn=$dirn
14                 ./hostside-old -s$s speed126 2 $speed $dirn
15         fi
16         if [ $which -lt 128 ]; then
17                 value=$(( $which * 16 ))
18                 printf "which=%s value=%s value=0x%x\n" $which $value $value
19                 ./hostside-old -s$s funcs5to8 2 $value
20         fi
21         delay=$(hexdump </dev/urandom -n1 -e '"%d"')
22         delayv=$(( $delay / 2 + 10 ))
23         printf "delay=%d delayv=%d\n" $delay $delayv
24         sleep $delayv
25 done