Recent

Author Topic: Native read GPIO pin function.  (Read 1293 times)

pascalbythree

  • Full Member
  • ***
  • Posts: 237
Native read GPIO pin function.
« on: September 04, 2023, 04:53:07 pm »
Hey everybody, does anyody know how to convert this procedure to a read PIN function;

Code: Pascal  [Select][+][-]
  1.     { Swith SoC pin 17 on: }
  2.     gReturnCode := fpsystem('echo "1" > /sys/class/gpio/gpio17/value');
  3.     LogMemo.Lines.Add(IntToStr(gReturnCode));

as seen in this wiki:

https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Native_hardware_access

i want to use the fpsystem procedure and if you will take a closer look at te website, it is only described to use by a fpopen

Please reply without using hwiringpi, PX,L etc. I would like to use native code.


Greets, Wouter van Wegen

To get more response, this is the project photo:



It is because PXL does not compile on my brand new RPI4, and i want to shift over to native code from here to control upcomming problems...
« Last Edit: September 04, 2023, 04:59:29 pm by pascalbythree »

ojz0r

  • Jr. Member
  • **
  • Posts: 55
Re: Native read GPIO pin function.
« Reply #1 on: September 04, 2023, 07:20:22 pm »
Why do you want to use fpsystem call instead of a concrete working example with fpopen?
Just trying to learn.

ccrause

  • Hero Member
  • *****
  • Posts: 793
Re: Native read GPIO pin function.
« Reply #2 on: September 04, 2023, 08:48:45 pm »
I've recently started testing the IOCTL native interface, see e.g. this discussion on why it is supposed to be a "better" alternative.  A simple demo using gpio.pas.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6378
Re: Native read GPIO pin function.
« Reply #3 on: September 05, 2023, 08:22:27 am »
I've recently started testing the IOCTL native interface, see e.g. this discussion on why it is supposed to be a "better" alternative.  A simple demo using gpio.pas.

Thread at https://forum.lazarus.freepascal.org/index.php/topic,56063.msg416733.html#msg416733 applies.

It's better than going through the /sys/class etc. tree, but when I looked at it the API was far from stable.

*HOWEVER* it's applicable to more than just RPi, and I consider that to be an important consideration.

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

 

TinyPortal © 2005-2018