#
# ADVANTECH Industrial Comunication Multiport Card Make Node Utility
#
#    Usage : pclmknod
#

#!/bin/sh

#Tty naming : ttyM[port idx]
TTYNAME=ttyP

#Callout device naming : cup[port idx]
CUANAME=cup

echo "ADVANTECH Industrial Comunication Multiport Card Make Node Utility"
echo "Please input device major number(Enter for default=30):"
read MAJOR
if [ ! $MAJOR ] ; then
    MAJOR=30
fi
echo "major=" $MAJOR
echo ""

echo "Please input callout device major number(Enter for default=35):"
read CUMAJOR
if [ ! $CUMAJOR ] ; then
    CUMAJOR=35
fi
echo "major=" $CUMAJOR
echo ""

echo "Please input total port number (6-128, Enter for default=20):"
read PORTS
if [ ! $PORTS ] ; then
    PORTS=20
fi
echo "ports=" $PORTS
echo ""

#
# make node loop
#
echo "Make tty device..."
id=64
port=0
while [ $port -lt $PORTS ]

    do
        
	[ -c /dev/$TTYNAME$port ] && rm -f /dev/$TTYNAME$port
	[ -c /dev/$CUANAME$port ] && rm -f /dev/$CUANAME$port

	echo  /dev/$TTYNAME$port /dev/$CUANAME$port $port
        mknod /dev/$TTYNAME$port c $MAJOR $id
        mknod /dev/$CUANAME$port c $CUMAJOR $id

	chmod a+wx /dev/$TTYNAME$port
	chmod a+wx /dev/$CUANAME$port

        port=`expr $port + 1`
	id=`expr $id + 1`

done

