Solved

LPT Port ?

Posted on 2002-07-08
7
535 Views
Last Modified: 2010-04-04
Hi.

I need to read bits from my printer port.
I use DLPORTIO.dll to write the bits.

Now i need to read the bits that are active.

Eg if i write: 1001110

Then i want to be able to close my prog, and read the current status of the port, and actually get back the: 1001110

If u use the read button in the demo, it gets back the value in hex, and i need to get it back the other way.

Can anyone help?

Thanks
0
Comment
Question by:Dennis9
7 Comments
 
LVL 5

Expert Comment

by:alanwhincup
ID: 7138234
If you can get the value back in hex then you can convert the hex value back to its binary form with a function like below:

function HexToBin(Hex : string) : string;
const
  BCD : array [0..15] of string = ('0000', '0001', '0010', '0011', '0100',
    '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101',
    '1110', '1111');
var
  I : integer;
begin
  for I := Length(Hex) downto 1 do
    Result := BCD[StrToInt('$' + Hex[I])] + Result;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(HexToBin('4E'));
end;

Cheers,

Alan
0
 
LVL 1

Author Comment

by:Dennis9
ID: 7139052
its 8 bit result i want eg: 10101101
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 7139232
I've downloaded and had a quick look at the DLPORTIO.dll and assume you are using the following function to interface between your prog and the driver to read an 8 bit result (or a byte):

function DlPortReadPortUchar(Port : LongInt) : Byte; stdcall;

As this returns a byte then you can convert straight from a byte to its binary form with the function IntToBin() which is implemented in the IdGlobal unit.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
Dennis9 earned 0 total points
ID: 7164478
I found another way around, i thought i could write bits, but i need to write hex decimals now its all working

Thanks anyways
0
 

Expert Comment

by:CleanupPing
ID: 9343093
Dennis9:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9460301
Dennis9,
No comment has been added lately (18 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Accept alanwhincup's answer http:#7139232 and Refund

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 212
Intraweb download file link ? 1 167
Dev express lookupcombo 3 44
DBCtrlGrid, Delphi, Scroll 8 56
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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