home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBBS / ECO_FOSL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-08-03  |  13.7 KB  |  535 lines

  1. {
  2.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  3.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  4.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  5.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  6.     ▓▓▓▓▓▓▓▓·──                                              ──·▓▓▓▓▓▓▓▓▓▓▓
  7.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  8.     ▓▓▓▓▓▓▓▓   ptd_fosl was conceived and written by            ░░▓▓▓▓▓▓▓▓▓
  9.     ▓▓▓▓▓▓▓▓   floor naaijkens for                              ░░▓▓▓▓▓▓▓▓▓
  10.     ▓▓▓▓▓▓▓▓   persistent thought dynamics, inc.                ░░▓▓▓▓▓▓▓▓▓
  11.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  12.     ▓▓▓▓▓▓▓▓   (c) 1991 by euro-online data communications      ░░▓▓▓▓▓▓▓▓▓
  13.     ▓▓▓▓▓▓▓▓   all rights reserved.                             ░░▓▓▓▓▓▓▓▓▓
  14.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  15.     ▓▓▓▓▓▓▓▓   ptd_fosl wil interface between a fido opus       ░░▓▓▓▓▓▓▓▓▓
  16.     ▓▓▓▓▓▓▓▓   seadog standard interface layer, and tp user.    ░░▓▓▓▓▓▓▓▓▓
  17.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  18.     ▓▓▓▓▓▓▓▓·──                                              ──·░░▓▓▓▓▓▓▓▓▓
  19.     ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
  20.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  21.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  22.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  23.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  24. }
  25. unit eco_fosl;
  26. interface uses dos, crt;
  27. var regs: registers;
  28.  
  29.  
  30.   procedure fos_ansi_       (character : char);
  31.   function  fos_atcmd_      (comport_  : byte;  command_: string): boolean;
  32.   function  fos_avail_      (comport_  : byte): boolean;
  33.   procedure fos_bios_       (character : char);
  34.   function  fos_cd_         (comport_  : byte): boolean;
  35.   function  fos_checkmodem_ (comport_  : byte): boolean;
  36.   procedure fos_clear_regs_;
  37.   procedure fos_close_      (comport_  : byte);
  38.   procedure fos_dtr_        (comport_  : byte;  state: boolean);
  39.   function  fos_empty_      (comport_  : byte): boolean;
  40.   procedure fos_flow_       (comport_  : byte;  state: boolean);
  41.   procedure fos_flush_      (comport_  : byte);
  42.   function  fos_hangup_     (comport_  : byte): boolean;
  43.   function  fos_init_       (comport_  : byte): boolean;
  44.   procedure fos_kill_out_   (comport_  : byte);
  45.   procedure fos_kill_in_    (comport_  : byte);
  46.   function  fos_oktosend_   (comport_  : byte): boolean;
  47.   procedure fos_parms_      (comport_  : byte;  baud: integer; databits: byte;
  48.                                                 parity: char;   stopbit: byte);
  49.   function  fos_present_    (comport_  : byte): boolean;
  50.   procedure fos_reboot_;
  51.   function  fos_receive_    (comport_  : byte): char;
  52.   procedure fos_string_     (comport_  : byte;  outstring: string);
  53.   procedure fos_stringcrlf_ (comport_  : byte;  outstring: string);
  54.   procedure fos_watchdog_   (comport_  : byte;  state: boolean);
  55.   procedure fos_write_      (comport_  : byte;  character: char);
  56.   function  fos_name_(comport: byte) : string;
  57.  
  58.  
  59.  
  60.  
  61.  
  62. implementation
  63.  
  64.  
  65.  
  66.  
  67.  
  68.   procedure fos_clear_regs_;
  69.   begin
  70.     fillchar(regs, sizeof(regs), 0);
  71.   end;
  72.  
  73.  
  74.   function fos_init_(comport_: byte): boolean;
  75.   begin
  76.     fos_clear_regs_;
  77.     with regs do begin
  78.       ah := 4; dx :=(comport_-1); intr($14, regs);
  79.       if ax <> $1954 then begin
  80.         writeln; writeln(' Fossil driver is not loaded.');
  81.         fos_init_ := false;
  82.       end else fos_init_ := true
  83.     end;
  84.   end;
  85.  
  86.  
  87.  
  88.   function fos_present_(comport_: byte): boolean;
  89.   begin
  90.     fos_clear_regs_;
  91.     with regs do begin
  92.       ah := 4; dx := (comport_-1); intr($14, regs);
  93.       fos_present_ := (ax = $1954);
  94.     end;
  95.   end;
  96.  
  97.  
  98.  
  99.  
  100.   procedure fos_close_(comport_: byte);
  101.   begin
  102.     fos_clear_regs_; fos_dtr_(comport_,false);
  103.     with regs do begin
  104.       ah := 5; dx := comport_ - 1; intr($14, regs);
  105.     end;
  106.   end;
  107.  
  108.  
  109.   procedure fos_parms_(
  110.     comport_: byte; baud: integer; databits: byte; parity: char;
  111.     stopbit: byte
  112.   );
  113.   var
  114.     code: integer;
  115.  
  116.   begin
  117.     code := 0; fos_clear_regs_;
  118.     case baud of
  119.       0   : exit;
  120.       100 : code := code + 000 + 00 + 00;
  121.       150 : code := code + 000 + 00 + 32;
  122.       300 : code := code + 000 + 64 + 00;
  123.       600 : code := code + 000 + 64 + 32;
  124.       1200: code := code + 128 + 00 + 00;
  125.       2400: code := code + 128 + 00 + 32;
  126.       4800: code := code + 128 + 64 + 00;
  127.       9600: code := code + 128 + 64 + 32;
  128.       19200: code := code + 000 + 00 + 00;
  129.     end;
  130.   
  131.     case databits of
  132.       5: code := code + 0 + 0;
  133.       6: code := code + 0 + 1;
  134.       7: code := code + 2 + 0;
  135.       8: code := code + 2 + 1;
  136.     end;
  137.   
  138.     case parity of
  139.       'N','n': code := code + 00 + 0;
  140.       'O','o': code := code + 00 + 8;
  141.       'E','e': code := code + 16 + 8;
  142.     end;
  143.   
  144.     case stopbit of
  145.       1: code := code + 0;
  146.       2: code := code + 4;
  147.     end;
  148.   
  149.     with regs do begin
  150.       ah := 0; al := code;
  151.       dx :=(comport_-1);
  152.       intr($14, regs);
  153.     end;
  154.   end;
  155.  
  156.  
  157.   procedure fos_dtr_(comport_: byte; state: boolean);
  158.   begin
  159.     fos_clear_regs_;
  160.     with regs do begin
  161.       ah := 6; dx :=(comport_-1);
  162.       case state of
  163.         true  : al := 1;
  164.         false : al := 0;
  165.       end;
  166.       intr($14, regs);
  167.     end;
  168.   end;
  169.   
  170.  
  171.   function  fos_cd_(comport_: byte) : boolean;
  172.   begin
  173.     fos_clear_regs_;
  174.     with regs do begin
  175.       ah := 3; dx :=(comport_-1);
  176.       intr($14, regs);
  177.       fos_cd_ :=((al and 128) = 128);
  178.     end;
  179.   end;
  180.   
  181.  
  182.   procedure fos_flow_(comport_: byte; state: boolean);
  183.   begin
  184.     fos_clear_regs_;
  185.     with regs do begin
  186.       ah := 15; dx := comport_-1;
  187.       case state of
  188.         true  : al := 255;
  189.         false : al := 0;
  190.       end;
  191.       intr($14, regs);
  192.     end;
  193.   end;
  194.  
  195.  
  196.  
  197.   procedure fos_kill_out_(comport_: byte);
  198.   begin
  199.     fos_clear_regs_;
  200.     with regs do begin
  201.       ah := 9; dx := comport_-1;
  202.       intr($14, regs);
  203.     end;
  204.   end;
  205.  
  206.  
  207.  
  208.   procedure fos_kill_in_(comport_: byte);
  209.   begin
  210.     fos_clear_regs_;
  211.     with regs do begin
  212.       ah := 10; dx := comport_-1;
  213.       intr($14, regs);
  214.     end;
  215.   end;
  216.  
  217.  
  218.  
  219.   procedure fos_flush_(comport_: byte);
  220.   begin
  221.     fos_clear_regs_;
  222.     with regs do begin
  223.       ah := 8; dx := comport_-1;
  224.       intr($14, regs);
  225.     end;
  226.   end;
  227.  
  228.  
  229.  
  230.   function  fos_avail_(comport_: byte): boolean;
  231.   begin
  232.     fos_clear_regs_;
  233.     with regs do begin
  234.       ah := 3; dx := comport_-1;
  235.       intr($14, regs);
  236.       fos_avail_ := ((ah and 1) = 1);
  237.     end;
  238.   end;
  239.  
  240.  
  241.  
  242.   function  fos_oktosend_(comport_: byte) : boolean;
  243.   begin
  244.     fos_clear_regs_;
  245.     with regs do begin
  246.       ah := 3; dx := comport_-1;
  247.       intr($14, regs);
  248.       fos_oktosend_ :=((ah and 32) = 32);
  249.     end;
  250.   end;
  251.  
  252.  
  253.  
  254.  
  255.   function  fos_empty_(comport_: byte) : boolean;
  256.   begin
  257.     fos_clear_regs_;
  258.     with regs do begin
  259.       ah := 3; dx := comport_-1;
  260.       intr($14, regs);
  261.       fos_empty_ :=((ah and 64) = 64);
  262.     end;
  263.   end;
  264.  
  265.  
  266.  
  267.   procedure fos_write_(comport_: byte; character: char);
  268.   begin
  269.     fos_clear_regs_;
  270.     with regs do begin
  271.       ah := 1; dx := comport_-1;
  272.       al := ord(character);
  273.       intr($14, regs);
  274.     end;
  275.   end;
  276.  
  277.  
  278.  
  279.   procedure fos_string_(comport_: byte; outstring: string);
  280.   var pos: byte;
  281.   
  282.   begin
  283.     for pos := 1 to length(outstring) do fos_write_(comport_,outstring[pos]);
  284.     outstring := '';
  285.   end;
  286.   
  287.  
  288.  
  289.   procedure fos_stringcrlf_(comport_: byte; outstring: string);
  290.   var pos: byte;
  291.   begin
  292.     for pos := 1 to length(outstring) do fos_write_(comport_,outstring[pos]);
  293.     fos_write_(comport_,char(13)); fos_write_(comport_,char(10));
  294.     outstring := '';
  295.   end;
  296.  
  297.  
  298.  
  299.   procedure fos_bios_(character: char);
  300.   begin
  301.     fos_clear_regs_;
  302.     with regs do begin
  303.       ah := 21; al := ord(character); intr($14, regs)
  304.     end;
  305.   end;
  306.  
  307.  
  308.  
  309.  
  310.   procedure fos_ansi_(character: char);
  311.   begin
  312.     fos_clear_regs_;
  313.     with regs do begin
  314.       ah := 2; dl := ord(character); intr($21, regs)
  315.     end;
  316.   end;
  317.  
  318.  
  319.   procedure fos_watchdog_(comport_: byte; state: boolean);
  320.   begin
  321.     fos_clear_regs_;
  322.     with regs do begin
  323.       ah := 20; dx := comport_-1;
  324.       case state of
  325.         true  : al := 1;
  326.         false : al := 0;
  327.       end;
  328.       intr($14, regs);
  329.     end;
  330.   end;
  331.  
  332.  
  333.  
  334.   function fos_receive_(comport_: byte) : char;
  335.   begin
  336.     fos_clear_regs_;
  337.     with regs do
  338.     begin
  339.       ah := 2; dx := comport_-1;
  340.       intr($14, regs);
  341.       fos_receive_ := chr(al);
  342.     end;
  343.   end;
  344.  
  345.  
  346.   function fos_hangup_(comport_: byte) : boolean;
  347.   var
  348.     tcount : integer;
  349.   
  350.   begin
  351.     fos_dtr_(comport_,false); delay(600); fos_dtr_(comport_,true);
  352.     if fos_cd_(comport_)=true then begin
  353.       tcount := 1;
  354.       repeat
  355.         fos_string_(comport_,'+++'); delay(3000);
  356.         fos_stringcrlf_(comport_,'ATH0'); delay(3000);
  357.         if fos_cd_(comport_)=false then tcount := 3;
  358.         inc(tcount);
  359.       until tcount=4;
  360.     end;
  361.     if fos_cd_(comport_)=true then fos_hangup_ := false else fos_hangup_ := true;
  362.   end;
  363.  
  364.  
  365.  
  366.   procedure fos_reboot_;
  367.   begin
  368.     fos_clear_regs_;
  369.     with regs do begin
  370.       ah := 23; al := 1;
  371.       intr($14, regs);
  372.     end;
  373.   end;
  374.  
  375.  
  376.  
  377.  
  378.   function fos_checkmodem_(comport_: byte) : boolean;
  379.   var
  380.     ch     :   char;
  381.     result :   string[10];
  382.     i,z    :   integer;
  383.   
  384.   begin
  385.     fos_checkmodem_ := false;
  386.     result := '';
  387.     for z := 1 to 3 do begin
  388.       delay(500); fos_write_(comport_,char(13));
  389.       delay(1000); fos_stringcrlf_(comport_,'AT'); delay(1000);
  390.       repeat
  391.         if fos_avail_(comport_) then begin
  392.           ch := fos_receive_(comport_); result := result+ch;
  393.         end;
  394.       until fos_avail_(1)=false;
  395.       for i := 1 to length(result) do begin
  396.         if copy(result,i,2)='OK' then begin
  397.           fos_checkmodem_ := true; exit;
  398.         end;
  399.       end;
  400.     end;
  401.   end;
  402.  
  403.  
  404.  
  405.   function fos_atcmd_(comport_: byte; command_: string) : boolean;
  406.   var
  407.     ch     :   char;
  408.     result :   string;
  409.     i,z    :   integer;
  410.   
  411.   begin
  412.     fos_atcmd_ := false; result := '';
  413.     for z := 1 to 3 do begin
  414.       delay(500); fos_write_(comport_,char(13));
  415.       delay(1000); fos_stringcrlf_(comport_, command_); delay(1000);
  416.       repeat
  417.         if fos_avail_(comport_) then begin
  418.           ch := fos_receive_(comport_); result := result + ch;
  419.         end;
  420.       until not fos_avail_(comport_);
  421.       for i := 1 to length(result)-1 do begin
  422.         if copy(result,i,2) = 'OK' then begin
  423.           fos_atcmd_ := true; exit;
  424.         end;
  425.       end;
  426.     end;
  427.   end;
  428.  
  429.  
  430.  
  431.  
  432.   function fos_name_(comport: byte) : string;
  433.   { returns ascii description of fossil driver in use. }
  434.   { returns empty string if no fossil was detected.    }
  435.   type
  436.     ary128 = array[1..128] of char;
  437.     aryptr = ^ary128;
  438.     fossil_info_record_type = record
  439.       size      : word;    { size of the structure in bytes      }
  440.       majver    : byte;    { major fossil driver spec            }
  441.       minver    : byte;    { minor fossil driver spec            }
  442.       ident     : aryptr;  { far pointer to ascii id string      }
  443.       inbuffer  : word;    { size of the input buffer in bytes   }
  444.       infree    : word;    { number of bytes left in buffer      }
  445.       outbuffer : word;    { size of the output buffer in bytes  }
  446.       outfree   : word;    { number of bytes left in the buffer  }
  447.       width     : byte;    { width of screen on this adapter     }
  448.       height    : byte;    { height of screen on this adapter    }
  449.       baud      : byte     { actual baud rate, computer to modem }
  450.     end;
  451.  
  452.   var
  453.     r : registers;
  454.     i, j : byte;
  455.     f    : fossil_info_record_type;
  456.     temp : string;
  457.  
  458.   begin
  459.     j := pred(comport);
  460.     repeat
  461.       fillchar(f, sizeof(f), #0); fillchar(r, sizeof(r), #0);
  462.       temp := ''; r.ah := $1b; r.cx :=  19; { size of fossil_info_record_type }
  463.       r.dx := j; { com port } r.es := seg(f); r.di := ofs(f); intr($14,r);
  464.       if r.ax = 19 then begin { looks as if fossil was detected? }
  465.         i := 1;
  466.         repeat
  467.           if f.ident^[i] <> #0 then temp := temp + f.ident^[i]; inc(i)
  468.         until (f.ident^[i] = #0) or (i = 128)
  469.       end else inc(j)
  470.     until (temp <> '') or (j > 4); { only check com1-com4 }
  471.     fos_name_ := temp
  472.   end; { fossil_name }
  473.   
  474.  
  475.  
  476. end.
  477.  
  478.  
  479.  
  480. (*
  481.  
  482.   procedure initport(baud : integer; parity : char; charlength,stopbits: byte);
  483.   begin
  484.     temp := '';
  485.     case baud of
  486.       19200 : temp := '000';
  487.        9600 : temp := '111';
  488.        4800 : temp := '110';
  489.        2400 : temp := '101';
  490.        1200 : temp := '100';
  491.         300 : temp := '010';
  492.     end;
  493.     case upcase(parity) of
  494.       'N' : temp := temp + '00';
  495.       'E' : temp := temp + '11';
  496.       'O' : temp := temp + '01';
  497.     end;
  498.     if stopbits = 1 then temp := temp + '0' else temp := temp + '1';
  499.     case charlength of
  500.       8 : temp := temp + '11';
  501.     end;
  502.     r.ah := $00; r.al := bin2dec(temp); r.dx := pred(comport); intr($14,r);
  503.   end;
  504.  
  505.  
  506.  
  507.   procedure raisedtr;
  508.   begin
  509.     r.ah := $06; r.al := $01; r.dx := pred(comport); intr($14,r);
  510.   end;
  511.  
  512.  
  513.  
  514.   procedure lowerdtr;
  515.   begin
  516.     r.ah := $06; r.al := $00; r.dx := pred(comport); intr($14,r);
  517.   end;
  518.  
  519.  
  520.  
  521.   procedure purge_input;
  522.   begin
  523.     r.ah := $0a; r.dx := pred(comport); intr($14,r);
  524.   end;
  525.  
  526.  
  527.  
  528.   function charinbuffer : boolean;
  529.   begin
  530.     r.ah := $0c; r.dx := pred(comport); intr($14,r);
  531.     if r.ax = $ffff then charinbuffer := false else charinbuffer := true;
  532.   end;
  533.  
  534. *)
  535.