Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
OK, I have now subscribed to the fpc-other list. Hopefully I can ask "stupid" fpc usage questuions there... Best Regards, Bo Berglund -Original Message- You just mentioned that you don't like to subscribe to mailing lists because you already receive many mails. By posting mails on a list that are not really on topic, you make that exact same problem worse for other people that do prefer to use email rather than use a web or nntp interface. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On 09/10/15 09:33, Jonas Maebe wrote: > Bo Berglund wrote: >> I have asked about this on the Pi forum instead, but I fear noone >> (almost) over there use free-pascal so I have no high hopes. > > The point is that this question is completely unrelated to Pascal or > Free Pascal. It's a basic Unix/Linux usage question, which is > independent of the used programming language. If you ask how to > access "GPIO pins on RPi2 without root" on a Linux/Raspberry forum, > any answer you will get will equally apply to FPC as to any other > language. You already have the Pascal code to access the pins from > the wiki, per a previous post of yours, so you don't have to mention > FPC/Pascal at all. > > You just mentioned that you don't like to subscribe to mailing lists > because you already receive many mails. By posting mails on a list > that are not really on topic, you make that exact same problem worse > for other people that do prefer to use email rather than use a web or > nntp interface. > Hi Jonas, would you support us, writing to Gmane to actually subscribe to fpc-other mailing list ? Gmane is nice not just for storage, I just more like separation of traffic between my emails and the actual discussions; like in the olden days... and I'm sorry but forums don't really cut it for me, for various reasons. el es ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root? [lenghty and very [OT] ]
On 09/10/15 08:50, Bo Berglund wrote: > On Thu, 08 Oct 2015 22:01:49 +, Mark Morgan Lloyd > wrote: >>> Sorry for causing a problem here... >>> The lists you refer to are not present in the Gmane newsserver as a >>> newsgroup so I cannot access it. >> >> I suggest setting up a direct subscription using the instructions given >> at http://www.freepascal.org/maillist.var Things like Gmane are really >> only useful as long-term archives. > > Well, I don't like to have my inbox receive the number of emails on a > list like this. The new interface is a much better way in my view. > I already receive 100+ emails every day so doubling this seems not to > be a good way for me > I second that, especially thread.gmane.org is nice - also one can use the mail to news gateway, through any news/reader/mua (like I use thunderbird). Bo, how about if we petition the gmane admins to subscribe to fpc-other? There is a lot of discussion that seems to be going on there. If you write one like that, you've got my vote too. (and sorry to the list admins, for bringing it on this list/topic, gmane tries to obfuscate senders emails when using the mail-to-news gateway) >>> I will try to locate an updated pigpio.pas file by asking in the >>> Lazarus forum instead. >> >> I would strongly suggest going through /sys/class/gpio first, since you >> can exercise it using echo and there are fewer things to get wrong. > > I have seen you mention "echo" a number of times and I have gone back > (in the Gmane gmane.comp.compilers.free-pascal.general news archive in > my newsreader) to locate the exact method for this but I failed. (again sorry to the admins here that this may be lengthy and ot, but Bo's email has been garbled by Gmane) 'echo' is a distribution-contained (usually a separate program, but that depends on the distribution) that writes its given parameters to std-output, as text, then the '>' redirects it to a file. Long story short, most you need to remember, in unix-like systems everything that can be, is treated as a file, placed under the single virtual file system (VFS) hierarchy. No 'drive letters', etc. When you issue a command 'echo something > /path/to/file' there are several things that may happen; The '>' operation tells the shell to take the echo's std-output and write it to the file. (OT: if you used >> instead, it would have been added/appended to file; only really works on disk for this reason) In higher-level compiled languages like c or pascal you achieve this by opening the file, writing to it (possibly preceded by doing a 'rewrite' it, but not sure) and then closing. (remember that either of these 3 operations may throw an error which you need to handle) in case of GPIO, the in-kernel driver has VFS hooks that tell it : - someone has 'just' replaced the content of the file in its virtual filesystem hierarchy under /sys/class/gpio/* with 'something', so it intercepts that write, interprets/sanitizes what it has been given, and handles the userspace programs writing to that file. It also detects 'reads' from the file similarly, some drivers support just reading from a file in a loop, by means of likes of: 'open-repeat-read-sleep-untilneeded-close'; but some may need an 'repeat-open-read-close-sleep-untilneeded' pattern; there is also a family of *notify system functions/calls, but that seems to not be as loved by the system/kernel developers as the simpl(istic) open-read-close chain. It really can't be done any simpler to the userspace, at least in Unix-like/Linux world. it also has interesting implications (regarding permissions) that this space is really too small and off-topic to contain. > And I am a total noob in this low level handling of Linux... > I will continue searching for your echo examples after I return home > again. > It's not as low-level as kernel, so don't worry ;) and yes the information is all over the place and incredibly scattered. But that's the 'feature' with all the FOSS stuff, it's a myriad of independent projects. el es ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Jonas Maebe wrote: Bo Berglund wrote: I have asked about this on the Pi forum instead, but I fear noone (almost) over there use free-pascal so I have no high hopes. The point is that this question is completely unrelated to Pascal or Free Pascal. It's a basic Unix/Linux usage question, which is independent of the used programming language. If you ask how to access "GPIO pins on RPi2 without root" on a Linux/Raspberry forum, any answer you will get will equally apply to FPC as to any other language. You already have the Pascal code to access the pins from the wiki, per a previous post of yours, so you don't have to mention FPC/Pascal at all. You just mentioned that you don't like to subscribe to mailing lists because you already receive many mails. By posting mails on a list that are not really on topic, you make that exact same problem worse for other people that do prefer to use email rather than use a web or nntp interface. FWIW, I agree and I'd like to apologise for making things slightly worse. However I was doing my best to help somebody who obviously still had problems, even though I anticipated that he'd eventually put himself in the position where I had no choice but to stop. -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Fr, 2015-10-09 at 09:50 +0200, Bo Berglund wrote: > On Thu, 08 Oct 2015 22:01:49 +, Mark Morgan Lloyd > wrote: > >> I will try to locate an updated pigpio.pas file by asking in the > >> Lazarus forum instead. > > > >I would strongly suggest going through /sys/class/gpio first, since you > >can exercise it using echo and there are fewer things to get wrong. > > I have seen you mention "echo" a number of times and I have gone back > (in the Gmane gmane.comp.compilers.free-pascal.general news archive in > my newsreader) to locate the exact method for this but I failed. > And I am a total noob in this low level handling of Linux... > I will continue searching for your echo examples after I return home > again. A starting point for understanding and finding additional information about udev is there: https://en.wikipedia.org/wiki/Udev Another issue of interest would be basic user management. I suggest going to the documentation pages of the distro you use and reading some basic administration docs. Short pre-info: Each user on your RPi can be member of multiple groups. This is managed in the file /etc/group. Group membership is for giving rights regarding software and hardware access to users. E.g. by making a user a member of the group "dialer" (or similar) this user is allowed to use modems attached to the computer. Each file and directory has an owner and a set of flags for managing access allowance. Try "man chown" and "man chmod" on the pi's console window. And since hardware devices are made usable via device nodes, which are files in the /dev hierarchie, anything is a file in Linux/Unix and this rights management work for anything. To map hardware access rights to groups, udev is used. Udev is instructed to do this by rules. I assume RPi has those udev rules built in, because the special gpio hardware has to be managed somehow. -- Marc Santhoff ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Bo Berglund wrote: I have asked about this on the Pi forum instead, but I fear noone (almost) over there use free-pascal so I have no high hopes. The point is that this question is completely unrelated to Pascal or Free Pascal. It's a basic Unix/Linux usage question, which is independent of the used programming language. If you ask how to access "GPIO pins on RPi2 without root" on a Linux/Raspberry forum, any answer you will get will equally apply to FPC as to any other language. You already have the Pascal code to access the pins from the wiki, per a previous post of yours, so you don't have to mention FPC/Pascal at all. You just mentioned that you don't like to subscribe to mailing lists because you already receive many mails. By posting mails on a list that are not really on topic, you make that exact same problem worse for other people that do prefer to use email rather than use a web or nntp interface. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Thu, 08 Oct 2015 22:01:49 +, Mark Morgan Lloyd wrote: >> Sorry for causing a problem here... >> The lists you refer to are not present in the Gmane newsserver as a >> newsgroup so I cannot access it. > >I suggest setting up a direct subscription using the instructions given >at http://www.freepascal.org/maillist.var Things like Gmane are really >only useful as long-term archives. Well, I don't like to have my inbox receive the number of emails on a list like this. The new interface is a much better way in my view. I already receive 100+ emails every day so doubling this seems not to be a good way for me >> I will try to locate an updated pigpio.pas file by asking in the >> Lazarus forum instead. > >I would strongly suggest going through /sys/class/gpio first, since you >can exercise it using echo and there are fewer things to get wrong. I have seen you mention "echo" a number of times and I have gone back (in the Gmane gmane.comp.compilers.free-pascal.general news archive in my newsreader) to locate the exact method for this but I failed. And I am a total noob in this low level handling of Linux... I will continue searching for your echo examples after I return home again. -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Bo Berglund wrote: On Thu, 08 Oct 2015 19:48:54 +, Mark Morgan Lloyd wrote: Do not, under any circumstances, try to fiddle with the permission of those files/directories. Instead, add the gpio group to your normal user (as I have already said). Jonas has already asked us to discuss this elsewhere, i.e. either the fpc-other or lazarus-other mailing list, and I really do not want to upset the list managers by going into basic unix management or into things which are specific to managing the RPi. Having said that, by analogy if you want to drive one of the serial ports on a Linux system you usually end up adding the dialout group to your normal user ID. If you aren't prepared to discuss this in one of the more general MLs, then I suggest researching that and then extending what you learn to adding the gpio group to your normal user. Sorry for causing a problem here... The lists you refer to are not present in the Gmane newsserver as a newsgroup so I cannot access it. I suggest setting up a direct subscription using the instructions given at http://www.freepascal.org/maillist.var Things like Gmane are really only useful as long-term archives. I have asked about this on the Pi forum instead, but I fear noone (almost) over there use free-pascal so I have no high hopes. The user pi seems to be in the required group so I take it there is no need to sudo any execution of the program for user pi? pi@rpi2b-wheezy ~ $ groups pi pi : pi adm dialout cdrom sudo audio video plugdev games users netdev input spi i2c gpio Or add the gpio group to your normal userid. However the "right" way of doing this usually relies on a system-specific user management program (the "wrong" way, which most people use in practice, is to edit /etc/group and /etc/gshadow). I will try to locate an updated pigpio.pas file by asking in the Lazarus forum instead. I would strongly suggest going through /sys/class/gpio first, since you can exercise it using echo and there are fewer things to get wrong. -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Thu, 08 Oct 2015 19:48:54 +, Mark Morgan Lloyd wrote: >Do not, under any circumstances, try to fiddle with the permission of >those files/directories. Instead, add the gpio group to your normal user >(as I have already said). > >Jonas has already asked us to discuss this elsewhere, i.e. either the >fpc-other or lazarus-other mailing list, and I really do not want to >upset the list managers by going into basic unix management or into >things which are specific to managing the RPi. > >Having said that, by analogy if you want to drive one of the serial >ports on a Linux system you usually end up adding the dialout group to >your normal user ID. If you aren't prepared to discuss this in one of >the more general MLs, then I suggest researching that and then extending >what you learn to adding the gpio group to your normal user. Sorry for causing a problem here... The lists you refer to are not present in the Gmane newsserver as a newsgroup so I cannot access it. I have asked about this on the Pi forum instead, but I fear noone (almost) over there use free-pascal so I have no high hopes. The user pi seems to be in the required group so I take it there is no need to sudo any execution of the program for user pi? pi@rpi2b-wheezy ~ $ groups pi pi : pi adm dialout cdrom sudo audio video plugdev games users netdev input spi i2c gpio I will try to locate an updated pigpio.pas file by asking in the Lazarus forum instead. Bye! -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Bo Berglund wrote: On Thu, 08 Oct 2015 13:15:10 +, Mark Morgan Lloyd wrote: You access the GPIOs via the kernel's sysfs interface. The files are all under /sys/class/gpio. I'd be pretty amazed if your distro doesn't already have a udev rule to set a certain group for those files. You probably just have to add your user to that group. Yes, it's the gpio group. I worked through the first couple of steps as described on the Lazarus wiki page manually (i.e. using echo from the command line), so can confirm that it's broadly accurate as of Raspbian "Wheezy". Did you mean this page: http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#5._PiGpio_Low-level_native_pascal_unit_.28GPIO_control_instead_of_wiringPi_c_library.29 It contains a unit PiGpio for the Broadcom chip on the original Pi. Is this some the fpc wrapper that handles what has been described in this thread so an fpc program can actually read and write the GPIO pins? It seems easy enough to use were it not for the discussion here talking about modifying user permissions on Linux to make the program run... This is what I see in the gpio dir: root@rpi2b-wheezy:/sys/class/gpio# ls -la total 0 drwxrwx--- 2 root gpio0 Jan 1 1970 . drwxr-xr-x 44 root root0 Oct 8 20:38 .. -rwxrwx--- 1 root gpio 4096 Jan 1 1970 export lrwxrwxrwx 1 root gpio0 Jan 1 1970 gpiochip0 -> ./../devices/soc/3f20.gpio/gpio/gpiochip0 -rwxrwx--- 1 root gpio 4096 Jan 1 1970 unexport Do not, under any circumstances, try to fiddle with the permission of those files/directories. Instead, add the gpio group to your normal user (as I have already said). Jonas has already asked us to discuss this elsewhere, i.e. either the fpc-other or lazarus-other mailing list, and I really do not want to upset the list managers by going into basic unix management or into things which are specific to managing the RPi. Having said that, by analogy if you want to drive one of the serial ports on a Linux system you usually end up adding the dialout group to your normal user ID. If you aren't prepared to discuss this in one of the more general MLs, then I suggest researching that and then extending what you learn to adding the gpio group to your normal user. -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Thu, 08 Oct 2015 13:15:10 +, Mark Morgan Lloyd wrote: >> You access the GPIOs via the kernel's sysfs interface. The files are >> all under /sys/class/gpio. I'd be pretty amazed if your distro doesn't >> already have a udev rule to set a certain group for those files. You >> probably just have to add your user to that group. > >Yes, it's the gpio group. I worked through the first couple of steps as >described on the Lazarus wiki page manually (i.e. using echo from the >command line), so can confirm that it's broadly accurate as of Raspbian >"Wheezy". Did you mean this page: http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#5._PiGpio_Low-level_native_pascal_unit_.28GPIO_control_instead_of_wiringPi_c_library.29 It contains a unit PiGpio for the Broadcom chip on the original Pi. Is this some the fpc wrapper that handles what has been described in this thread so an fpc program can actually read and write the GPIO pins? It seems easy enough to use were it not for the discussion here talking about modifying user permissions on Linux to make the program run... This is what I see in the gpio dir: root@rpi2b-wheezy:/sys/class/gpio# ls -la total 0 drwxrwx--- 2 root gpio0 Jan 1 1970 . drwxr-xr-x 44 root root0 Oct 8 20:38 .. -rwxrwx--- 1 root gpio 4096 Jan 1 1970 export lrwxrwxrwx 1 root gpio0 Jan 1 1970 gpiochip0 -> ../../devices/soc/3f20.gpio/gpio/gpiochip0 -rwxrwx--- 1 root gpio 4096 Jan 1 1970 unexport -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Henry Vermaak wrote: On Wed, Oct 07, 2015 at 01:09:58PM +0200, Bo Berglund wrote: On Wed, 07 Oct 2015 10:05:03 +0200, Jonas Maebe wrote: Bo Berglund wrote on Wed, 07 Oct 2015: How can one control the GPIO outputs on a Raspberry Pi2 without needing the program to run as root? I am using Raspbian Wheezy and I need to add two relays controls to my program. This really has nothing to do with either FPC or Pascal programming in general. Please ask such questions on the fpc-other list in the future. I think that it really does because there must be some interface between the FPC system and the underlying operating system managing the hardware. You access the GPIOs via the kernel's sysfs interface. The files are all under /sys/class/gpio. I'd be pretty amazed if your distro doesn't already have a udev rule to set a certain group for those files. You probably just have to add your user to that group. Yes, it's the gpio group. I worked through the first couple of steps as described on the Lazarus wiki page manually (i.e. using echo from the command line), so can confirm that it's broadly accurate as of Raspbian "Wheezy". -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Wed, Oct 07, 2015 at 01:09:58PM +0200, Bo Berglund wrote: > On Wed, 07 Oct 2015 10:05:03 +0200, Jonas Maebe > wrote: > >Bo Berglund wrote on Wed, 07 Oct 2015: > > > >> How can one control the GPIO outputs on a Raspberry Pi2 without > >> needing the program to run as root? I am using Raspbian Wheezy and I > >> need to add two relays controls to my program. > > > >This really has nothing to do with either FPC or Pascal programming in > >general. Please ask such questions on the fpc-other list in the future. > > > I think that it really does because there must be some interface > between the FPC system and the underlying operating system managing > the hardware. You access the GPIOs via the kernel's sysfs interface. The files are all under /sys/class/gpio. I'd be pretty amazed if your distro doesn't already have a udev rule to set a certain group for those files. You probably just have to add your user to that group. Henry ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Wed, 7 Oct 2015, Mark Morgan Lloyd wrote: Jonas Maebe wrote: Bo Berglund wrote on Wed, 07 Oct 2015: I think that it really does because there must be some interface between the FPC system and the underlying operating system managing the hardware. On Linux/Unix, every interface to hardware gets exposed as a file (generally under /dev). Sometimes you have libraries that provide a higher level interface, but in the end it will always access that file. If you need root permissions to perform actions on this file with language X, you will also need them with language Y and also if you use library Z to access it. The file operations are basic POSIX operations (open, read, write, ioctl, close), which are available with an "fp" prefix via the baseunix and unix units, and which are the same in C or other languages. If you have a library that you want to use, then you can of course ask here whether anyone has translated the headers for it (which will probably be in C) to Pascal or so. I've just been taking a look and I don't immediately see a kernel module that provides an interface to GPIO via /dev. I think there's things for I2C etc. GPIO is managed via a mmap-ped file, which means the usual access mechanisms apply. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Jonas Maebe wrote: Bo Berglund wrote on Wed, 07 Oct 2015: I think that it really does because there must be some interface between the FPC system and the underlying operating system managing the hardware. On Linux/Unix, every interface to hardware gets exposed as a file (generally under /dev). Sometimes you have libraries that provide a higher level interface, but in the end it will always access that file. If you need root permissions to perform actions on this file with language X, you will also need them with language Y and also if you use library Z to access it. The file operations are basic POSIX operations (open, read, write, ioctl, close), which are available with an "fp" prefix via the baseunix and unix units, and which are the same in C or other languages. If you have a library that you want to use, then you can of course ask here whether anyone has translated the headers for it (which will probably be in C) to Pascal or so. I've just been taking a look and I don't immediately see a kernel module that provides an interface to GPIO via /dev. I think there's things for I2C etc. Via http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#1._Native_hardware_access I see mention of /sys/class/gpio etc. although I've not looked to see what's implemented as standard. Using this interface requires membership of the gpio group, which in principle answers Bo's question. -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Bo Berglund wrote on Wed, 07 Oct 2015: I think that it really does because there must be some interface between the FPC system and the underlying operating system managing the hardware. On Linux/Unix, every interface to hardware gets exposed as a file (generally under /dev). Sometimes you have libraries that provide a higher level interface, but in the end it will always access that file. If you need root permissions to perform actions on this file with language X, you will also need them with language Y and also if you use library Z to access it. The file operations are basic POSIX operations (open, read, write, ioctl, close), which are available with an "fp" prefix via the baseunix and unix units, and which are the same in C or other languages. If you have a library that you want to use, then you can of course ask here whether anyone has translated the headers for it (which will probably be in C) to Pascal or so. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On Wed, 07 Oct 2015 10:05:03 +0200, Jonas Maebe wrote: > >Bo Berglund wrote on Wed, 07 Oct 2015: > >> How can one control the GPIO outputs on a Raspberry Pi2 without >> needing the program to run as root? I am using Raspbian Wheezy and I >> need to add two relays controls to my program. > >This really has nothing to do with either FPC or Pascal programming in >general. Please ask such questions on the fpc-other list in the future. > I think that it really does because there must be some interface between the FPC system and the underlying operating system managing the hardware. It usually is, so therefore I chose between this newsgroup and the lazarus one for my question. On the Raspberry Pi forum they do not know about FPC in general so I got no response there. As example for Windows I needed to get some special plug-in to Delphi to be able to access the Windows hardware and that was delphi programming. Why should it be off-topic here? And this is the only fpc list I can find that is carried by Gmane News. -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
leledumbo wrote: How can one control the GPIO outputs on a Raspberry Pi2 without needing the program to run as root? sudo chown root sudo chmod 4755 The 4 is setuid bit, which will allow normal users to run the program but the program itself has root privilege. With the caveat that running setuid root is incompatible with at least some versions of GTL, it's necessary to use Qt instead. "The unix way" for this would be to have a driver that exposes the GPIO pins somewhere in /dev, with appropriate group ownership to which select users could be added. -- 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 - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
Bo Berglund wrote on Wed, 07 Oct 2015: How can one control the GPIO outputs on a Raspberry Pi2 without needing the program to run as root? I am using Raspbian Wheezy and I need to add two relays controls to my program. This really has nothing to do with either FPC or Pascal programming in general. Please ask such questions on the fpc-other list in the future. Thanks, Jonas FPC mailing lists admin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
On 07/10/15 08:02, Bo Berglund wrote: > How can one control the GPIO outputs on a Raspberry Pi2 without > needing the program to run as root? I am using Raspbian Wheezy and I > need to add two relays controls to my program. > The pages I have found with google are for the original Pi so the > connector referenced is the wrong size and it is also always mentioned > that the program must be run as root. > My program must be started every minute by cron so I don't know how > this will happen... > (Not so used to Linux) > > Do I need to install some driver in Raspbian to allow access to the > GPIO ports from FPC? > > Apart from running SUID Root, which is generally discouraged (there is lots of answers on why setuid root is bad) I'd probably search for some udev rules to make up - to chown the gpio devices in /dev to root:gpio, (for example) and your unprivileged user to be a member of group gpio; ( possibly https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=9667, but also worth checking out other https://www.google.com/search?q=raspberry+pi+udev+gpio+user&ie=utf-8&oe=utf-8 results.) el es ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access GPIO pins on RPi2 without root?
>How can one control the GPIO outputs on a Raspberry Pi2 without needing the program to run as root? sudo chown root sudo chmod 4755 The 4 is setuid bit, which will allow normal users to run the program but the program itself has root privilege. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Access-GPIO-pins-on-RPi2-without-root-tp5722809p5722810.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal