home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
COMMS
/
PMODEM.ARC
/
ROS.MDM
< prev
next >
Wrap
Text File
|
1991-08-11
|
8KB
|
268 lines
{ ROSMDM.INC - Remote Operating System Modem Dependent Routines }
{ File: ADC4.MDM-----> SMARTEAM.MDM
Description: This driver is designed to support modems which use the 'AT'
command set such as the Hayes Smartmodem, the Courier 2400, and
others. It ensures that the modem has correctly received the
command sent from the computer by monitoring the echo from the
modem. This prevents potential problems from modems which
reset or lose characters when a call and a command are received
simultaneously.
Date: 7/28/28
Authors: Jacques Durosier, Steve Fox
Credits: Chris Hueuser, Richard Transue, Steve Holtzclaw
Description: Make computer independent by using calls to channel drivers
instead of direct port accesses, comment update, and code
cleanup.
Date: 9/7/85
Author: Mick Gaitor, Steve Fox
Description: Improve operation.
Date: 10/26/85
Author: Steve Fox
Description: Use verbal result codes instead of numeric so that modems
which do not have a verbal/numeric switch can use closed loop
driver.
Date: 4/13/86
Author: Steve Fox
Description: Added code to turn speaker off and comment switch settings
for the ADC 1200 Phone Modem (10) switches.
Date: 6/12/86
Author Terry Smith
The following hardware configuration is assumed:
DCD (pin 8) is supported and used by the channel procedures
DTR (pin 20) is supported and used by the channel procedures
RI (pin 22) is not supported
For the Courier 2400 and the Smarteam 1200, the switches should be set as
follows:
1 = up DTR supported, do not force to always logic true.
2 = up Send result codes as digits.
3 = down Send result codes to the host.
4 = up Echo characters when in command state.
5 = down Do not answer the telephone.
6 = up DCD supported, do not force to always logic true.
7 = up Single line RJ11 telephone connection to modem.
8 = down Enables modem command recognition when in command state.
For the ADC 1200 Phone Modem: Remember UP = Open Down = On
1 = down Enable command recognition
2 = N/A Activates beep (your choice)
3 = up Use Hayes command set
4 = down Do not answer calls
5 = up Echo commands in command mode
6 = down Send result codes
7 = up Send result codes in English
8 = up DTR supported
9 = N/A Auto redial selector
10 = up Respond to DCD
}
const
{ Modem command strings }
mdCmdInit = 'ATH0S0=0S2=3E1X1V1Q0M0'^M;
{ AT = get attention
H0 = ensure phone hung up
S0=0 = disable modem auto answer function
S2=3 = change escape code from '+' to ETX
E1 = echo on
X1 = extended response set
V1 = word response
Q0 = send modem responses
}
mdCmdBusy = 'ATH1'^M;
mdCmdHangup = 'ATH'^M;
mdCmdAns = 'ATA'^M;
{ Modem result codes }
mdRspOkay = 'OK'; { Command executed with no errors }
mdRspCnct3 = 'CONNECT'; { Carrier detect at 300 bps }
mdRspRing = 'RING'; { Ring signal detected }
mdRspNoCar = 'NO CARRIER'; { Carrier lost or never heard }
mdRspError = 'ERROR'; { Error in command execution }
mdRspCnct12 = 'CONNECT 1200'; { Carrier detect at 1200 bps }
mdRspCnct24 = 'CONNECT 2400'; { Carrier detect at 2400 bps }
mdRspOffhk = 'OFF HOOK'; { Modem off hook}
type
Str13 = string[13];
procedure mdQuiet;
{ Wait for 100 ms of silence }
var
i: integer;
begin
i := 0;
repeat
if ch_inprdy
then
begin
i := ch_inp;
i := 0
end
else
begin
delay(5);
i := succ(i)
end
until i >= 20;
end;
function mdReady(sec: integer): boolean;
{ Check for input from the modem }
var
ctr: integer;
begin
ctr := round(6.0 * lps);
while (not ch_inprdy) and (sec > 0) do { Loop until ready or timeout }
begin
ctr := pred(ctr);
if ctr <= 0
then
begin
sec := pred(sec);
ctr := round(6.0 * lps)
end
end;
mdReady := sec > 0
end;
function mdReply(bt: byte; sec: integer): boolean;
{ Compare the input to what was sent out }
begin
if mdReady(sec)
then mdReply := bt = ch_inp
else mdReply := FALSE
end;
function mdResult: Str13;
{ Get result code from modem }
var
ch: char;
result: Str13;
begin
result := '';
repeat
if mdReady(5)
then ch := chr($7F and ch_inp) { Get input }
else
begin
result := mdRspError;
ch := LF
end;
if ch in [' '..'_']
then result := result + ch;
if length(result) > 12
then delete(result, 1, 1)
until ch = LF;
gotoxy (1,1);
mdResult := result
end;
function mdCommand(stg: StrPr; sec: integer): Str13;
{ Send a command string to the modem }
var
OK: boolean;
bt: byte;
i: integer;
begin
mdQuiet;
i := 1;
repeat
bt := ord(stg[i]);
i := succ(i);
ch_out(bt); { Send the character }
OK := mdReply(bt, sec)
until (not OK) or (i > length(stg));
if OK
then OK := mdReply(ord(CR), sec);
if OK
then OK := mdReply(ord(LF), sec);
if OK
then mdCommand := mdResult
else mdCommand := mdRspError
end;
procedure mdInit;
{ Ensure the modem is hung up, initialized, and ready to wait for a ring. }
var
tries: integer;
begin
tries := 3;
ch_init; { Initialize the remote channel }
ch_on;
ch_set(1200); { Set the channel speed }
repeat
tries := pred(tries)
until (mdCommand(mdCmdInit, 5) = mdRspOkay) or (tries <= 0);
mdQuiet
end;
procedure mdBusy;
{ Take modem off hook to present a busy signal to incoming callers }
var
tries: integer;
begin
tries := 3;
repeat
tries := pred(tries)
until (mdCommand(mdCmdBusy, 5) = mdRspOkay) or (tries <= 0)
end;
procedure mdHangup;
{ Hangup modem }
var
i, tries: integer;
result: Str13;
begin
tries := 3;
repeat
ch_off;
delay(500);
ch_on;
if ch_carck
then
begin
delay(1000);
for i := 1 to 3 do
ch_out(ord(ETX));
delay(1000);
result := mdCommand(mdCmdHangup, 5)
end;
tries := pred(tries)
until not ch_carck or (tries <= 0)
end;
function mdRing: boolean;
{ Determine if the phone is ringing }
begin
if ch_inprdy
then mdRing := mdResult = mdRspRing
else mdRing := FALSE
end;
procedure mdAns;
{ Answer call and set system to correct baud rate }
var
result: Str13;
begin
result := mdCommand(mdCmdAns, 35); { Let the modem answer }
if result = mdRspCnct3
then ch_set(300)
else if result = mdRspCnct12
then ch_set(1200)
(* else if result = mdRspCnct24
then ch_set(2400)
*) else mdHangup;
mdQuiet
end;