! Xyplex CCL   $RCSfile: GV_TP_Serial_High_Speed,v $
!             $Revision: 1.2 $
!                 $Date: 1994/01/06 20:52:29 $
!
! 08/02/92 TelePort Gold draft
! 10/23/92 CTC Switched to new script written by RBH
! 10/26/92 CTC Fix for International calling(S7=60)
! 11/11/92 CTC Rewrote the Hang up section of the script to use AT\Y
! 12/07/92 CTC Fix for Shiva LanRover/L image 1.0 problem
!
@ORIGINATE
@ANSWER
!
! Talk to the modem at 19,200 bps.  
!
serreset 19200, 0, 8, 1
!
! &f    - recall factory settings
! &d0   - Ignore DTR
! &k3   - Enable Hardware flow control
! w2    - Connect result code reports modem speed
! \q3   - Use RTS/CTS flow control in full-duplex mode
! \k0   - Enter command state but do not send break
! \j0   - Disable port rate adjust
! s7=60 - To allow for an international call
!
HSReset 0 1 0 0 0 0
settries 0
matchclr
@LABEL 1
matchstr 1 4 "OK\13\10"
write "AT&f&d0&k3\\k0\\j0w2\\q3s7=60\13"
matchread 30
inctries
iftries 2 59
! Modem is not responding, reset and send a break
SBreak
jump 1
!
! Next, Set up the configuration: Turn off auto answer and command echo.   
!
! S0=0 - Don't answer calls
! E0   - Turn command echo off
! 
@LABEL 4
matchclr
pause 5
matchstr 1 5 "OK\13\10"
write "ATS0=0E0\13"
matchread 30
jump 59
!
! Note: When the "\Nn" commands of the TP Serial are like those of the PP we
!       will need to change the \Nn setting to allow a V.42 connection without
!       a fallback to MNP4
!
! \n0 - disable v.42 autoreliable
! %c0 - turn off MNP5 compression
! 
@LABEL 5
pause 5
matchstr 1 6 "OK\13\10"
write "AT\\n0%c0\13"
matchread 30
jump 59
!
!
! If speaker on flag is true, jump to label 8.  Else turn off the speaker
!
@LABEL 6
ifstr 2 8 "1"
pause 5
matchstr 1 8 "OK\13\10"
write "ATM0\13"
matchread 30
jump 59
!
! The modem is ready so enable answering, or originate a call
!
@LABEL 8
pause 5
ifANSWER 30
note "Dialing ^1" 3
write "ATDT^1\13"
!
@LABEL 9
matchstr 1  11 "CONNECT 1200\13\10"
matchstr 2  12 "CONNECT 2400\13\10"
matchstr 3  13 "CONNECT 4800\13\10"
matchstr 4  19 "CONNECT 7200\13\10"
matchstr 5  14 "CONNECT 9600\13\10"
matchstr 6  20 "CONNECT 12000\13\10"
matchstr 7  18 "CONNECT 14400\13\10"
matchstr 8  50 "NO CARRIER\13\10"
matchstr 9  50 "ERROR\13\10"
matchstr 10 52 "NO DIAL TONE\13\10"
matchstr 11 53 "BUSY\13\10"
matchstr 12 54 "NO ANSWER\13\10"
matchread 700
jump 59
!
! Notice that all we do for different connect speeds is issue a 
! "CommunicatingAt" command.  Remember, we locked the interface speed
! to 19,200 bps so we don't want to reset the serial speed after we connect.
! CommunicatingAt tells ARA what the actual line speed is so that it
! can set it's timers appropriately.  I guess your performance would be
! sub-optimal if you don't set this...
!
@LABEL 11
note "Communicating at 1200 bps." 2
CommunicatingAt 1200
jump 15
!
@LABEL 12
note "Communicating at 2400 bps." 2
CommunicatingAt 2400
jump 15
!
@LABEL 13
note "Communicating at 4800 bps." 2
CommunicatingAt 4800
jump 15
!
@LABEL 19
note "Communicating at 7200 bps." 2
CommunicatingAt 7200
jump 15
!
@LABEL 14
note "Communicating at 9600 bps." 2
CommunicatingAt 9600
jump 15
!
@LABEL 20
note "Communicating at 12000 bps." 2
CommunicatingAt 12000
jump 15
!
@LABEL 18
note "Communicating at 14400 bps." 2
CommunicatingAt 14400
jump 15
!
!
@LABEL 15
HSReset 0 1 0 0 0 0
ifANSWER 16
pause 30
@LABEL 16
exit 0
!
! @ANSWER
! Set up the modem to answer
!
@LABEL 30
write "ATS0=1\13"
matchstr 1 31 "OK\13\10"
matchread 30
jump 59
!
@LABEL 31
matchstr 1  32 "RING\13\10"
matchstr 2  11 "CONNECT 1200\13\10"
matchstr 3  12 "CONNECT 2400\13\10"
matchstr 4  13 "CONNECT 4800\13\10"
matchstr 5  19 "CONNECT 7200\13\10"
matchstr 6  14 "CONNECT 9600\13\10"
matchstr 7  20 "CONNECT 12000\13\10"
matchstr 8  18 "CONNECT 14400\13\10"
matchstr 9  50 "NO CARRIER\13\10"
matchstr 10 50 "ERROR\13\10"
matchstr 11 52 "NO DIAL TONE\13\10"
matchstr 12 53 "BUSY\13\10"
matchstr 13 54 "NO ANSWER\13\10"
matchread 700
jump 31
!
@LABEL 32
userhook 1
note "Answering phone..." 2
jump 31
!
! 50: error messages
!
@LABEL 50
exit -6021
!
@LABEL 52
exit -6020
!
@LABEL 53
exit -6022
!
@LABEL 54
exit -6023
!
@LABEL 59
exit -6019
!
! Hang up the modem
!
@HANGUP
@LABEL 60
settries 0
serreset 19200, 0, 8, 1
HSReset 0 1 0 0 0 0
@LABEL 61
!
! In order to hang up quickly, we go into command state and attempt a reliable
! connection. While we are attempting to re-establish
! the connection we hit return and cancel the attempt causing the modem to
! hang up.
!
SBreak
pause 20            ! allow time for modem to return from break
Flush               ! prevent disconnect garbage
write "\13"         ! start on a clean line
@LABEL 96
matchclr
matchstr 1 97 "OK\13\10"
write "AT\13"
matchread 30
Pause 30
inctries
iftries 3 59
jump 96
@LABEL 97
settries 0
matchclr
matchstr 1 62 "NO CARRIER\13\10"
Flush                                  ! prevent disconnect garbage
write "AT\\Y\13"                       ! Attempt to re-establish connection
!pause 2                               ! Causes problems with LanRover/L 1.0
@LABEL 98
write "ho\13ho\13"                 ! Dreaded Christmas Abort re-connect
inctries
iftries 50 125
Jump 98
@LABEL 125
matchread 150                      ! to hang up the modem
@LABEL 62
settries 0
pause 100
!
! recall the factory settings. (see note at top of script)
!
@LABEL 63
matchclr
matchstr 1 92 "OK\13\10"
write "ATZ\13"
matchread 30
inctries
iftries 3 59
jump 63
@LABEL 92
Settries 0
@LABEL 93
matchclr
matchstr 1 64 "OK\13\10"
write "AT&f&d0&k3\\k0\\j0w2\\q3s7=60\13"
matchread 30
inctries
iftries 3 59
jump 93
!
! Turn off auto answer.
! 
! S0=0 - Don't try to answer the phone
!
@LABEL 64
pause 5
matchstr 1 65 "OK\13\10"
write "ATS0=0\13"
matchread 20
!
@LABEL 65
exit 0
