Actually I was suggesting the really simple way with apt install but there is 
another.

The fpupdeluxe is a windowing install application that allows you to create any 
version for any target on your PC.  I did install it on my Beagle and yes,  
hours later it's done but that's because the beagle is a bit of a pig.  Went 
much faster on a Pi3 and on both a LinuxCNC PC and WIN-7 PC lightning fast.  
And you can install which target you want to compile for. 

The key here is that for the most part you write once, compile either anywhere 
or on the same machine for anywhere along with an IDE for much faster program 
development.  The blinky.lpi project that I referred to is a command line 
program.  

But I'm trying to keep this discussion pointed in the direction of the subject 
line.  The problem with access to GPIO seems to exist in both the Pi and Beagle 
world.  One posting mentioned how his software broke when the Pi OS was 
upgraded to 4.14.

The issues seem to be the same.  Something with udev and creating the correct 
scripts and files.
https://stackoverflow.com/questions/41586162/access-gpio-on-beaglebone-as-non-root-user

The problem with the above link is that step 1 running 
80-gpio-permissions.rules doesn't work for me because it doesn't exist on my 
system and the contents of that file aren't listed.

However they are in the reference but in that reference the revision of the 
kernel is 4.4.36
https://github.com/adafruit/adafruit-beaglebone-io-python/issues/137

My experience with changing Beagle versions is fraught with disaster where the 
change then breaks all sorts of stuff that was working.  This is why I'm 
staying on 4.11 which is what the book uses and at least there's 1.25" of paper 
all pointing to the same OS.  

So.   Should I just blindly, in the command line way, type all that stuff with 
no idea of why I'm doing it, run it and if it works be happy? 

As an example  the second link uses:
chown -R nick:digital /sys/devices/gpio

The first link above uses
chown -R debian:root /sys/devices/gpio

I think debian:root is what I want to do but I don't understand why the 
nick:digital allows root access.  Why not nick:root?

And the second link with nick's /usr/local/bin/udev-gpio-permissions.sh has a 
lot more lines in it.

As I said, this appears to have been an ongoing issue for more than 7 years.   
And perhaps the latest OS fixes it?  But then I have to go through the process 
of rebuilding an entire system.  Like going from WIN-7 to WIN-10.  What a pain.

John



> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On 
> Behalf Of Dennis Lee Bieber
> Sent: May-11-21 5:30 PM
> To: Beagleboard
> Subject: [beagleboard] Re: Using GPIOs without Using sudo
> 
> On Tue, 11 May 2021 09:43:49 -0700, in gmane.comp.hardware.beagleboard.user
> "John Dammeyer" <[email protected]> wrote:
> 
> 
> >To try this program do sudo apt install lazarus.
> >
>       I think not... Not for an experiment at least. No offence intended, but
> it wants to install over 1GB of stuff -- which is a 33% increase in the
> content of my uSD card!, and would require me to attach a keyboard and
> display to work with the GUI.
> 
>       Now, a simple command line only program would be a different matter
> (does FPC support command line only? -- FPC may be small enough to justify
> installing for testing via SSH, but not Lazarus... *** nope, just FPC is
> most of the load, 900+MB)
> 
>       An example using GNAT (Ada). There is no (or I don't know of one)
> library for GPIO access in GNAT Ada, so everything is SysFS I/O. I had to
> set the pin number to string as the simple integer'image(pin) was
> generating leading spaces, which resulted in invalid file name. Everything
> is in one (117 line) file -- no nasty forms, etc.
> 
> debian@beaglebone:~/BBB_IO$ ls
> main.adb
> debian@beaglebone:~/BBB_IO$ cat main.adb
> with Ada.Text_IO;         use Ada.Text_IO;
> with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
> 
> procedure Main is
> 
>    Sysfs_Path : constant String := "/sys/class/gpio";
>    GPIO_Pin   : constant String := "48";
>    Pin_Value  : Integer;
> 
>    procedure Export_Pin (Pin : in String) is
> 
>       Export_File : File_Type;
>       Export_Path : constant String := Sysfs_Path & "/export";
> 
>    begin
>       Put_Line ("Opening " & Export_Path);
>       Open (Export_File, Mode => Out_File, Name => Export_Path);
> 
>       Put_Line ("Writing pin number: " & Pin);
>       Put (Export_File, Pin);
> 
>       Put_Line ("Closing " & Export_Path);
>       Close (Export_File);
> 
>       New_Line;
> 
>    end Export_Pin;
> 
>    procedure Set_Direction (Pin : in String; Direction : in String) is
>       Pin_File : File_Type;
>       Pin_Path : constant String := Sysfs_Path & "/gpio" & Pin &
> "/direction";
> 
>    begin
>       Put_Line ("Opening " & Pin_Path);
>       Open (Pin_File, Mode => Out_File, Name => Pin_Path);
> 
>       Put_Line ("Writing direction: " & Direction);
>       Put (Pin_File, Direction);
> 
>       Put_Line ("Closing " & Pin_Path);
>       Close (Pin_File);
> 
>       New_Line;
> 
>    end Set_Direction;
> 
>    procedure Set_Value (Pin : in String; Value : in Integer) is
> 
>       Pin_File : File_Type;
>       Pin_Path : constant String := Sysfs_Path & "/gpio" & Pin & "/value";
> 
>    begin
>       Put_Line ("Opening " & Pin_Path);
>       Open (Pin_File, Mode => Out_File, Name => Pin_Path);
> 
>       Put_Line ("Writing value: " & Integer'Image (Value));
>       Put (Pin_File, Value, Width => 1);
> 
>       Put_Line ("Closing " & Pin_Path);
>       Close (Pin_File);
> 
>       New_Line;
> 
>    end Set_Value;
> 
>    procedure Get_Value (Pin : in String; Value : out Integer) is
> 
>       Pin_File : File_Type;
>       Pin_Path : constant String := Sysfs_Path & "/gpio" & Pin & "/value";
>       In_Value : String          := " ";
> 
>    begin
>       Put_Line ("Opening " & Pin_Path);
>       Open (Pin_File, Mode => In_File, Name => Pin_Path);
> 
>       Put_Line ("Reading value");
>       Get (Pin_File, Value, Width => 0);
> 
>       Put_Line ("Closing " & Pin_Path);
>       Close (Pin_File);
> 
>       New_Line;
> 
>    end Get_Value;
> 
> begin
>    -- Believe the pins are already exported in Buster
>    --Export_Pin (Gpio_Pin);
> 
>    Get_Value (GPIO_Pin, Pin_Value);
>    Put_Line
>      ("Current value of " & GPIO_Pin & " is " & Integer'Image (Pin_Value));
>    New_Line;
> 
>    Set_Direction (GPIO_Pin, "out");
> 
>    New_Line;
> 
>    Get_Value (GPIO_Pin, Pin_Value);
>    Put_Line
>      ("Current value of " & GPIO_Pin & " is " & Integer'Image (Pin_Value));
> 
>    New_Line;
> 
>    Set_Value (GPIO_Pin, 0);
>    Get_Value (GPIO_Pin, Pin_Value);
>    Put_Line
>      ("Current value of " & GPIO_Pin & " is " & Integer'Image (Pin_Value));
> 
>    New_Line;
> 
>    Set_Value (GPIO_Pin, 1);
>    Get_Value (GPIO_Pin, Pin_Value);
>    Put_Line
>      ("Current value of " & GPIO_Pin & " is " & Integer'Image (Pin_Value));
> 
> end Main;
> debian@beaglebone:~/BBB_IO$
> 
> debian@beaglebone:~/BBB_IO$ gnatmake main
> arm-linux-gnueabihf-gcc-8 -c main.adb
> arm-linux-gnueabihf-gnatbind-8 -x main.ali
> arm-linux-gnueabihf-gnatlink-8 main.ali
> debian@beaglebone:~/BBB_IO$
> debian@beaglebone:~/BBB_IO$ ls
> main  main.adb  main.ali  main.o
> debian@beaglebone:~/BBB_IO$
> debian@beaglebone:~/BBB_IO$ ./main
> Opening /sys/class/gpio/gpio48/value
> Reading value
> Closing /sys/class/gpio/gpio48/value
> 
> Current value of 48 is  1
> 
> Opening /sys/class/gpio/gpio48/direction
> Writing direction: out
> Closing /sys/class/gpio/gpio48/direction
> 
> 
> Opening /sys/class/gpio/gpio48/value
> Reading value
> Closing /sys/class/gpio/gpio48/value
> 
> Current value of 48 is  0
> 
> Opening /sys/class/gpio/gpio48/value
> Writing value:  0
> Closing /sys/class/gpio/gpio48/value
> 
> Opening /sys/class/gpio/gpio48/value
> Reading value
> Closing /sys/class/gpio/gpio48/value
> 
> Current value of 48 is  0
> 
> Opening /sys/class/gpio/gpio48/value
> Writing value:  1
> Closing /sys/class/gpio/gpio48/value
> 
> Opening /sys/class/gpio/gpio48/value
> Reading value
> Closing /sys/class/gpio/gpio48/value
> 
> Current value of 48 is  1
> debian@beaglebone:~/BBB_IO$
> 
>        Again, under a Buster IoT image (no X-Window overhead), NO SUDO NEEDED
> FOR GPIO48 -- and it is already exported so I could even skip the export
> call.
> 
>       I'm not going to try to configure a SPI device for testing.
> 
> 
> --
> Dennis L Bieber
> 
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/cr0m9g5jld35qrvviacghq4ut5o2aivj9q%404ax.com.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/097f01d746d1%2450a9e660%24f1fdb320%24%40autoartisans.com.

Reply via email to