home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 3 Comm
/
03-Comm.zip
/
phon22.zip
/
PHONE22.SCR
< prev
Wrap
Text File
|
1994-06-30
|
9KB
|
440 lines
!
! Copyright (c) 1993
! by CompuServe Incorporated, Columbus, Ohio
!
! The information in this software is subject to change without
! notice and should not be construed as a commitment by CompuServe.
!
! v2.2a 6/28/94 Mike Tannenbaum 75110,2037 Send comments by email only
!
! PHONE:
! Contains modem/phone related logic.
! Success: returns %Success
! Failure: saves error msg in %FailureMsg and returns %Failure
!
!+V
! "3.5"
!-V
MdmCmd = "";
Z_Sent = %FALSE;
WaitTime = 10;
ifndef %mdm_UserID = "";
ifndef %mdm_Password = "";
ifndef %mdm_ECOn = "";
ifndef %mdm_DCOn = "";
if %DialType = 2 goto Direct_Connect;
goto Do_Phone_Connect;
!
! Subroutines
!
Hangup_Before_Connect:
define %LOCAL = 2;
call %Dir & "disconct.scr" () : Result;
return;
Two_Tries_Hangup:
gosub Hangup_Before_Connect;
goto Send_Reset_String;
!
! Main Program: Start_Connect
!
Do_Phone_Connect:
RingLimit = 5;
RingCount = 0;
UsingModem = %FALSE;
on cancel goto Phone_Cancelled;
if %DialType = 0 goto Get_Tone_Str;
DialTypeStr = %mdm_Pulse_Dial; ! Type = DT_Pulse
goto Init_Modem;
Get_Tone_Str:
DialTypeStr = %mdm_Tone_Dial; ! Type = DT_Tone
Init_Modem:
show "Initializing modem";
MsgStr = "Dialing " & %Phone;
tries = 0;
Send_Reset_String:
if (%mdm_Reset = "") goto Modem_OK;
sendm %mdm_Prefix;
sendm %mdm_Reset;
sendm %mdm_Suffix;
Send_Wait:
wait
"User Id" goto Send_User_ID,
"Password" goto Send_Password,
%mdm_Ack goto Modem_OK,
"0" goto Modem_OK,
"ERROR" goto Send_Z
until 40;
tries = tries + 1;
if tries = 2 goto Two_Tries_Hangup; ! Two failures to send Reset -
! hang up and try twice more.
if tries < 4 goto Send_Reset_String;
wait until WaitTime;
define %ErrorCode = 10;
FailStr = "Modem not responding";
goto Phone_Failed;
Send_User_ID:
!
! For those modems that support password security...
!
send %mdm_UserID & "^M";
goto Send_Wait;
Send_Password:
!
! For those modems that support password security...
!
send %mdm_Password & "^M";
wait
"User id" goto Modem_Security_Error,
%mdm_Ack goto Send_Reset_String,
"0" goto Send_Reset_String
until 100;
goto Send_Reset_String;
Modem_Security_Error:
define %ErrorCode = 11;
define %FailureMsg = "Invalid modem security User ID or password";
exit %Fatal;
Send_Z:
if %mdm_Reset = "Z" goto Modem_OK;
if Z_Sent goto Modem_OK;
wait until 5;
Z_Sent = %TRUE;
sendm %mdm_Prefix;
sendm "Z";
sendm %mdm_Suffix;
goto Send_Wait;
Modem_OK:
!show %mdm_Init;
wait until 10;
if (%mdm_Init = "") goto Check_Modem_Speaker;
sendm %mdm_Init;
wait
%mdm_Ack goto Check_Modem_Speaker,
"ERROR" goto Show_Init_Error
until 33;
FailStr = "Modem not responding";
define %ErrorCode = 12;
goto Phone_Failed;
Show_Init_Error:
show "Error in modem command";
wait until 10;
Check_Modem_Speaker:
if (%mdm_Speaker <> 0) goto Check_DC;
MdmCmd = "M0";
Check_DC:
if %mdm_DCOn = "" goto Check_EC;
MdmCmd = MdmCmd & %mdm_DCOn;
goto Wait_Ack;
Check_EC:
if %mdm_ECOn = "" goto Wait_Ack;
MdmCmd = MdmCmd & %mdm_ECOn;
Wait_Ack:
if MdmCmd = "" goto Try_Phone;
wait until 2; ! delay for 300 baud modems
sendm %mdm_Prefix & MdmCmd & %mdm_Suffix;
wait
%mdm_Ack goto Try_Phone,
"ERROR" goto Show_Proto_Error
until 33;
goto Try_Phone;
Show_Proto_Error:
show "Error in modem command";
Try_Phone:
wait until 10;
count = 0;
FailStr = "";
Dial_Phone:
if (count > %Retry) goto Exit_Error;
show MsgStr;
sendm %mdm_Prefix;
sendm DialTypeStr & %Phone;
sendm %mdm_Suffix;
Start_Phone_Loop:
wait
"CARRIER 2400" goto Tcarchk,
"CARRIER 4800" goto Hcarchk,
"CARRIER 9600" goto Ncarchk,
"CARRIER 14400" goto Fcarchk,
"CONN" goto Three_Connect,
%mdm_Failure goto Modem_Failure,
"No Dial" goto No_Dial_Tone,
"Dial Complete" goto Dial_Complete,
"Busy" goto Line_Busy,
"Ring" goto Remote_Ring
until 556;
FailStr = "Dialing failed";
goto End_Phone_Loop;
Tcarchk:
BdnoStr = "2400 bps DCE ";
goto Proto_Check;
Hcarchk:
BdnoStr = "4800 bps DCE ";
goto Proto_Check;
Ncarchk:
BdnoStr = "9600 bps DCE ";
goto Proto_Check;
Fcarchk:
BdnoStr = "14400 bps DCE ";
goto Proto_Check;
Proto_Check:
wait
"PROTOCOL: V.42" goto VFour_Test,
"PROTOCOL: LAP" goto VFour_Test,
"PROTOCOL: MNP" goto Mnp_Test,
"PROTOCOL: ALT" goto Mnp_Test,
"PROTOCOL: NONE" goto Cnum_Test,
"CONN" goto Success_Test
until 40;
goto Comp_Test;
VFour_Test:
BdnoStr = BdnoStr & "LAP-M ";
goto Comp_Test;
Mnp_Test:
BdnoStr = BdnoStr & "MNP ";
goto Comp_Test;
Comp_Test:
wait
"COMPRESSION: V.42BIS" goto Bis_Test,
"COMPRESSION: MNP" goto Mfive_Test,
"COMPRESSION: CLASS 5" goto Mfive_Test,
"COMPRESSION: NONE" goto Cnum_Test,
"CONN" goto Success_Test
until 20;
goto Cnum_Test;
Bis_Test:
BdnoStr = BdnoStr & "V.42bis ";
goto Cnum_Test;
Mfive_Test:
BdnoStr = BdnoStr & "MNP5 ";
goto Cnum_Test;
Cnum_Test:
wait
"CONN" goto Success_Test
until 90;
goto Modem_Failure;
Success_Test:
wait
"ECT 2400" goto Twenty_Test,
"ECT 4800" goto Eight_Test,
"ECT 9600" goto Ninety_Test,
"ECT 14400" goto Ndce_Test,
"ECT 19200" goto Fdte_Test,
"ECT 38400" goto Dbldte_Test
until 50;
goto Norpt_Test;
Ndce_Test:
BdnoStr = BdnoStr & "14.4kb DTE";
show BdnoStr;
goto Modem_Success;
Fdte_Test:
BdnoStr = BdnoStr & "19.2kb DTE";
show BdnoStr;
goto Modem_Success;
Dbldte_Test:
BdnoStr = BdnoStr & "38.4kb DTE";
show BdnoStr;
goto Modem_Success;
Eight_Test:
BdnoStr = BdnoStr & "4800 bps DTE";
show BdnoStr;
goto Modem_Success;
Twenty_Test:
BdnoStr = BdnoStr & "2400 bps DTE";
show BdnoStr;
goto Modem_Success;
Ninety_Test:
BdnoStr = BdnoStr & "9600 bps DTE";
show BdnoStr;
goto Modem_Success;
Norpt_Test:
show BdnoStr;
goto Modem_Success;
Three_Connect:
wait
"ECT 38400" goto Super_Connect,
"ECT 19200" goto Fast_Connect,
"ECT 14400" goto Fourteen_Connect,
"ECT 12000" goto Twelve_Connect,
"ECT 9600" goto Ninesix_Connect,
"ECT 7200" goto Seven_Connect,
"ECT 4800" goto Halfnine_Connect,
"ECT 2400" goto Twofor_Connect,
"ECT 1200^M" goto Onetwo_Connect,
"ECT 1200/" goto Onetwo_Connect
until 20;
show "Connect: 300 or Unknown bps";
goto Modem_Success;
Super_Connect:
Bdrt = "Connect: 38400 bps DTE";
goto Arqchk;
Fast_Connect:
Bdrt = "Connect: 19200 bps DTE";
goto Arqchk;
Fourteen_Connect:
Bdrt = "Connect: 14400 bps";
goto Arqchk;
Twelve_Connect:
Bdrt = "Connect: 12000 bps";
goto Arqchk;
Ninesix_Connect:
Bdrt = "Connect: 9600 bps";
goto Arqchk;
Seven_Connect:
Bdrt = "Connect: 7200 bps";
goto Arqchk;
Halfnine_Connect:
Bdrt = "Connect: 4800 bps";
goto Arqchk;
Twofor_Connect:
Bdrt = "Connect: 2400 bps";
goto Arqchk;
Onetwo_Connect:
Bdrt = "Connect: 1200 bps";
goto Arqchk;
Arqchk:
wait
"REL" goto Lastst,
"ARQ" goto Lastst
until 15;
show Bdrt;
goto Modem_Success;
Lastst:
Bdrt = Bdrt & " w/ Error Control";
show Bdrt;
Modem_Success:
wait until 15;
Direct_Connect:
exit %Success;
Modem_Failure:
FailStr = "Dialing unsuccessful, check phone number";
wait until WaitTime;
goto End_Phone_Loop;
No_Dial_Tone:
FailStr = "No Dialtone";
define %ErrorCode = 13;
goto Exit_Failure;
Dial_Complete:
MsgStr = "Dialed " & %Phone & ", awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
Line_Busy:
FailStr = "Number is busy";
wait until 2 * WaitTime;
send %CR;
wait
%mdm_Success goto End_Line_Busy,
%mdm_Failure goto End_Line_Busy,
"No Dial" goto End_Line_Busy,
"Dial Complete" goto End_Line_Busy,
"Busy" goto End_Line_Busy,
"Ring" goto End_Line_Busy
until 56;
End_Line_Busy:
wait until WaitTime;
goto End_Phone_Loop;
Remote_Ring:
RingCount = RingCount + 1;
if RingCount <= RingLimit goto Show_Ringing;
FailStr = "No answer";
goto End_Phone_Loop;
Show_Ringing:
MsgStr = %Phone & " is ringing, awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
End_Phone_Loop:
MsgStr = FailStr & ", redialing " & %Phone;
count = count + 1;
goto Dial_Phone;
Phone_Cancelled:
gosub Hangup_Before_Connect;
exit Result;
Phone_Failed:
if FailStr <> "" goto Exit_Fatal;
FailStr = "Dialing failed";
Exit_Fatal:
define %FailureMsg = FailStr;
exit %Fatal;
Exit_Error:
define %ErrorCode = 14;
Exit_Failure:
define %FailureMsg = FailStr;
exit %Failure;