Program demonštruje možnosť kominukácie pomocou parallelného portu

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: System

Program: Parallel_port.pas
File exe: Parallel_port.exe

Program demonštruje možnosť kominukácie pomocou parallelného portu.
{ PARALLEL_PORT.PAS                                                 }
{ Example for communication via parallel port.                      }
{                                                                   }
{ Datum:09.07.2013                             http://www.trsek.com }
 
program parallel_port;
uses crt;
 
{ parallel port LPT1 localize at $379 }
{ at this send byte } 
procedure send(b:byte);
var pom:byte;
begin
  pom:=15 and b;
  port[$379]:=pom;
  pom:=240 and b;
  port[$379]:=pom;
end;
 
{ receive byte from parallel port LPT1 localize at $379 } 
function receive:byte;
var pom,b:byte;
begin
  pom:=port[$379];
  b:=(120 and pom) shr 3;
  pom:=port[$379];
  b:=b or((120 and pom) shl 1);
  receive:=b;
end;
 
{ main program }
begin
  writeln('Program send byte 0xFF on parallel port.');
  send($FF);
 
  writeln('Program receive from parallel port ', receive);
  readln;
end.