Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install on Armbian_22.11.0-trunk_Bananapim2zero_bullseye_edge_6.0.9 ends with an error #21

Open
evandene opened this issue Feb 7, 2023 · 6 comments

Comments

@evandene
Copy link

evandene commented Feb 7, 2023

Dear support team,
Is there a method to make this GPIO install works on Armbian_22.11.0-trunk_Bananapim2zero_bullseye_edge_6.0.9

sudo python setup.py install resuls in an error.

/RPi.GPIO_BP/source/event_gpio.c:58: first defined here
collect2: error: ld returned 1 exit status
error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1

Thanks in advance for helping me out

@vssir
Copy link

vssir commented Feb 8, 2023

See if this package can solve your problem
https://pypi.org/project/gpio4/

@evandene
Copy link
Author

evandene commented Feb 8, 2023

Banana Pi M2 Zero:
Firmware Armbian 22.11.0-trunk Bullseye

Installation:
pi@clearview:~$ sudo pip install gpio4
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
Collecting gpio4
Using cached gpio4-0.1.4-py3-none-any.whl (12 kB)
Installing collected packages: gpio4
Successfully installed gpio4-0.1.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Running a python script:
pi@clearview:~$ sudo python3 motion_on_off2a.py
Traceback (most recent call last):
File "/home/pi/motion_on_off2a.py", line 2, in
import gpio4.GPIO as GPIO
ModuleNotFoundError: No module named 'gpio4.GPIO'

Also
gpio readall doesn't show anything

@vssir
Copy link

vssir commented Feb 8, 2023

I won't make any mistakes. Try it
import gpio4 GPIO = gpio4.GPIO() GPIO.setmode(GPIO.BCM)

@evandene
Copy link
Author

evandene commented Feb 8, 2023

Thanks, now I need to learn how to write a decent script with gpio4. :-)
The below script doesn't work out of my RPI box. Are there somewhere samples I can look at?

import RPi.GPIO as GPIO
import time
import subprocess
import pycurl
import requests
from subprocess import call
from time import sleep

#Set warnings off (optional)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)

#Set Button pins
Buttonrec = 22
Buttonpic = 24

def buttonrec_callback(channel):
print("Buttonrec was pushed!")

def buttonpic_callback(channel):
print("Buttonpic was pushed!")

#Setup Buttonrec and Buttonpic

Set pin 22 to be an input pin and set initial value to be pulled low (off)

Set pin 24 to be an input pin and set initial value to be pulled low (off)

GPIO.setup(Buttonrec, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(Buttonpic, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

#as long as button 22 is pressed a video is recorded and stored according Motioneye settings
while True:
button_state = GPIO.input(Buttonrec)
print(button_state)
if button_state == 0:
subprocess.call(['/etc/motioneye/light_on_1'], shell=False)
else:
subprocess.call(['/etc/motioneye/light_off_1'], shell=True)

#When button 24 is pressed a picture is taken and stored according Motioneye settings
button_state = GPIO.input(Buttonpic)
print(button_state)
if button_state == 0:

    url = 'http://localhost:7999/1/action/snapshot'
    response = requests.get(url)

    with open('/home/pi/clearview/image.jpg', 'wb') as f:
        f.write(response.content)

sleep(1)

GPIO.cleanup() # Clean up

@vssir
Copy link

vssir commented Feb 10, 2023

None of the above should apply, check out the link below, I tested it on bananapi pro.
https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library
`
from pyGPIO.gpio import gpio, connector

gpio.init()
gpio.setcfg(connector.GPIOp35, 1)
gpio.output(connector.GPIOp35, True)
`
image

@wgebis
Copy link

wgebis commented Oct 26, 2023

Hi there, PRs: #22 (banana-pi) and #23 (banana-pro) allow to compile under newer gcc environments. Adding flag -fcommon solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants