Listing 2: asap.scr
;Usage pqcall.scr <messagefile> <phonenumber>
set line /dev/modem ; Set for second serial port on a SPARCstation die
set modem hayes ; Set for Hayes modem
set local-echo on ; Echo local (doesn't seem to work)
set duplex full ; Echo local (doesn't seem to work)
set parity even ; Should set us to 7e1
set speed 19200 ; 1200 is max speed AirTouch seems to accept
;set output pacing 1 ; Seems needed to work with AirTouch
set input echo on ; Need to watch.
set debug session
set take error off ; To handle EOF on READ (doesn't seem to do anything)
;output at s11=25 ; Set speed dialing to 25ms bursts
output at s11=50 ; Set speed dialing on to 50ms bursts
output at s13=50 ; Set speed dialing off to 50ms bursts
out atm0
open read \&@[2] ; Open the file message.txt read-only
if fail goto noinput
read \%p ; Read a line (presumably containing a pin)
if fail goto nofirst
read \%m ; Read a line (presumably containing a message)
if fail goto nofirst
read \%c ; Read a line (presumably containing a checksum)
if fail goto nofirst
read \%d ; Read a line (presumably containing a cr delimeter)
if fail goto nofirst
:makecall
hangup
dial \&@[3] ; Dial second parameter
;define echo echo Error: \%1, end ; Error-handling macro.
;set input timeout proceed ; Don't quit if INPUT fails.
;set input case ignore ; Alphabetic case doesn't matter.
output \13 ; Send carriage return (ASCII 13).
output \13 ; Send carriage return (ASCII 13).
input 10 ID= ; Wait for ID request
if fail goto noid
output {\27PG1\13} ; Send <ESC>PG1<CR> to go into automatic mode
if fail echo \7I can't send the pg1!, what the hell is going on here?!
input 5 \006 ; Wait for <CR><ACK><CR>
if fail goto nofirsthand
def \%i 0 ; Initialize the block counter to zero
:beginwhile
output \2\%p\13\%m\13\3\%c\13 ; Send the block (ugly huh?)
if fail echo \7I can't send the block!, what the hell is going on here?!
input 5 \006 ; Wait for <CR><ACK><CR>
if success goto contwhile
reinput 0 \21
if success GOTO gotnak
reinput 0 \27
if success GOTO goteot
echo \7I didn't get anything I know about when I was hoping for an <ACK>, I'll try the call
again!
goto makecall
:contwhile
read \%p ; Read a line (presumably containing a pin), bug out of while if I can't read one
if fail goto endwhile
read \%m ; Read a line (presumably containing a message)
if fail goto trunc
read \%c ; Read a line (presumably containing a checksum)
if fail goto trunc
read \%d ; Read a line (presumably containing a cr delimeter)
if fail goto trunc
goto beginwhile
:endwhile
close read ; Close the message file
output \13 ; Get outta here!
hangup
quit
:noinput
echo \7 I couldn't open the input file, help!
goto die
:nofirst
ECHO \7 I couldn't get the first record of the file, help!
ECHO Here is what I got
echo \v(input)
goto die
:noid
ECHO \7 I didn't even get the ID prompt, I'll try the call again
GOTO makecall
:nofirsthand
ECHO \7I didn't even get the initial <CR><ACK><CR>, I'll try the call again!
GOTO makecall
:gotnak
echo OK I got a <NAK> I'll just resend the packet
goto beginwhile
:goteot
echo \7I got an <EOT> I'll try the call again
;goto makecall
goto contwhile
:trunc
echo \7It looks like the message input file is truncated, help!
goto die
:die
echo \7\7\7 I am dying!!!
close read ; Close the message file
output \13 ; Get outta here!
hangup ;
quit 1
;End of File
|