RPi.GPIO

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

Not sure if this should go here or in Embedded...

I'm trying to build an RPi.GPIO module for FreeBSD to allow Python programs to easily interact with GPIO on a Raspberry Pi. Apparently under Raspian it is as easy as running
pip3 install RPi.GPIO

Here is what I got on FreeBSD on a RPi2:-
Code:
RPi.GPIO
  Using cached RPi.GPIO-0.6.3.tar.gz
Installing collected packages: RPi.GPIO
  Running setup.py install for RPi.GPIO ... [?25l- \ | / error
    Complete output from command /usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ax9qhiic/RPi.GPIO/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ah575x8n-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.freebsd-11.1-RELEASE-arm-3.6
    creating build/lib.freebsd-11.1-RELEASE-arm-3.6/RPi
    copying RPi/__init__.py -> build/lib.freebsd-11.1-RELEASE-arm-3.6/RPi
    creating build/lib.freebsd-11.1-RELEASE-arm-3.6/RPi/GPIO
    copying RPi/GPIO/__init__.py -> build/lib.freebsd-11.1-RELEASE-arm-3.6/RPi/GPIO
    running build_ext
    building 'RPi._GPIO' extension
    creating build/temp.freebsd-11.1-RELEASE-arm-3.6
    creating build/temp.freebsd-11.1-RELEASE-arm-3.6/source
    /usr/bin/cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fno-strict-aliasing -fPIC -I/usr/local/include/python3.6m -c source/py_gpio.c -o build/temp.freebsd-11.1-RELEASE-arm-3.6/source/py_gpio.o
    source/py_gpio.c:87:4: error: function definition is not allowed here
       {
       ^
    source/py_gpio.c:143:10: warning: implicit declaration of function 'cleanup_one' is invalid in C99 [-Wimplicit-function-declaration]
             cleanup_one();
             ^
    source/py_gpio.c:200:24: error: function definition is not allowed here
       int setup_one(void) {
                           ^
    source/py_gpio.c:293:13: warning: implicit declaration of function 'setup_one' is invalid in C99 [-Wimplicit-function-declaration]
           if (!setup_one())
                ^
    source/py_gpio.c:345:21: error: function definition is not allowed here
       int output(void) {
                        ^
    source/py_gpio.c:419:18: error: called object type 'PyObject *' (aka 'struct _object *') is not a function or function pointer
          if (!output())
               ~~~~~~^
    source/py_gpio.c:475:18: error: called object type 'PyObject *' (aka 'struct _object *') is not a function or function pointer
          if (!output())
               ~~~~~~^
    source/py_gpio.c:581:32: warning: comparison of integers of different signs: 'const int' and 'unsigned int' [-Wsign-compare]
          if (*(*pin_to_gpio+chan) == gpio)
              ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
    3 warnings and 5 errors generated.
    error: command '/usr/bin/cc' failed with exit status 1
   
    ----------------------------------------
[31mCommand "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ax9qhiic/RPi.GPIO/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ah575x8n-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ax9qhiic/RPi.GPIO/[0m
[?25hroot@rpi2:~

Any ideas as to what is missing here?
 

aragats

Daemon

Reaction score: 689
Messages: 1,603

I believe we already discussed this project here. It relies on /proc and /sys virtual filesystems which don't exist in FreeBSD.
You can easily get rid of /proc dependency though by rewriting the corresponding part.
Actually it's strange that they use /dev/mem and still need /sys/class/gpio.
 
OP
B

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

I believe we already discussed this project here. It relies on /proc and /sys virtual filesystems which don't exist in FreeBSD.
You can easily get rid of /proc dependency though by rewriting the corresponding part.
Actually it's strange that they use /dev/mem and still need /sys/class/gpio.

I realise that this topic was discussed elsewhere but I was trying to figure out what the python errors were related to....

I think it's important to have an RPi.GPIO module for FreeBSD as it would make more GPIO python apps available on FreeBSD, but I don't think building such a module is something I'm capable of, so I hoped that pip3 install RPi.GPIO
might just do the trick....
 

aragats

Daemon

Reaction score: 689
Messages: 1,603

I think it's important to have an RPi.GPIO module for FreeBSD as it would make more GPIO python apps available on FreeBSD
A agree, it would be great to have such a module, but the backend has to be reworked. My point is why spending time on something which will not serve in it's current state since relies on Linux backend...
 
OP
B

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

I'm not technical enough to know what reworking needs to be done, but would gladly spend time testing any possible solution and providing feedback.

A Google search for 'freebsd rpi gpio' shows that there is plenty of expertise in accessing GPIO on RPi under FreeBSD so there must be someone capable of creating a python RPi.GPIO module...
 

gfx

Member

Reaction score: 7
Messages: 27

Have you tried Python bindings for FreeBSD libgpio in this github repo ?
https://github.com/evadot/fbsd_gpio_py

But first -- depending on the Python version that you use -- you should install one of the cffi packages below:
Code:
pkg install py27-cffi-1.7.0
Code:
pkg install py36-cffi-1.7.0
 
Top