Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-02

[Fwd: Ports under Linux]

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis R. Hilario
Uses linux, ports;
// Program based on:
http://www.linuxdoc.org/HOWTO/mini/IO-Port-Programming-9.html
Const
 BASEPORT = $0378;  // Normally it is LPT1
begin
 // Get access to the ports: $0378..$037A
 if not (ioperm(BASEPORT, 3, 1)) then Halt(1);
 // Set the data signals (D0-7) of the port to all low (0)
 Port[$378] := 0;
 // Read the port of data. It must read the previous value, in this case
a zero.
 Writeln(Port[$378]);
 // We don't need the ports anymore.
 if not (ioperm(BASEPORT, 3, 0)) then Halt(1);
// Important note:
// Bit 5 of the control port ($37A) selects the direction (In or Out) of
the port of data.
end.

"Under LINUX, your program must be run as root, or the IOPerm call..." In the documentation it must go "and" instead of "or".

|-----------------------------| | Luis R. Hilario | | http://www.luisdigital.2y.net | |-----------------------------|

Reply by email