home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol072 / acoustic.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  5.3 KB  |  222 lines

  1. { Donated Warren Smith, Feb 1982 }
  2.  
  3. Module Acoustic_Coupler;
  4.  
  5. { Port assignments for serial port of acoustic coupler }
  6. Const
  7.     Status_Reg_Modem= $03;
  8.     Modem_Rcv_Reg    = $02;
  9.     Modem_Xmit_Reg    = $02;
  10.  
  11.  
  12. Procedure Init_Modem;
  13.  
  14.   Const    Char_Length     = 3;    { 8 data bits    }
  15.     Stop_bits    = 0;    { 1 stop bits    }
  16.     Parity_Inhibit    = 1;    { no parity    }
  17.     Parity_Type    = 1;    { even parity    }
  18.     Baud        = 300;    { 300 baud    }
  19.  
  20.   Var
  21.     Out_Byte : byte;
  22.  
  23.   begin { Init_Modem }
  24.     { This routine is intended for use as an initializing routine    }
  25.     { if your serial port needs it.  You should set up your port    }
  26.     { to match the comments above. }
  27.   end;  { Init_Modem }
  28.  
  29. Procedure Set_Modem (Modebyte : byte);
  30.  
  31.   begin { Set_Modem }
  32.     { This routine lets you change the various modes of the modem,    }
  33.     { most acoustic couplers can't do anything. }
  34.   end;  { Set_Modem }
  35.  
  36. Procedure Go_Onhook (Var Modem_Mode : byte);
  37.  
  38.   begin { Go_Onhook }
  39.   Clrbit (Modem_Mode, 7);
  40.   Set_Modem (Modem_Mode)
  41.   end;  { Go_Onhook }
  42.  
  43. Procedure Go_Offhook (Var Modem_Mode : byte);
  44.  
  45.   begin { Go_Offhook }
  46.   SetBit (Modem_Mode, 7);
  47.   Set_Modem (Modem_Mode)
  48.   end;  { Go_Offhook }
  49.  
  50. Procedure Set_Ans_Mode (Var Modem_Mode : byte);
  51.  
  52.   begin { Set_Ans_Mode }
  53.   Clrbit (Modem_Mode, 2);
  54.   Set_Modem (Modem_Mode)
  55.   end;  { Set_Modem_Mode }
  56.  
  57. Procedure Set_Org_Mode (Var Modem_Mode : byte);
  58.  
  59.   begin { Set_Org_Mode }
  60.   Setbit (Modem_Mode, 2);
  61.   Set_Modem (Modem_Mode)
  62.   end;  { Set_Org_Mode }
  63.  
  64. Procedure Set_110bps (Var Modem_Mode : byte);
  65.  
  66.   begin { Set_110bps }
  67.   Clrbit (Modem_Mode, 0);
  68.   Set_Modem (Modem_Mode)
  69.   end;  { Set_110bps }
  70.  
  71. Procedure Set_300bps (Var Modem_Mode : byte);
  72.  
  73.   begin { Set_300bps }
  74.   Setbit (Modem_Mode, 0);
  75.   Set_Modem (Modem_Mode)
  76.   end;  { Set_300bps }
  77.  
  78. Procedure Enable_Xmit (Var Modem_Mode : byte);
  79.  
  80.   begin { Enable_Xmit }
  81.   Setbit (Modem_Mode, 1);
  82.   Set_Modem (Modem_mode)
  83.   end;  { Enable_Xmit }
  84.  
  85. Procedure Disable_Xmit (Var Modem_Mode : byte);
  86.  
  87.   begin { Disable_Xmit }
  88.   Clrbit (Modem_Mode, 1);
  89.   Set_Modem (Modem_Mode)
  90.   end;  { Disable_Xmit }
  91.  
  92. Function Carrier_Present : boolean;
  93.  
  94.   begin { Carrier_Present }
  95.     { If you have your serial port wired up to recieve a carrier    }
  96.     { detect signal then you should test for that bit, otherwise    }
  97.     { just return TRUE. }
  98.   Carrier_Present := TRUE
  99. {  Carrier_Present := Tstbit (Inp[Status_Reg_Modem], 6)    }
  100.   end;  { Carrier_Present }
  101.  
  102. Function Ringing : boolean;
  103.  
  104.   begin { Ringing }
  105.     { Most ports can't detect ringing so just return FALSE.        }
  106.   Ringing := FALSE
  107. {  Ringing := not Tstbit (Inp[Status_Reg_Modem]), 7) }
  108.   end;  { Ringing }
  109.  
  110. Function Modem_Char_Rdy : boolean;
  111.  
  112.   Var
  113.     Status    : byte;
  114.  
  115.   begin { Modem_Char_Rdy }
  116.     { Returns TRUE if data is available in the input port        }
  117.     { (does NOT read the data) }
  118.   PortIn (Status_Reg_Modem, Status);
  119.   Modem_Char_Rdy := Tstbit (Status, 1)
  120.   end;  { Modem_Char_Rdy }
  121.  
  122. Function Modem_In : char;
  123.  
  124.   Var
  125.     In_Char    : byte;
  126.  
  127.   begin { Modem_In }
  128.     { Reads the data port of the acoustic coupler.  May have to    }
  129.     { mask off bit 7 of the data if the sender is not treating it    }
  130.     { as part of the data byte sent. }
  131.   PortIn (Modem_Rcv_Reg, In_Char);
  132.   Modem_In := chr(In_Char & $7F)
  133.   end;  { Modem_In }
  134.  
  135. Function Modem_Out (OutChar : char) : boolean;
  136.  
  137.   Function Modem_Busy : boolean;
  138.  
  139.     Var
  140.     Status    : byte;
  141.  
  142.     begin { Modem_Busy }
  143.     { Returns TRUE if the transmit buffer empty bit of status port    }
  144.     { indicates that the UART is still transmitting.        }
  145.     PortIn (Status_Reg_Modem, Status);
  146.     Modem_Busy := not Tstbit (Status, 0)
  147.     end;  { Modem_Busy }
  148.  
  149.   begin { Modem_Out }
  150.   While Modem_Busy do;
  151.   If Carrier_Present then
  152.     begin
  153.     PortOut (Modem_Xmit_Reg, ord(OutChar));
  154.     Modem_Out := TRUE
  155.     end
  156.   else
  157.     Modem_Out := FALSE
  158.   end;  { Modem_Out }
  159.  
  160. Procedure Delay;    { delay's for 10 millisecond }
  161.  
  162.   Const
  163.     Count = 477;
  164.   Var
  165.     I : integer;
  166.  
  167.   begin { Delay }
  168.     { Very machine dependent.  I am using a 5 MHz 8085, running    }
  169.     { Pascal MT+ 5.5 if that helps. }
  170.   For I := 1 to Count do
  171.   end;  { Delay }
  172.  
  173. Procedure Dial_a_Number (Var Modem_Mode : byte; Number : string);
  174.  
  175.   Var
  176.     I, J,  Pulse_Count : integer;
  177.  
  178.   Procedure Pulse_Line;
  179.  
  180.     Var
  181.     I : integer;
  182.     begin { Pulse_Line }
  183.     Go_Onhook (Modem_Mode);
  184.     For I := 1 to 5 do
  185.       Delay;            { leave on for 50 ms }
  186.     Go_Offhook (Modem_Mode);
  187.     For I := 1 to 5 do
  188.       Delay            { leave off for 50 ms }
  189.     end;  { Pulse_Line }
  190.  
  191.   begin { Dial_a_Number }
  192.     { Included as an example of how to do it.    }
  193.   Go_Offhook (Modem_Mode);
  194.   For I := 1 to 100 do
  195.     Delay;
  196.   For I := 1 to Length(Number) do
  197.     If (Number[I] < '0') OR (Number[I] > '9') then
  198.       begin
  199.       Write (Number[I]);
  200.       For J := 1 to 300 do    { wait 3 seconds for non_digit }
  201.     Delay
  202.       end
  203.     else
  204.       begin
  205.       Pulse_Count := ord(Number[I]) - $30;
  206.       If Pulse_Count = 0 then
  207.     Pulse_Count := 10;
  208.       Write (Number[I]);
  209.       For J := 1 to Pulse_Count do
  210.     Pulse_Line;
  211.       For J := 1 to 60 do
  212.     Delay            { 600 ms delay between digits }
  213.       end;
  214.   Writeln;
  215.   Writeln('All right dummy, now that you''ve watched me, let''s see if');
  216.   Writeln('you know how to dial a phone.  Make the connection, and hit');
  217.   Writeln('RETURN when you get a carrier.')
  218.   end;  { Dial_a_Number }
  219.  
  220.  
  221. Modend.
  222.