Parallel Port Access with Free Pascal - windows

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Parallel Port Access with Free Pascal - windows

Zaaphod
I am trying to get access to the parallel port with Free Pascal.  

I'm trying to use this version of inpout32 (x64) http://www.highrez.co.uk/downloads/inpout32/ 

Here's my program:
http://pastebin.com/facf6EFc

Here's my Unit:
http://pastebin.com/XR0aYUPR

When I try to run it, I get a windows message The application was unable to start correctly (0xc000007b). click ok to close the application.

then  I get Exitcode 123 in the Free Pascal IDE.  123 is decimal of 7b.

Does anyone know how to get this to work?   reading and writing the parallel port used to be so easy, now it's extremely confusing, thanks windows!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Marc Santhoff-2
On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote:

> I am trying to get access to the parallel port with Free Pascal.  
>
> I'm trying to use this version of inpout32 (x64)
> http://www.highrez.co.uk/downloads/inpout32/ 
>
> Here's my program:
> http://pastebin.com/facf6EFc
>
> Here's my Unit:
> http://pastebin.com/XR0aYUPR
>
> When I try to run it, I get a windows message The application was unable to
> start correctly (0xc000007b). click ok to close the application.

You could search Microsofts web site to decode this error.

> then  I get Exitcode 123 in the Free Pascal IDE.  123 is decimal of 7b.
>
> Does anyone know how to get this to work?   reading and writing the parallel
> port used to be so easy, now it's extremely confusing, thanks windows!

Didn't test, but as a remark: parallel port is dead and it has been a
constant source of problems. First the access rights problems you know
of. Second it has no fixed timing, so you're in trouble when e.g.
flashing a microcontroller works on one machine and refuses to on
another one. Third it is not electrically protected, if you fry it, the
mainboard is dead by chance or you have to insert an extension board -
which is hard to find nowadays, too.

Depending on your needs I'd suggest using a USB-to-serial-Adapter or
similar. They are cheap and well supported (e.g. using CP2102). As an
alternative FTDI has some nice USB-to-anything (including parallel)
chips and they sell modules with mil spacing pins for easy
breadboarding.

HTH somehow,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Paul Breneman
On 07/20/2016 10:29 PM, Marc Santhoff wrote:
...
> Depending on your needs I'd suggest using a USB-to-serial-Adapter or
> similar. They are cheap and well supported (e.g. using CP2102). As an
> alternative FTDI has some nice USB-to-anything (including parallel)
> chips and they sell modules with mil spacing pins for easy
> breadboarding.

You can do *everything* via USB. :) I joked about this several years ago
but then went searching and found USB to ISA slot and USB to PCI slot
adapters.  Folks use these to run expensive data acquisition cards.

Regards,
Paul
www.ControlPascal.com

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Marc Santhoff-2
On Do, 2016-07-21 at 08:39 -0500, Paul Breneman wrote:

> You can do *everything* via USB. :) I joked about this several years ago
> but then went searching and found USB to ISA slot and USB to PCI slot
> adapters.  Folks use these to run expensive data acquisition cards.

https://www.youtube.com/watch?v=MoREmn7SCwg ?

CNR,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
In reply to this post by Marc Santhoff-2
What I need to do is be able to read some 5v TTL Inputs in and write some 5v
TTL outputs out.  The parallel port always worked when my program was a DOS
program.. it was so simple, just do Port[$378]:= data to set the bits on the
port  or data:=port[$378] to read some bits from the port.   I'm not opposed
to some hardware other than a parallel port if it will be able to interface
with freepascal easily, if anyone can make a recommendation.   Serial ports
won't work because they are not made to just read and write bits like the
parallel port and they are not TTL voltage levels.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Marc Santhoff
Sent: Wednesday, July 20, 2016 11:29 PM
To: [hidden email]
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote:

> I am trying to get access to the parallel port with Free Pascal.  
>
> I'm trying to use this version of inpout32 (x64)
> http://www.highrez.co.uk/downloads/inpout32/
>
> Here's my program:
> http://pastebin.com/facf6EFc
>
> Here's my Unit:
> http://pastebin.com/XR0aYUPR
>
> When I try to run it, I get a windows message The application was
> unable to start correctly (0xc000007b). click ok to close the application.

You could search Microsofts web site to decode this error.

> then  I get Exitcode 123 in the Free Pascal IDE.  123 is decimal of 7b.
>
> Does anyone know how to get this to work?   reading and writing the
parallel
> port used to be so easy, now it's extremely confusing, thanks windows!

Didn't test, but as a remark: parallel port is dead and it has been a
constant source of problems. First the access rights problems you know of.
Second it has no fixed timing, so you're in trouble when e.g.
flashing a microcontroller works on one machine and refuses to on another
one. Third it is not electrically protected, if you fry it, the mainboard is
dead by chance or you have to insert an extension board - which is hard to
find nowadays, too.

Depending on your needs I'd suggest using a USB-to-serial-Adapter or
similar. They are cheap and well supported (e.g. using CP2102). As an
alternative FTDI has some nice USB-to-anything (including parallel) chips
and they sell modules with mil spacing pins for easy breadboarding.

HTH somehow,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Mark Morgan Lloyd-5
James Richters wrote:
> What I need to do is be able to read some 5v TTL Inputs in and write some 5v
> TTL outputs out.  The parallel port always worked when my program was a DOS
> program.. it was so simple, just do Port[$378]:= data to set the bits on the
> port  or data:=port[$378] to read some bits from the port.   I'm not opposed
> to some hardware other than a parallel port if it will be able to interface
> with freepascal easily, if anyone can make a recommendation.   Serial ports
> won't work because they are not made to just read and write bits like the
> parallel port and they are not TTL voltage levels.

Something like a Velleman K8055, which I've talked to using libusb on
Linux. Or an Arduino with appropriate firmware. Or go the whole hog and
port the program onto a Raspberry Pi: Bo's doing something like you're
asking.

Any of those have the advantage that the electronics can be positioned
to minimise the signal run carrying TTL. Long printer cables are
generally bad news.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Marc Santhoff-2
In reply to this post by Marc Santhoff-2
On Do, 2016-07-21 at 05:29 +0200, Marc Santhoff wrote:

> On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote:
> > I am trying to get access to the parallel port with Free Pascal.  
> >
> > I'm trying to use this version of inpout32 (x64)
> > http://www.highrez.co.uk/downloads/inpout32/ 
> >
> > Here's my program:
> > http://pastebin.com/facf6EFc
> >
> > Here's my Unit:
> > http://pastebin.com/XR0aYUPR
> >
> > When I try to run it, I get a windows message The application was
> unable to
> > start correctly (0xc000007b). click ok to close the application.
>
> You could search Microsofts web site to decode this error.

Or use a search engine:

http://www.techanges.com/fix-error-0xc00007b/
http://stackoverflow.com/questions/10492037/the-application-was-unable-to-start-correctly-0xc000007b

Looks like you are using a 32 Bit version on 64 bit or the like. The
original site tells about similar error:

http://www.highrez.co.uk/downloads/inpout32/

Look at the update history...


Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
Thank you!  I was indeed trying to use the 64bit DLL.. I mistakenly thought
you were supposed to use the version of the operating system, not the
program.

I have absolutely zero experience with windows programs.   I am able to run
my program now, but still not working exactly as I want it to work.. but I
think I might need to set my port to the right mode.. so I'll see if that
works.



-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Marc Santhoff
Sent: Friday, July 22, 2016 10:56 AM
To: [hidden email]
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
> > When I try to run it, I get a windows message The application was
> unable to
> > start correctly (0xc000007b). click ok to close the application.
>
> You could search Microsofts web site to decode this error.

Or use a search engine:

http://www.techanges.com/fix-error-0xc00007b/
http://stackoverflow.com/questions/10492037/the-application-was-unable-to-st
art-correctly-0xc000007b

Looks like you are using a 32 Bit version on 64 bit or the like. The
original site tells about similar error:

http://www.highrez.co.uk/downloads/inpout32/

Look at the update history...


Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
In reply to this post by Mark Morgan Lloyd-5
I like the looks of that Velleman K8055,  that would do the job for me if I
can get it to work.   I would actually prefer a linux port of my program
however I keep hitting a roadblock when I try to use the graph unit.  My
program used the turbo pascal graph unit exclusively for it's user interface
and I'm trying to avoid re-writing the entire thing.  It works fine in
windows, but when I try to run it on linux I can't get it to compile, it
can't find the graph unit.  I may have some directories set wrong or
something, I'm not sure, but that's what's holding me up on a linux port.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Mark Morgan
Lloyd
Sent: Friday, July 22, 2016 10:19 AM
To: [hidden email]
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

James Richters wrote:
> What I need to do is be able to read some 5v TTL Inputs in and write
> some 5v TTL outputs out.  The parallel port always worked when my
> program was a DOS program.. it was so simple, just do Port[$378]:= data to
set the bits on the
> port  or data:=port[$378] to read some bits from the port.   I'm not
opposed
> to some hardware other than a parallel port if it will be able to
interface
> with freepascal easily, if anyone can make a recommendation.   Serial
ports
> won't work because they are not made to just read and write bits like
> the parallel port and they are not TTL voltage levels.

Something like a Velleman K8055, which I've talked to using libusb on Linux.
Or an Arduino with appropriate firmware. Or go the whole hog and port the
program onto a Raspberry Pi: Bo's doing something like you're asking.

Any of those have the advantage that the electronics can be positioned to
minimise the signal run carrying TTL. Long printer cables are generally bad
news.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Mark Morgan Lloyd-5
James Richters wrote:

I was rather rushed earlier for reasons that would probably amuse but
would be vastly OT (shoving sheep around Sussex since we're shearing
Saturday...).

> I like the looks of that Velleman K8055,  that would do the job for me if I
> can get it to work.   I would actually prefer a linux port of my program

The Velleman boards usually come as kits, but they use PTH components
and are a doddle to assemble. My recollection is that the K8055 came
with something crude that allowed you to interface from e.g. Visual
Basic, however I found that somebody had reverse-engineered it and
produced a library (?) for Linux... I can't remember whether this was C
or Pascal. I used this with Lazarus (the IDE and class library that sits
on top of FPC) to produce something similar to Velleman's own demo app,
you'd obviously be welcome to this.

However in the general case I think it would be worth bearing in mind
that functionality of the Velleman board could fairly easily be
implemented using appropriate firmware on an Arduino, and this is likely
to be more "future proof" than a demo kit. But I don't have any ready
URLs etc.

> however I keep hitting a roadblock when I try to use the graph unit.  My
> program used the turbo pascal graph unit exclusively for it's user interface
> and I'm trying to avoid re-writing the entire thing.  It works fine in
> windows, but when I try to run it on linux I can't get it to compile, it
> can't find the graph unit.  I may have some directories set wrong or
> something, I'm not sure, but that's what's holding me up on a linux port.

Can't comment on that, but I see Graham's lending a hand. Particularly
if you're porting to Linux you do need to consider whether you're
planning to run in the context of a GUI or over SSH etc, what /exactly/
are you trying to display and on what sort of system?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
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.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Mark Morgan
Lloyd
Sent: Friday, July 22, 2016 5:39 PM
To: [hidden email]
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

James Richters wrote:

I was rather rushed earlier for reasons that would probably amuse but would
be vastly OT (shoving sheep around Sussex since we're shearing Saturday...).

> I like the looks of that Velleman K8055,  that would do the job for me if
I
> can get it to work.   I would actually prefer a linux port of my program

The Velleman boards usually come as kits, but they use PTH components and
are a doddle to assemble. My recollection is that the K8055 came with
something crude that allowed you to interface from e.g. Visual Basic,
however I found that somebody had reverse-engineered it and produced a
library (?) for Linux... I can't remember whether this was C or Pascal. I
used this with Lazarus (the IDE and class library that sits on top of FPC)
to produce something similar to Velleman's own demo app, you'd obviously be
welcome to this.

However in the general case I think it would be worth bearing in mind that
functionality of the Velleman board could fairly easily be implemented using
appropriate firmware on an Arduino, and this is likely to be more "future
proof" than a demo kit. But I don't have any ready URLs etc.

> however I keep hitting a roadblock when I try to use the graph unit.  
> My program used the turbo pascal graph unit exclusively for it's user
> interface and I'm trying to avoid re-writing the entire thing.  It
> works fine in windows, but when I try to run it on linux I can't get
> it to compile, it can't find the graph unit.  I may have some
> directories set wrong or something, I'm not sure, but that's what's
holding me up on a linux port.

Can't comment on that, but I see Graham's lending a hand. Particularly if
you're porting to Linux you do need to consider whether you're planning to
run in the context of a GUI or over SSH etc, what /exactly/ are you trying
to display and on what sort of system?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
In reply to this post by Mark Morgan Lloyd-5
I have an update on this.   I found a demo program here:
http://www.highrez.co.uk/downloads/inpout32/   I was able to successfully
run the demo program and access my parallel port.  I could write to it and
read back what I just wrote accurately.  I wrote '123' decimal to it, then
tried to read it back with my freepacal program,  it read 255.. then I tried
to read it back with the demo program, it was still 123.  So this proves
that my parallel port is working and that it works with this DLL.  The
question is, why can't I access it with my freepascal program?  

I am wondering if it has something to do with my variable declarations.  I
used shortint for the port address but I wonder If it should be something
else.. the c++ example used smallint, but maybe that's not the same thing?
I randomly tried some other types but still no luck.  There has to be some
simple reason why I can't get this to work... any ideas?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Marc Santhoff-2
In reply to this post by Zaaphod
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';

HTH,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Marc Santhoff-2
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
I get
Error: Calling convection doesn't match forward
Error: Found Declaration: IsInpOutDriverOpen:Boolean;

Do I need to specify the functions differently in the interface section?
Thanks for the help


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Marc Santhoff
Sent: Saturday, July 23, 2016 1:09 AM
To: [hidden email]
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
In reply to this post by Marc Santhoff-2
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: [hidden email]
[mailto:[hidden email]] On Behalf Of Marc Santhoff
Sent: Saturday, July 23, 2016 1:09 AM
To: [hidden email]
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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Bo Berglund
In reply to this post by Mark Morgan Lloyd-5
On Fri, 22 Jul 2016 14:19:20 +0000, Mark Morgan Lloyd
<[hidden email]> wrote:

>Or go the whole hog and
>port the program onto a Raspberry Pi: Bo's doing something like you're
>asking.

Yes, indeed! I now have something like 7-8 operational RPi units for
different purposes and in several places I have used the GPIO pins to
control and read back digital stuff from FPC programs. Very
convenient.

Last I did was to attach a 4-way relay board to a RPi and put a smapp
FPC command line program on it, which gets called from a PHP script on
the Apache webserver on the Pi.
Now I have a webpage, with which I can switch on/off the relays with
in order to control the operational state of some measuring equipment
sitting half way across the workd!

You could do a LOT with FPC and a Raspberry Pi!

Examples:
The Pi also runs an OpenVPN server so I can access it with PuTTY
and/or TightVNC to program it if I need to.

My Pi also has a port mapping utility which makes it possible for me
to remotely access a WiFi network device on a WiFi access point close
to the RPi again from a long distance away. THis was created with FPC
and Indy10 on the RPi.


>Any of those have the advantage that the electronics can be positioned
>to minimise the signal run carrying TTL. Long printer cables are
>generally bad news.

15 cm wires to the relay board...


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Bo Berglund
In reply to this post by Zaaphod
On Fri, 15 Jul 2016 14:59:10 -0700 (MST), Zaaphod
<[hidden email]> wrote:

>I am trying to get access to the parallel port with Free Pascal.  
>
>I'm trying to use this version of inpout32 (x64)
>http://www.highrez.co.uk/downloads/inpout32/ 
>
>Here's my program:
>http://pastebin.com/facf6EFc
>
>Here's my Unit:
>http://pastebin.com/XR0aYUPR
>
>When I try to run it, I get a windows message The application was unable to
>start correctly (0xc000007b). click ok to close the application.
>
>then  I get Exitcode 123 in the Free Pascal IDE.  123 is decimal of 7b.
>
>Does anyone know how to get this to work?   reading and writing the parallel
>port used to be so easy, now it's extremely confusing, thanks windows!

If I remember correctly the printer port was originally on the ISA
bus, which is no longer present on modern day PC:s.
On that bus the programs could simply address the port and read/write
data to say $378 (LPT1:).
I used that ages ago too.
But then it changed on both the PC hardwaere and in Windows (more
protection of the bits) and direct access stopped working.
I think you need another solution for the hardware.


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows

Zaaphod
In reply to this post by Bo Berglund
Bo,
I also have a raspberry pi project..  I got a hifi-berry card for it and it
is streaming audio to a central audio system, I'm using VLC media player and
an app on my cell phone to control it,  I have not made use of the GPIO on
them yet, but I would really like to learn how this can be accomplished with
FPC, since I am more familiar with pascal than any other language, it would
be great to learn how to do this!  I have a particular application in mind.
I have a relay board that will turn relays on and off with TTL level
signals, what I wish to do is have a remote way to turn certain amplifiers
on and off.   There are 24 amplifiers going to 44 speakers (4 are
subwoffers) in and around my house, sometimes I'll want just downstairs and
outside amps on, other times I'll want just one room on, or all amps on....
etc.    The amps are all in my crawlspace under the first floor, and that's
where the raspberry pi is.  I also have some volume control chips that are
controlled by clocking data into them, I could chain them all together and
be able to control all of them with just one clock and one data bit.  
Any advice on how to get started on controlling GPIO with a raspberry pi
with FPC would be greatly appreciated!

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Bo Berglund
Sent: Sunday, July 24, 2016 2:22 AM
To: [hidden email]
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

On Fri, 22 Jul 2016 14:19:20 +0000, Mark Morgan Lloyd
<[hidden email]> wrote:

>Or go the whole hog and
>port the program onto a Raspberry Pi: Bo's doing something like you're
>asking.

Yes, indeed! I now have something like 7-8 operational RPi units for
different purposes and in several places I have used the GPIO pins to
control and read back digital stuff from FPC programs. Very convenient.

Last I did was to attach a 4-way relay board to a RPi and put a smapp FPC
command line program on it, which gets called from a PHP script on the
Apache webserver on the Pi.
Now I have a webpage, with which I can switch on/off the relays with in
order to control the operational state of some measuring equipment sitting
half way across the workd!

You could do a LOT with FPC and a Raspberry Pi!

Examples:
The Pi also runs an OpenVPN server so I can access it with PuTTY and/or
TightVNC to program it if I need to.

My Pi also has a port mapping utility which makes it possible for me to
remotely access a WiFi network device on a WiFi access point close to the
RPi again from a long distance away. THis was created with FPC and Indy10 on
the RPi.


>Any of those have the advantage that the electronics can be positioned
>to minimise the signal run carrying TTL. Long printer cables are
>generally bad news.

15 cm wires to the relay board...


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parallel Port Access with Free Pascal - windows - PiGpio.zip (0/1)

Bo Berglund
On Sun, 24 Jul 2016 10:29:04 -0400, "James Richters"
<[hidden email]> wrote:

>Bo,
>I also have a raspberry pi project..  I got a hifi-berry card for it and it
>is streaming audio to a central audio system, I'm using VLC media player and
>an app on my cell phone to control it,  I have not made use of the GPIO on
>them yet, but I would really like to learn how this can be accomplished with
>FPC, since I am more familiar with pascal than any other language, it would
>be great to learn how to do this!  I have a particular application in mind.
>I have a relay board that will turn relays on and off with TTL level
>signals, what I wish to do is have a remote way to turn certain amplifiers
>on and off.   There are 24 amplifiers going to 44 speakers (4 are
>subwoffers) in and around my house, sometimes I'll want just downstairs and
>outside amps on, other times I'll want just one room on, or all amps on....
>etc.    The amps are all in my crawlspace under the first floor, and that's
>where the raspberry pi is.  I also have some volume control chips that are
>controlled by clocking data into them, I could chain them all together and
>be able to control all of them with just one clock and one data bit.  
>Any advice on how to get started on controlling GPIO with a raspberry pi
>with FPC would be greatly appreciated!
>

It has been discussed over at the Raspberry Pi forum. Basically the
solution is to use a modified version of teh PiGpio.pas driver.
Here are a few threads where I was involved:

https://www.raspberrypi.org/forums/viewtopic.php?p=826439#p826439

https://www.raspberrypi.org/forums/viewtopic.php?p=826888#p826888

I have attached a zipped version of the PiGpio.pas driver file for
you.


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12
Loading...