Recent

Author Topic: FPC on Rasp Pi, non Lazarus, use of GPIO.  (Read 6869 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 2540
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #105 on: March 01, 2021, 01:14:23 am »
Go back and look at my example.

Code: Pascal  [Select][+][-]
  1.         pChip := Gpiod.gpiod_chip_open(PChar(gpiochip));
  2.         if pChip = nil then
  3. ...
  4.  

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

AlanTheBeast

  • Full Member
  • ***
  • Posts: 188
  • My software never cras....
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #106 on: March 01, 2021, 03:42:50 pm »

Without changing my code, but changing the path again, it finally worked.  Some typo before? (rhetoric)

Anyway, path
      Const
       GPIOPath : Pchar = '/dev/gpiochip0';
works

      GPIOPath : Pchar = '/sys/class/gpio/gpiochip0';   
does not work, returns a nil for the chiphandle.

Onward ...
Thanks.
Everyone talks about the weather but nobody does anything about it.
..Samuel Clemens.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2540
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #107 on: March 01, 2021, 07:28:07 pm »
      GPIOPath : Pchar = '/sys/class/gpio/gpiochip0';   
does not work, returns a nil for the chiphandle.

Of course it doesn't work! Have you taken the trouble to read my #89, and in particular did you read the bit that referred to the gpiodetect command and gave you an example of its output? Did you look at the gpiodetect manpage, and in particular the "see also" section that pointed you at the various utility commands... the source for which you can read if you're in any doubt about the documented API?

The two set of names- those in sysfs and those in /dev- are for DIFFERENT APIS, and you can't just mix-and-match at random and expect things to work.

Except obviously where you have to, for reasons that I did my best to explain, and even then you're effectively running them in parallel rather than chucking them into a communal pot.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

AlanTheBeast

  • Full Member
  • ***
  • Posts: 188
  • My software never cras....
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #108 on: March 01, 2021, 10:31:20 pm »

I had tried both paths without success.  (And for the avoidance of doubt, in case it matters, I did remove the gpiod unit).

And had compiled, running (crash or not) code with the correct one.  Something else was amiss.  So I try things to see what happens.

pi@raspberrypi:~/Documents/PharosGPS $ gpiodetect
gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)

Doesn't really clarify where they are, now does it? (other than that there is -h and -v ... no other commands).

Further the following call does not work (crashes) with a valid path in it:
           t := gpiod.gpiod_is_gpiochip_device(PChar('/dev/gpiochip0'));

Which sends one down other rabbit holes...

Now trying to figure out serial data (UART).  That is truly opaque in this well documented program.

Esp. as I don't have a reliable source of UART input that I know for sure is outputting data to the pin...
Perhaps a loop back from terminal ... tbd.

I get you're frustrated.  To me, all of this is abstracted to the point of incomprehensibility and densely worded documentation doesn't show clearly.  Also: I'm not a Linux guy.  At all.  I don't use API's much.  At all.   When I had hardware to interface to, I always did it at the lowest level possible.  Not portable.  That was never the intention.  Nor is it with the current project.

Cheers,

Big boom from Hermann in your old home town the other day ...
Everyone talks about the weather but nobody does anything about it.
..Samuel Clemens.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2540
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #109 on: March 02, 2021, 08:25:03 am »
pi@raspberrypi:~/Documents/PharosGPS $ gpiodetect
gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)

Doesn't really clarify where they are, now does it? (other than that there is -h and -v ... no other commands).

As I said, that is a problem. Refer to your hardware documentation to find out which are which.

Quote
Further the following call does not work (crashes) with a valid path in it:
           t := gpiod.gpiod_is_gpiochip_device(PChar('/dev/gpiochip0'));

I ALREADY TOLD YOU THAT ONE WASN'T IMPLEMENTED!!!!! Message #76, and being able to cope with that sort of thing is one of the big advantages of dynamic linkage.

Quote
Now trying to figure out serial data (UART).  That is truly opaque in this well documented program.

Esp. as I don't have a reliable source of UART input that I know for sure is outputting data to the pin...

Not my problem until you start looking at the serial.pp unit. In a separate topic.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

AlanTheBeast

  • Full Member
  • ***
  • Posts: 188
  • My software never cras....
Re: FPC on Rasp Pi, non Lazarus, use of GPIO.
« Reply #110 on: March 02, 2021, 02:08:59 pm »

Sorry Mark,

The mind wanders - didn't realize I repeated that.

I'll be looking more at the UART later this week.  Full work days ahead, alas.
Everyone talks about the weather but nobody does anything about it.
..Samuel Clemens.

 

TinyPortal © 2005-2018