[fpc-pascal] Access GPIO pins on RPi2 without root?

Michael Van Canneyt michael at freepascal.org
Wed Oct 7 14:47:50 CEST 2015



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.



More information about the fpc-pascal mailing list