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

  1. {
  2.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  3.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  4.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  5.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  6.     ▓▓▓▓▓▓▓▓·──                                              ──·▓▓▓▓▓▓▓▓▓▓▓
  7.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  8.     ▓▓▓▓▓▓▓▓   Unit was conceived, designed and written         ░░▓▓▓▓▓▓▓▓▓
  9.     ▓▓▓▓▓▓▓▓   by Floor A.C. Naaijkens for                      ░░▓▓▓▓▓▓▓▓▓
  10.     ▓▓▓▓▓▓▓▓   UltiHouse Software / The ECO Group.              ░░▓▓▓▓▓▓▓▓▓
  11.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  12.     ▓▓▓▓▓▓▓▓   (C) MCMXCII by EUROCON PANATIONAL CORPORATION.   ░░▓▓▓▓▓▓▓▓▓
  13.     ▓▓▓▓▓▓▓▓   All Rights Reserved for The ECO Group.           ░░▓▓▓▓▓▓▓▓▓
  14.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  15.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  16.     ▓▓▓▓▓▓▓▓·──                                              ──·░░▓▓▓▓▓▓▓▓▓
  17.     ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
  18.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  19.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  20.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  21. }
  22.  
  23. {$R-,S-}
  24. {
  25.      byte: 7   6   5    4    3       2      1    0
  26.            ─────────    ──────    ───────   ──────
  27.            baud rate    parity    stopbit   length
  28.  
  29.  
  30.            tabel  i:                │       tabel  ii:
  31.    baud rate:   bit: 7  6  5        │  parity:   bit   4   3
  32.    ─────────────────────────────────┼─────────────────────────────
  33.                                     │
  34.          110         0  0  0        │    none          0   0
  35.          150         0  0  1        │
  36.          300         0  1  0        │     odd          0   1
  37.          600         0  1  1        │
  38.         1200         1  0  0        │    even          1   1
  39.         2400         1  0  1        │
  40.         4800         1  1  0        │
  41.         9600         1  1  1        │
  42.  
  43.  
  44.            tabel  iii:              │       tabel  iv:
  45.    stop bits:      bit: 2           │  length:   bit:  1   0
  46.    ─────────────────────────────────┼─────────────────────────────
  47.                                     │
  48.        1  bit           0           │  7 bits          1   0
  49.                                     │
  50.        2 bits           1           │  8 bits          1   1
  51.  
  52.    convert this binary code into a hexadecimal code and use it as in the
  53.    following example:
  54.  
  55.  
  56. uses
  57.   eco_232
  58.  
  59.   ;
  60.  
  61.  
  62. var
  63.   com1: text;
  64.  
  65.  
  66. begin
  67.    assignaux(com1,0,$83);  /this ($83) means com1, 1200 baud, no parity\
  68.    rewrite(com1);          /1 stop bit and 8 data bits                 \
  69.    writeln(com1,'devicedriver by persistent thought dynamics!')
  70.    close(com1);
  71. end.
  72. }
  73.  
  74.  
  75.  
  76. unit eco_232;
  77.  
  78. interface
  79. uses
  80.   dos
  81.  
  82.   ;
  83.  
  84.  
  85.   procedure assignaux(var f: text; port,params: word);
  86.  
  87.  
  88.  
  89. implementation
  90.  
  91.  
  92. type
  93.   auxrec = record
  94.     port,params: word;
  95.     unused: array[1..12] of byte;
  96.   end;
  97.  
  98.  
  99.   procedure auxinit(port,param: word);
  100.   inline(
  101.     $58/         {pop ax    ;pop parameters          }
  102.     $5a/         {pop dx    ;pop port number         }
  103.     $b4/$00/     {mov ah,0  ;code for initialise     }
  104.     $cd/$14      {int 14h   ;call bios               }
  105.   );
  106.  
  107.  
  108.  
  109.   function auxinchar(port: word): char;
  110.   inline(
  111.     $5a/         {pop dx    ;pop port number         }
  112.     $b4/$02/     {mov ah,2  ;code for input          }
  113.     $cd/$14      {int 14h   ;call bios               }
  114.   );
  115.  
  116.  
  117.  
  118.   procedure auxoutchar(port:word; ch: char);
  119.   inline(
  120.     $58/         {pop ax    ;pop character           }
  121.     $5a/         {pop dx    ;pop port number         }
  122.     $b4/$01/     {mov ah,1  ;code for output         }
  123.     $cd/$14      {int 14h   ;call bios               }
  124.   );
  125.  
  126.  
  127.   function auxinready(port: word): boolean;
  128.   inline(
  129.     $5a/         {pop dx    ;pop port number         }
  130.     $b4/$03/     {mov ah,3  ;code for status         }
  131.     $cd/$14/     {int 14h   ;call bios               }
  132.     $88/$e0/     {mov al,ah ;get line status in ah   }
  133.     $24/$01      {and al,1  ;isolate data ready bit  }
  134.   );
  135.  
  136.  
  137.  
  138. {$F+}
  139.   function auxinput(var f: textrec): integer;
  140.   var p: integer;
  141.   begin
  142.     with f,auxrec(userdata) do begin
  143.       p := 0;
  144.       while auxinready(port) and (p<bufsize) do begin
  145.         bufptr^[p] := auxinchar(port); inc(p)
  146.       end;
  147.       bufpos := 0; bufend := p
  148.     end;
  149.     auxinput := 0
  150.   end;
  151.  
  152.  
  153.  
  154.  
  155.   function auxoutput(var f: textrec): integer;
  156.   var p: integer;
  157.   begin
  158.     with f,auxrec(userdata) do begin
  159.       p := 0;
  160.       while p<bufpos do begin
  161.         auxoutchar(port,bufptr^[p]);
  162.         inc(p)
  163.       end;
  164.       bufpos := 0
  165.     end;
  166.     auxoutput := 0
  167.   end;
  168.  
  169.  
  170.  
  171.   function auxignore(var f: textrec): integer;
  172.   begin
  173.     auxignore := 0
  174.   end;
  175.  
  176.  
  177.   function auxopen(var f: textrec): integer;
  178.   begin
  179.     with f,auxrec(userdata) do begin
  180.       auxinit(port,params);
  181.       if mode = fminput then begin
  182.         inoutfunc := @auxinput; flushfunc := @auxignore
  183.       end else begin
  184.         mode := fmoutput; inoutfunc := @auxoutput;
  185.         flushfunc := @auxoutput
  186.       end;
  187.       closefunc := @auxignore
  188.     end;
  189.     auxopen := 0;
  190.   end;
  191. {$F-}
  192.  
  193.  
  194.  
  195.  
  196.   procedure assignaux;
  197.   begin
  198.     with textrec(f) do begin
  199.       handle    := $ffff;
  200.       mode      := fmclosed;
  201.       bufsize   := sizeof(buffer);
  202.       bufptr    := @buffer;
  203.       openfunc  := @auxopen;
  204.       auxrec(userdata).port := port;
  205.       auxrec(userdata).params := params;
  206.       name[0]   := #0
  207.     end;
  208.   end;
  209.  
  210.  
  211.  
  212. end. { unit }
  213.