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
/
BBS
/
C128PICS.ARC
/
C1670.MDM
< prev
next >
Wrap
Text File
|
1991-08-11
|
4KB
|
134 lines
{ ROSMDM.INC - Remote Operating System Modem Dependent Routines }
{ File C1670.mdm
Discription This is the modem routines for the Commodore 1670 (Hayes
Compatable) modem.
date 7/7/89
Author Peter B. Carter
}
const
{ Modem result codes }
OKAY = 'OKAY'; { Command executed with no errors }
CONNECT300 = 'CONNECT'; { Carrier detect at 300 bps }
RING = 'RING'; { Ring signal detected }
NOCARRIER = 'NO CARRIER'; { Carrier lost or never heard }
ERROR = 'ERROR'; { Error in command execution }
CONNECT1200 = 'CONNECT 1200'; { Carrier detect at 1200 bps }
function mdresult: StrStd;
{ Get result code from modem }
var
count,num: integer;
ch: char;
result: StrStd;
begin
result := '';
repeat
num:=0;
repeat
num:=num+1;
if num=3000 then
begin
if result='' then
mdresult := ERROR
else
mdresult := result;
exit;
end;
until ch_inprdy;
ch := chr(ch_inp);
if (ch <> CR) and (ch <> chr(10)) then result := result + ch;
until (ch = CR) and (result <> '');
mdresult := result;
end;
procedure mdsend(st: StrStd);
{ Send a command string to the modem and continue sending until the modem
echoes exactly what was sent. }
var
bt,p: byte;
count : integer;
begin
repeat
ch_purge;
OK:=true;
for p:=1 to length(st) do
begin
ch_out(ord(st[p]));
count:=500;
repeat
count:=pred(count);
until (count = 0) or ch_inprdy;
if count=0 then OK:=false
else
begin
bt:=ch_inp;
if chr(bt)=st[p] then OK:=true
else OK:=false;
end;
if not OK then p:=length(st);
end;
until OK;
end;
procedure mdhangup;
{ Hangup modem }
begin
{ Break before disconnect not implemented }
ch_off; { Hangup NOW! }
while ch_carck do inline(0);
ch_on;
ch_purge;
end;
procedure mdbusy;
{ Take modem off hook to present a busy signal to incoming callers }
begin
mdsend('AT H1' + CR); { Take modem off hook }
end;
function mdring: boolean;
{ Determine if the phone is ringing }
begin
if ch_inprdy
then mdring := (RING = mdresult)
else mdring := FALSE;
end;
procedure mdans;
{ Detect and set system to rate at which modem answered phone }
var
bt: byte;
result: StrStd;
begin
mdsend('AT A' + CR);
delay(2000);
result := mdresult;
if result = CONNECT300
then ch_set(300)
else if result = CONNECT1200
then ch_set(1200)
else if ch_carck then
begin
bt:=inbc($dd01) and 32;
if bt=32 then ch_set(300) else ch_set(1200)
end else mdhangup;
end;
procedure mdinit;
{ Ensure the modem is hung up, initialized, and ready to wait for a ring. }
var
bt: byte;
begin
ch_init; { Initialize the remote channel }
ch_on;
ch_set(1200); { Set the channel speed }
mdsend('ATZ' + CR); { Get the modem's attention }
delay(500);
ch_purge;
mdsend('AT X1 H0 M0 S2=3' + CR);
ch_purge;
end;