Solved

Parallel port

Posted on 1998-05-26
2
419 Views
Last Modified: 2010-04-06
How do I read the parallel port
0
Comment
Question by:JustinCase
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 20 total points
ID: 1347988
This is something I have seen on one of the sites:

4. Reading a byte from the parallel port
Q:
I needed to read a byte from the parallel port (0x379).  I did it using inline
assemble language.  I noticed their is no way of doing it using the Windows API.
I have a sensor attached to this port.  It works fine but, is it safe to address
hardware directly in windows.  Windows is intercepting the call anyway (I
think).

Var
    BytesRead : BYTE;
begin
              asm                { Read port (LPT1) via Inline asm  }
                MOV dx,$379;
                IN  al,dx;
                MOV BytesRead,al;
              end;
BytesRead:=(BytesRead OR $07);   { OR and then XOR the data }
BytesRead:=(BytesRead XOR $80);  { to mask the unused bits  }

A:
It's no problem, use the Turbo Pascal command ...

 value:=port[$379]; { read from port }

and

 port[$379]:=value; { write to port }

The port command doesn't seem to be documented in online help, but it
certainly works!

[Andy Clark, andyc@rmpd-ngh.demon.co.uk]

See also:
http://www.chami.com/tips/delphi/111796D.html
0
 

Author Comment

by:JustinCase
ID: 1347989
Perfect.

 Thanks !
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question