home *** CD-ROM | disk | FTP | other *** search
- { ROS.MCH - Remote Operating System Clock Routines }
-
- { File: OSBEXEC.MCH
- Description: Osborne Executive driver set.
- All pertinent data and some subprogram "strategy" extracted
- from Maurice Thaler's OX-MAC.INC for ROS 3.2 and my
- ROS33QX2.LBR. This is an attempt to get 3.3 running on the
- Exec but as I have no access to an Exec, these files are
- untested - I hope they are useful.
- Date: 9/9/85
- Author: Mick Gaitor
- Credits: Maurice Thaler
- }
-
- {** Remote channel routines **}
-
- const
-
- { Port locations }
-
- DataPort = $0C; { Data port }
- StatusPort = $0D; { Status port }
- RatePort = $04; { Data rate (bps) port }
-
- { StatusPort commands }
-
- RESSTA = $10; { Reset ext/status }
- RESCHN = $18; { Reset channel }
- RESERR = $30; { Reset error }
- WRREG1 = $00; { Value to write to register 1 }
- WRREG3 = $C1; { 8 bits/char, RX enable }
- WRREG4 = $44; { 16x, 1 stop bit, no parity }
- DTROFF = $68; { DTR off, RTS off }
- DTRON = $EA; { DTR on, 8 bits/char, TX enable, RTS on }
-
- { StatusPort masks }
-
- DAV = $01; { Data available }
- TRDY = $04; { Transmit buffer empty }
- DCD = $08; { Data carrier detect }
- PE = $10; { Parity error }
- OE = $20; { Overrun error }
- FE = $40; { Framing error }
- ERR = $70; { Parity, overrun and framing error }
-
- { Rate setting commands }
-
- BD300 : array[1..2] of byte = ($80,$01); { 300 bps (=384 dec) }
- BD1200 : array[1..2] of byte = ($60,$00); { 1200 bps (= 96 dec) }
- BD2400 : array[1..2] of byte = ($30,$00); { 2400 bps (= 48 dec) }
-
- procedure ch_init;
- { Initialize the remote channel }
- const
- sio_init: array[1..8] of byte =
- (0, RESCHN, 4, WRREG4, 1, WRREG1, 3, WRREG3);
- var
- i: integer;
- begin
- for i := 1 to 8 do
- port[StatusPort] := sio_init[i]
- end;
-
- procedure ch_on;
- { Turn on remote channel (usually by enabling DTR) }
- begin
- port[StatusPort] := 5;
- port[StatusPort] := DTRON
- end;
-
- procedure ch_off;
- { Turn off remote channel (usually by disabling DTR) }
- begin
- port[StatusPort] := 5;
- port[StatusPort] := DTROFF
- end;
-
- function ch_carck: boolean;
- { Check to see if carrier is present }
- begin
- port[StatusPort] := 0;
- port[StatusPort] := RESSTA;
- ch_carck := ((DCD and port[StatusPort]) <> 0)
- end;
-
- function ch_inprdy: boolean;
- { Check for ready to input from port }
- var
- bt: byte;
- begin
- if (DAV and port[StatusPort]) <> 0
- then
- begin
- port[StatusPort] := 1;
- if (ERR and port[StatusPort]) <> 0
- then
- begin
- port[StatusPort] := RESERR;
- bt := port[DataPort]; { "eat" char }
- ch_inprdy := FALSE
- end
- else
- ch_inprdy := TRUE
- end
- else
- ch_inprdy := FALSE
- end;
-
- function ch_inp: byte;
- { Input a byte from port - no wait - assumed ready }
- begin
- ch_inp := port[DataPort]
- end;
-
- procedure ch_out(bt: byte);
- { Output a byte to port - wait until ready }
- begin
- repeat
- until ((TRDY and port[StatusPort]) <> 0);
- port[DataPort] := bt
- end;
-
- procedure ch_set(r: integer);
- { Set the bps rate }
- var
- i : integer;
- RateVal : array[1..2] of byte; { common area for rate vals }
- begin
- rate := r;
- case rate of { move current rate values }
- 300 : move( BD300,RateVal,2); { to common area }
- 1200 : move(BD1200,RateVal,2);
- (* Un-comment this if you can handle 2400 baud --
- 2400 : move(BD2400,RateVal,2);
- *)
- end;
- for i := 1 to 2 do { send rate values }
- port[RatePort] := RateVal[i]
- end;
-
-
- {** System routines **}
- { These were moved below the channel routines for the obvious (I hope)
- reason of needing the channel routines declared before I could do
- the system-init routine. [MAG]
- }
-
- procedure putstat(st: StrStd);
- { Display 'st' on status line }
- const
- status_line = 24; { Line used for system status }
- last_line = 24; { Last line on screen }
- begin
- GotoXY(1,status_line);
- LowVideo;
- writeln(st); { issue <cr> to clear nxt line }
- HighVideo;
- GotoXY(1,last_line)
- end;
-
- procedure init_send(st : StrStd);
- { Send chars to the modem (in a manner per ROS 3.2) to set up defaults }
- var
- byt : byte;
- i : integer;
- begin
- for i := 1 to Length(st) do
- begin
- byt := ord(st[i]);
- ch_out(byt)
- end
- end;
-
- procedure system_init;
- { Initialization to be done once when ROS first starts }
- var
- bt : byte;
- begin
- init_send('AT'+CR); { Get modem's attention }
- delay(2000);
- init_send('AT Z'+CR); { Tell the modem to reset }
- delay(2000);
- init_send('AT V0'+CR); { Use numeric results }
- delay(2000);
- bt := ch_inp; { Catch 'stray' chars }
- bt := ch_inp;
- end;
-
- procedure system_de_init;
- { De-initialization to be done once when ROS terminates }
- begin
- init_send('AT Z'+CR); { Tell the modem to reset }
- putstat('') { Clear status line }
- end;
-