
MODEM_PARAMS_FILE=MultiTech
RESET_MODEM=MultiTech-reset
STTY_PARAMS="19200 -echo"
STTY_MODEM="/usr/ucb/stty $STTY_PARAMS"
# changed to reflect new configurability for internationalisation
#INSTALL=modem_config
INSTALL=/tmp/rda_install

#
# NOTE: need to use UCB stty here since we need to adjust output stream
#
findcmd /usr/ucb/stty

write()
{
	echo "$*"
	sleep 6
}

write_modem()
{
	case $2 in
	initialise)
		message "Initialising modem:"
		;;
	
	reinitialise)
		message "Re-initialising modem:"
		MODEM_PARAMS_FILE=${MODEM_PARAMS_FILE}-reinit
		;;
	esac

	message ""
		
	if [ ! -f $INSTALL/$MODEM_PARAMS_FILE ]; then
		terminate Cannot locate modem configuration information
	fi

	while /bin/true
	do
		message "Please ensure that the modem is connected to port" $1
		message "on the machine."
		message ""
		message "Press return when ready:" \\c
		read KEY
	
		if dd if=/dev/null of=/dev/cua/$1 >/dev/null 2>&1
		then
			break
		fi

		message ""
		message "There appears to be a problem opening the modem port"
		message "for access.  This may be due to a bad cable"
		message "connection -- please check!"
		message ""
	done

	install_strmod /dev/cua/$1

	message ""
	message "The modem will now be completely reset to defaults before programming."
	message ""
        (
                while read line
                do
                        message_start "Writing $line"
                        write $line
                        message_done
                done
        ) < $INSTALL/$RESET_MODEM | (
                $STTY_MODEM
 
                cat -
        ) > /dev/cua/$1

	message ""
	message "Please wait while the device is configured -- this will take"
	message "approximately 2 minutes."
	message ""
	message "Note: If the modems SD and RD LEDs do not flicker during the next"
	message "      phase, then an error has occurred or the modem is connected"
	message "      to the wrong port."
	message ""
	
	(
		while read line
		do
			message_start "Writing $line"
			write $line
			message_done
		done
	) < $INSTALL/$MODEM_PARAMS_FILE | (
		$STTY_MODEM

		cat -
	) > /dev/cua/$1
	
	message "The modem has now been configured."
	
	message ""
	message "The modem \"Login\" Password is now set to \"rdCKRdp1\""
	message "The modem \"Setup\" Password is now set to \"RDAPASS1\""
	message ""
	message "To change these default parameters please consult the manual"
	message "If they are changed however, the re-initialise procedure will"
	message "no longer function."
	message ""

}
