#!/bin/sh

#Set up the test Environment for pad_tests

# Restart the VCOM software after reconfiguration

re_st_start()
{

vcom_rst -f 0
vcom_dl 0
vcom_stat 0
vcom_cfg 0
}

#
# Confiuration files for X25
#

echo "TYPE = X25
L3PLPMODE = DCE
LAPB_MODE = DCE
LAPB_phy_if = DCE
LAPB_MAXFRAME = 4096
LAPB_BAUD = 1638400
X25_VSN = 84
HTC = 255 " > /tmp/x25port.0D
    
echo "TYPE = X25
L3PLPMODE = DTE
LAPB_MODE = DTE
LAPB_phy_if = DTE
LAPB_MAXFRAME = 4096
LAPB_BAUD = 0
X25_VSN = 84
HTC=255 " > /tmp/x25port.0B

xcf -b0 -cb /tmp/x25port
xcf -b0 -cd /tmp/x25port

# Make a fresh start for the test
re_st_start

# remove the files created for xcf
rm /tmp/x25port.0B
rm /tmp/x25port.0D

# Clear the screen i.e ready to take the input
clear_scr

while :
do
echo "Enter Number of Connections to be made : \c"
read Num_cnct

if [ $Num_cnct -lt 1 -o $Num_cnct -gt 255 ]
then
	echo "Invalid Number of connections."
else
	break
fi
done

while :
do
echo "Enter Test number : \c"
read Test_num

if [ $Test_num -lt 1 -o $Test_num -gt 3 ]
then
	echo "Invalid Test Number."
else
	break
fi
done

while :
do
echo "Enter board number : \c"
read brd_num

if [ $brd_num -lt 0 -o $brd_num -gt 3 ]
then
	echo "Invalid board Number."
else
	break
fi
done

echo "Enter Subnet Id : \c"
read subnet_id

if [ x$Test_num = x1 ]
then
	echo "Enter Number of packets to be sent: \c"
	read Pkt_num
	echo "Enter Packet Size: \c"
	read Pkt_sz
fi

kk=1
while [ $kk -le 1 ]
do

xx=1
while : 
do
	if [ $xx -le $Num_cnct ]
	then
		echo "####### Starting the $xx x1 #######"
		xtest1 &
		xx=`expr $xx + 1`
	else
		break
	fi
done

xx=1
while :
do
	if [ $xx -le $Num_cnct ]
	then
		echo "####### Starting the $xx x2 #######"
		if [ x$Test_num = x1 ]
		then
			xtest2 -b$brd_num -s$subnet_id -t$Test_num -n$Pkt_num \
				-z$Pkt_sz &
		else
			xtest2 -b$brd_num -s$subnet_id -t$Test_num &
		fi

		xx=`expr $xx + 1`
	else
		break
	fi
done

#) >> x25.log 2>&1

subnet_id=c
kk=`expr $kk + 1`
done
