Solved

Parallel port

Posted on 1998-05-26
2
423 Views
Last Modified: 2010-04-06
How do I read the parallel port
0
Comment
Question by:JustinCase
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…

733 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