Board index » delphi » Direct parallel port access in Delphi

Direct parallel port access in Delphi

Hi,

I'm writing a program that needs to access the parallel port's datalines. It
needs to reads the databits and set them, so they remain at the same
position even after the program stopped. It's for use with a parallel port
relay.

Does anyone know how I can direct access the port ??

Thanks in advance,
Kim

 

Re:Direct parallel port access in Delphi


Quote
UNiDoG wrote:
> Hi,

> I'm writing a program that needs to access the parallel port's datalines. It
> needs to reads the databits and set them, so they remain at the same
> position even after the program stopped. It's for use with a parallel port
> relay.

> Does anyone know how I can direct access the port ??

> Thanks in advance,
> Kim

Delphi 3 doesn't offer any port handlers that I could find.  My solution is to
use an ASM block to write and read straight from
the io port.

procedure WriteByte(myb : byte);
begin
  asm
   mov al, myb                    {byte to write}
   mov dx, $378                 {address to write to, lpt1 here}
   out dx, al
 end;
end;

swap out 'out dx, al' with 'in dx,al' and remove the 'mov al,myb' to read the
port.
remember that the port reads back the line levels or'd with the last writen
value to the port.  You might want to write a $00
to $378 then read it to get the true values.

Also, this only works in '95 ('98?), not NT.  NT will hurl protection errors at
you when it runs.

Good luck
Thomas Kreider
tkrei...@uswest.net

Re:Direct parallel port access in Delphi


Check out the Delphi Super Page Site http://sunsite.icm.edu.pl/delphi/ there
is a lot of FREE and SHAREWARE components.
There is one called ASYNC32.ZIP

Quote
UNiDoG <unidog--no-spa...@bigfoot.com> wrote in message

news:7hk8f6$o4j$1@inf6serv.rug.ac.be...
Quote
> Hi,

> I'm writing a program that needs to access the parallel port's datalines.
It
> needs to reads the databits and set them, so they remain at the same
> position even after the program stopped. It's for use with a parallel port
> relay.

> Does anyone know how I can direct access the port ??

> Thanks in advance,
> Kim

Re:Direct parallel port access in Delphi


I did it the asm-way for now... and it worked :)
But since it only works in Windows 95 and 98 (!) ... i'll sure have to check
those components

Quote
Neil Odegard <node...@compusmart.ab.ca> wrote in message

news:926836491.782.59@news.remarQ.com...
Quote
> Check out the Delphi Super Page Site http://sunsite.icm.edu.pl/delphi/
there
> is a lot of FREE and SHAREWARE components.
> There is one called ASYNC32.ZIP

> UNiDoG <unidog--no-spa...@bigfoot.com> wrote in message
> news:7hk8f6$o4j$1@inf6serv.rug.ac.be...
> > Hi,
> > I'm writing a program that needs to access the parallel port's
datalines.
> > It needs to reads the databits and set them, so they remain at the same
> > position even after the program stopped. It's for use with a parallel
port
> > relay.
> > Does anyone know how I can direct access the port ??
> > Thanks in advance,
> > Kim

Re:Direct parallel port access in Delphi


There's a very good one called TVichW32 at
http://www.entechtaiwan.com/tools.htm. It does direct access, but has some other
useful features such as a property allowing you to read or set individual pins
(faster than masking out the relevant port register) and also Interrupts -
parallel port and all other IRQs from 1-15 are supported.

I think it's about $99.

Andrew

Quote
Neil Odegard wrote:
> Check out the Delphi Super Page Site http://sunsite.icm.edu.pl/delphi/ there
> is a lot of FREE and SHAREWARE components.
> There is one called ASYNC32.ZIP

> UNiDoG <unidog--no-spa...@bigfoot.com> wrote in message
> news:7hk8f6$o4j$1@inf6serv.rug.ac.be...
> > Hi,

> > I'm writing a program that needs to access the parallel port's datalines.
> It
> > needs to reads the databits and set them, so they remain at the same
> > position even after the program stopped. It's for use with a parallel port
> > relay.

> > Does anyone know how I can direct access the port ??

> > Thanks in advance,
> > Kim

Re:Direct parallel port access in Delphi


ime...@mtu-net.ru

Re:Direct parallel port access in Delphi


ime...@mtu-net.ru

Other Threads