Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-07

Parallel Port Access with Free Pascal - windows

30 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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!

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Parallel-Port-Access-with-Free-Pascal-windows-tp5725725.html Sent from the Free Pascal - General mailing list .
Marc Santhoff
to Zaaphod
Zaaphod wrote 13 lines
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

Paul Breneman
to Marc Santhoff

On 07/20/2016 10:29 PM, Marc Santhoff wrote:
...

Show quoted text 5 lines
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

James Richters
to Marc Santhoff: You could search Microsofts web site to decode this error. Didn't test, but as a remark:…

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.

Earlier message 47 lines
-----Original Message----- From: On Behalf Of Marc Santhoff Sent: Wednesday, July 20, 2016 11:29 PM To: 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
Mark Morgan Lloyd
to James Richters
James Richters wrote 8 lines
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]
Marc Santhoff
to Marc Santhoff: You could search Microsofts web site to decode this error. Didn't test, but as a remark:…
Marc Santhoff wrote 17 lines
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

James Richters
to Marc Santhoff

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.

Earlier message 28 lines
-----Original Message----- From: On Behalf Of Marc Santhoff Sent: Friday, July 22, 2016 10:56 AM To: 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
James Richters
to Mark Morgan Lloyd: Something like a Velleman K8055, which I've talked to using libusb on Linux. Or an…

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.

Earlier message 35 lines
-----Original Message----- From: On Behalf Of Mark Morgan Lloyd Sent: Friday, July 22, 2016 10:19 AM To: 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]
Mark Morgan Lloyd
to James Richters

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.

Show quoted text 6 lines
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]
James Richters
to Mark Morgan Lloyd

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.

Earlier message 49 lines
-----Original Message----- From: On Behalf Of Mark Morgan Lloyd Sent: Friday, July 22, 2016 5:39 PM To: 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]
James Richters
to Mark Morgan Lloyd: I was rather rushed earlier for reasons that would probably amuse but would be vastly OT…

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?

Marc Santhoff
to James Richters: I'm trying to avoid custom hardware if possible. I have always used parallel ports and…
James Richters wrote 20 lines
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

Marc Santhoff
to Marc Santhoff
Marc Santhoff wrote 33 lines
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

James Richters
to Marc Santhoff

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

Earlier message 58 lines
-----Original Message----- From: On Behalf Of Marc Santhoff Sent: Saturday, July 23, 2016 1:09 AM To: 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
James Richters
to Marc Santhoff: No, sorry. It has to be the other way round: Function IsInpOutDriverOpen; {$ifndef…

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!

Earlier message 58 lines
-----Original Message----- From: On Behalf Of Marc Santhoff Sent: Saturday, July 23, 2016 1:09 AM To: 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
Bo Berglund
to Mark Morgan Lloyd: Something like a Velleman K8055, which I've talked to using libusb on Linux. Or an…
Mark Morgan Lloyd 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
Bo Berglund
to Zaaphod: I am trying to get access to the parallel port with Free Pascal. I'm trying to use this…
Zaaphod wrote 18 lines
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
James Richters
to Bo Berglund: On Fri, 22 Jul 2016 14:19:20 +0000, Mark Morgan Lloyd Yes, indeed! I now have something…

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!

Earlier message 48 lines
-----Original Message----- From: On Behalf Of Bo Berglund Sent: Sunday, July 24, 2016 2:22 AM To: Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows On Fri, 22 Jul 2016 14:19:20 +0000, Mark Morgan Lloyd 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
Bo Berglund
to James Richters
"James Richters" wrote 19 lines
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
Bo Berglund
to James Richters: I also have a raspberry pi project.. I got a hifi-berry card for it and it is streaming…

begin 644 PiGpio.zip
(`#Q/F4CB2,",F```*````4&E'<&EO+G!A<\U9_U/B
MR!+_>?DK^JJL.CA920*Z*K=7AP((GF;4A22=!UM_9_?Y^>
M228!T=-7WKY'N9#T]/27S_3T]/2N`B^ED7<6>6&[\JU")Z<
MQ8V7I/$#=6/O3L1ULOTDI(4=T"H1E(:TM`,,;T5,<3[+CH6=
M5"HTO?426H2.(/RF(DF%0V'@/]!)'-K.(ES2?+&46B&D3H[GNB(600H!2R8E MT/-`@<`T/5:A&YA,CC2,O&7DBR7(=NJ%`51:AMFD,WL>QC3Y&OI^F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H^915CCDA_&VDN!%YS3MDG6(+R4] MN8TYLW(6LVJZ^I#0J+3+7#_0\^TMMS?TO67\G_A>OI-(UY_K5[XA`/O6TP!P M\5(^_0L8<-Y_S"J'S>NXJCHV&Q0_M-I^IEV:`1>M'*ZF5XXZ<K<!R"POP,]L M'9($B_EEL+"^MDK>JO`SZF36498=#UTH[8;W,.HJJCR3S+5A?Z_^N?7+Q&R$ ML,QDSZG6*7A#A$$_<!W_OI5]7VY5;KD9,9$O>_E5*E_8)TKM0Y3:X.4I^4$@ M_[=05]M-5-NZ%B_8S'4V&?WBBY?J8^)%QQ(6,5*-H=)II+SEK:?J[I-^7]YA M9>6PT'>??VI1(':O4OD/4$L!`A0`%``")(P4VN"P``(R8```H` M);RYP87,*`"````````$`&```VCLMR)[1
G`0#:.RW(GM$!T(SN6EJDT0%02P4&``````$``0!<
`
end

Koenraad Lelong
to James Richters: I also have a raspberry pi project.. I got a hifi-berry card for it and it is streaming…

Op 24-07-16 om 16:29 schreef James Richters:

Show quoted text 54 lines
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: On Behalf Of Bo Berglund Sent: Sunday, July 24, 2016 2:22 AM To: Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows On Fri, 22 Jul 2016 14:19:20 +0000, Mark Morgan Lloyd 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.

While Bo's contribution is valid, I have the impression that the raspberry is going to the pigpiod. Newer raspbian images have a switch (in raspi-config/advanced options) to enable a gpio-server. Using that it is possible to access all gpio-functions (gpio, serial, spi, pwm, ...) as a normal user. See http://abyz.co.uk/rpi/pigpio/index.html. There is a snag : the communication with the server happens via the network, so it could be that your pi will be hijacked, unless you take precautions.

FWIW, I ported the library to fpc, together with the test/demo software (x_pigpiod_if2).
The fact that the communication goes via the network opens possibilities though. I tested my port on my laptop, connected to the pi. So applications running on a remote PC could control the pi's IO.

I have no public place to publish this software, so if anyone is interested, please ask.

Koenraad.

Bo Berglund
to Koenraad Lelong
Koenraad Lelong wrote 9 lines
FWIW, I ported the library to fpc, together with the test/demo software (x_pigpiod_if2). The fact that the communication goes via the network opens possibilities though. I tested my port on my laptop, connected to the pi. So applications running on a remote PC could control the pi's IO. I have no public place to publish this software, so if anyone is interested, please ask.

I would be interested and I could put it up on my webserver if you like a public spot.

Bo Berglund Developer in Sweden
Unknown author
to Bo Berglund

yes thank you

Earlier message 27 lines
-----Original Message----- From: Bo Berglund To: fpc-pascal Sent: Tue, Jul 26, 2016 10:49 pm Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows On Tue, 26 Jul 2016 11:45:51 +0200, Koenraad Lelong wrote: >FWIW, I ported the library to fpc, together with the test/demo software >(x_pigpiod_if2). >The fact that the communication goes via the network opens possibilities >though. I tested my port on my laptop, connected to the pi. So >applications running on a remote PC could control the pi's IO. > >I have no public place to publish this software, so if anyone is >interested, please ask. > I would be interested and I could put it up on my webserver if you like a public spot. -- Bo Berglund Developer in Sweden
Unknown author
to Bo Berglund

i think it is the ight place i also like to rcv the software for directly controling i/o ports for fpc on wimdows Thank you
Ezra

Earlier message 19 lines
-----Original Message----- From: Bo Berglund To: fpc-pascal Sent: Wed, Jul 27, 2016 1:56 am Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows On Tue, 26 Jul 2016 16:23:12 -0400, wrote: >yes thank you You responded to the wrong post... -- Bo Berglund Developer in Sweden
James Richters
to Unknown author
i think it is the ight place i also like to rcv the software for directly controling i/o ports for fpc on wimdows Thank you Ezra

Ezra,

here’s the link to the FPC files. https://github.com/Zaaphod/FPC-Parallel-Port

The InpOut32 driver is here: http://www.highrez.co.uk/downloads/inpout32/

I am able to control the parallel port directly under Windows 7 Professional on this motherboard https://www.amazon.com/gp/product/B00IW99S4A It has on board parallel port on a header.

James

James Richters
to Bo Berglund: On Tue, 26 Jul 2016 11:45:51 +0200, Koenraad Lelong I would be interested and I could put…
Show quoted text 11 lines
>FWIW, I ported the library to fpc, together with the test/demo software >(x_pigpiod_if2). >The fact that the communication goes via the network opens >possibilities though. I tested my port on my laptop, connected to the >pi. So applications running on a remote PC could control the pi's IO. > >I have no public place to publish this software, so if anyone is >interested, please ask. > I would be interested and I could put it up on my webserver if you like a

public spot.

I would also be interest in this

Bo Berglund
to Bo Berglund: On Tue, 26 Jul 2016 11:45:51 +0200, Koenraad Lelong I would be interested and I could put…
Bo Berglund wrote 15 lines
On Tue, 26 Jul 2016 11:45:51 +0200, Koenraad Lelong wrote: >FWIW, I ported the library to fpc, together with the test/demo software >(x_pigpiod_if2). >The fact that the communication goes via the network opens possibilities >though. I tested my port on my laptop, connected to the pi. So >applications running on a remote PC could control the pi's IO. > >I have no public place to publish this software, so if anyone is >interested, please ask. > I would be interested and I could put it up on my webserver if you like a public spot.

I have received the code now but the project contained in the zip does not build on my RPi3 with Raspbian and Lazarus 1.6 FPC 3.0.

I get the following error message:

Compile Project, Target: x_pigpiod_if2: Exit code 256, Errors: 1 /usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: cannot find -lpigpiod_if2
x_pigpiod_if2.lpr(21,0) Error: Error while linking

The file it complains about is pigpiod_if2 and is not contained in the zipfile. But there is a pigpiod_if2.pas file that seems to define a lot of functions contained in a file with this name... I do not know if it is an external binary library, which must be supplied or where it resides.

Bo Berglund Developer in Sweden
James Richters
to James Richters: here’s the link to the FPC files. https://github.com/Zaaphod/FPC-Parallel-Port The…

I have updated my unit for accessing parallel ports on Windows with Freepascal to now select the correct .dll file depending on how the program is compiled.

It now uses

inpout32.dll if you compile for Win32

inpoutx64.dll if you compile for Win64

I also added a new sample program that can be compiled for Win32 or Win64 which also demonstrates some of the other procedures and functions available.

Here are links:

here’s the link to the FPC sample files. https://github.com/Zaaphod/FPC-Parallel-Port

The InpOut32 and InpOutx64 drivers are here: http://www.highrez.co.uk/downloads/inpout32/

James