[fpc-pascal] Parallel Port Access with Free Pascal - windows

James Richters james at productionautomation.net
Sat Jul 23 12:53:23 CEST 2016


Thank you for getting me on the right track with this Marc,  I have it
working now!
Here is a link I found that explains it: 
http://www.freepascal.org/docs-html/ref/refsu72.html

I would have never thought of that!  

I posted the fixed program on github here if anyone is interested:
https://github.com/Zaaphod/FPC-Parallel-Port

I tested it the Inp32 and Out32 functions and they are now working!  
Thank you everyone very much for the help with this!

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Marc Santhoff
Sent: Saturday, July 23, 2016 1:09 AM
To: fpc-pascal at lists.freepascal.org
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

On Sa, 2016-07-23 at 05:55 +0200, Marc Santhoff wrote:
> On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote:
> > I'm trying to avoid custom hardware if possible.  I have always used
> > parallel ports and never had a problem with them until now.   I like the
> > idea of a parallel port because they are still built onto motherboards,
and
> > there are also a TON of USB to parallel port adapters out there.   I'm
> > trying to keep this simple.
> > 
> > I put a repository of my test program here:
> > https://github.com/Zaaphod/FPC-Parallel-Port.  Perhaps someone can see
what
> > I'm doing wrong.    I'm reading 255s no matter what I do.    I included
my
> > old turbo pascal test program.  I would normally specify the port in 
> > hex with a $ like this $378.  I could write to the port then read 
> > back what I just wrote.. which is what I am trying to do now.. I 
> > don't have anything hooked up to the port yet, I should be able to write
to it and read it back.
> > 
> > I seem to be accessing the DLL correctly, because I tried it on a 
> > windows 7 computer and  IsInpOutDriverOpen was false, because I 
> > forgot to install the driver, once I installed the driver 
> > IsInpOutDriverOpen is now true, so that tells me I'm accessing the DLL
and the DLL is confirming the driver is open.
> 
> >From what I know, although it may be a bit outdated, on windows 
> >external
> functions have to be declared 'cdecl'. Which isn't so in the library 
> port to pascal.
> 
> One example:
> 
>   implementation
>   Function IsInpOutDriverOpen; external 'inpout32.DLL';
> 
> would then be:
> 
>   implementation
>   Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL';

No, sorry. It has to be the other way round:

  Function IsInpOutDriverOpen; {$ifndef Win32}cdecl{$else}stdcall{$endif};
external 'inpout32.DLL';

I didn't recognize that it is  $ifndef, not $ifdef.

Marc


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list