home *** CD-ROM | disk | FTP | other *** search
- { ROS.MDM - Remote Operating System Modem Dependent Routines }
-
- { File: APPLE-SM.MDM
- Description: Driver for Apple with External Modem 'AT' compatible
- Date: 5/24/87
- Author David Leffler
- Credits See Below
-
- Extracted: SM12.MDM
- Description: This driver set is designed to support 'AT' compatible modems.
- Date: 7/28/85
- Authors: Jacques Durosier, Steve Fox
- Credits: Chris Hueuser, Richard Transue, Steve Holtzclaw
-
- Description: Small changes made, including default to 1200 baud operation.
- Date: 9/1/85
- Author: Mick Gaitor
- }
- {** Modem drivers **}
-
- { 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.
-
- The following hardware configuration is assumed:
-
- DCD (pin 8) is supported
- DTR (pin 20) is supported
- RI (pin 22) is not supported
-
- The following modem default switches are assumed:
-
- 1 = up DTR supported, do not force to always logic true.
- 2 = down Send result codes as digits when in command state.
- (If using ROSQX.MCH, this switch position doesn't matter - [MAG])
- 3 = down Result codes are sent to the terminal.
- 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.
- }
-
- { To get this to work on an External Modem off an Apple // some changes
- had to be made. First all External modems have a continuous carrier so the
- check for carrier would hang the program. Second the modem initializer must
- set the modem for numeric return codes since mdresult won't work unless it
- gets numbers.
-
- You may have to set some of the modem strings (i.e. Md_init or any others
- that send straight Hayes Compatable type commands) to your particular Modem.
- }
-
- const
-
- { Modem result codes }
-
- OKAY = '0'; { Command executed with no errors }
- CONNECT300 = '1'; { Carrier detect at 300 bps }
- RING = '2'; { Ring signal detected }
- NOCARRIER = '3'; { Carrier lost or never heard }
- ERROR = '4'; { Error in command execution }
- CONNECT1200 = '5'; { Carrier detect at 1200 bps }
- CONNECT2400 = '10'; { Carrier detect at 2400 bps }
-
- function mdresult: Str3;
- { Get result code from modem }
- var
- count: integer;
- ch: char;
- result: Str3;
- begin
- result := '';
- repeat
- repeat
- until ch_inprdy;
- ch := chr(ch_inp);
- if ch in ['0'..'9']
- then result := result + ch;
- if length(result) > 2
- then delete(result, 1, 1)
- until ch = CR;
- 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: byte;
- i, j: integer;
- begin
- repeat
- while ch_inprdy do { Clear any inputs }
- begin
- bt := ch_inp;
- end;
- i := 1;
- repeat
- bt := ord(st[i]);
- ch_out(bt); { Send the character }
- j := 500;
- repeat { Loop until ready or timeout }
- j := pred(j)
- until ch_inprdy or (j <= 0);
- OK := ((bt = ch_inp) and (j > 0)); { Check for correct echo }
- i := succ(i)
- until (not OK) or (i > length(st));
- until OK;
- end;
-
- procedure mdhangup;
- { Hangup modem }
- var
- i: integer;
- begin
- { Break before disconnect not implemented }
- ch_off; { Hangup NOW! }
- delay(1000);
- ch_on;
- for i := 1 to 3 do
- ch_out(ord(ETX));
- delay(1500);
- repeat
- mdsend('AT H0'+CR)
- until mdresult = OKAY;
- end;
-
- procedure mdbusy;
- { Take modem off hook to present a busy signal to incoming callers }
- begin
- repeat
- mdsend('AT H1M0'+CR)
- { NOTE: 'M0' must be last command on line in order to work }
- { properly on the Prometheus ProModem 1200 [MAG] }
- until mdresult = OKAY
- 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: Str3;
- begin
- Write('');
- mdsend('AT A'+CR);
- result := mdresult;
- { Why not CASE here? }
- if result = CONNECT300 { Reformatted stmt [MAG] }
- then
- ch_set(300)
- else
- if result = CONNECT1200
- then
- ch_set(1200)
- (* Un-comment this if you can handle 2400 baud --
- else
- if result = CONNECT2400
- then
- ch_set(2400)
- *)
- else
- mdhangup;
- delay(500); { Make sure carrier is stable }
- while ch_inprdy do { Clear any inputs }
- bt := ch_inp;
- 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 }
- (* Un-comment this if you can handle 2400 baud --
- If so, don't forget to remove the "ch_set(1200);" above...
- ch_set(2400); { Set the channel speed }
- *)
- repeat
- mdsend('AT V0'+CR); { Make modem return numeric codes }
- until mdresult = OKAY;
- repeat
- mdsend('AT X2 H0 M0 S2=3' + CR); { Set Apple Personal Modem Extended Codes }
- until mdresult = OKAY;
- while ch_inprdy do { Clear any inputs }
- bt := ch_inp;
- end;
-