Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4845

Beginners • Suitable GPIO library for Buster?

$
0
0
I am constrained to using Buster on a RPi3B because of other software that is installed on it. A friend is helping me with programming and he has a file running fine on a RPi3 but with an up to date OS. Here is the file:

Code:

import timeimport sysimport selectfrom gpiozero import Buttondef sendCurl(post_data):    import os    cmd = 'curl -s -d \''+str(post_data)+'\' http://192.168.0.106:1025'    print(cmd)    os.system(cmd)cmdstart1234 = {"command": "sendCameraCommand","cameras": ["GoPro 1234"],"cameraCommand": "startRecording"}cmdstop_1234 = {"command": "sendCameraCommand","cameras": ["GoPro 1234"],"cameraCommand": "stopRecording"}cmdstart2281 = {"command": "sendCameraCommand","cameras": ["GoPro 2281"],"cameraCommand": "startRecording"}cmdstop_2281 = {"command": "sendCameraCommand","cameras": ["GoPro 2281"],"cameraCommand": "stopRecording"}cmdstart9464 = {"command": "sendCameraCommand","cameras": ["GoPro 9464"],"cameraCommand": "startRecording"}cmdstop_9464 = {"command": "sendCameraCommand","cameras": ["GoPro 9464"],"cameraCommand": "stopRecording"}# GPIO     Position        Phase 1# 2         Top Left       Start Left# 3         Top Middle     Start Front# 4         Top Right      Start Right# 9         Bottom Left    Stop Left# 10        Bottom Middle  Stop Front# 11        Bottom Right   Stop Rightclass Camera:        def  __init__(self,startPin,stopPin, aName, aStartCmd, aStopCmd):        self.startButton = Button(startPin)        self.stopButton  = Button(stopPin)        self.name = aName        self.startCmd = aStartCmd        self.stopCmd  = aStopCmd        self.startButton.when_pressed = self.start        self.stopButton.when_pressed = self.stop        self.running = False    def start(self):        self.running = True        sendCurl(self.startCmd)    def stop(self):        self.running = False        sendCurl(self.stopCmd)cam1 = Camera( 2, 9,"Camera 1",cmdstart1234,cmdstop_1234)cam2 = Camera( 3,10,"Camera 2",cmdstart2281,cmdstop_2281)cam3 = Camera( 4,11,"Camera 3",cmdstart9464,cmdstop_9464)  def actOnKeyb():    while sys.stdin in select.select([sys.stdin], [], [], 0)[0]:      line = sys.stdin.readline()      if line[0] == "q":          print("Quit")          exit(0)      if len(line) > 2:          camNo   = line[0]          state = line[1]          if camNo in ["1", "2","3"]:              cam = cam1              if camNo == "2":                  cam = cam2              if camNo == "3":                  cam = cam3              if state == "1":                  cam.start()              else:                  cam.stop()while True:    actOnKeyb()
For him it runs fine, but when I run it on Buster, this is the result:

Code:

  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 124, in __call__    self = super(GPIOMeta, cls).__call__(*args, **kwargs)  File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 432, in __init__    bounce_time=bounce_time, pin_factory=pin_factory)  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 383, in __init__    super(HoldMixin, self).__init__(*args, **kwargs)  File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 182, in __init__    pin_factory=pin_factory)  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 197, in __init__    super(EventsMixin, self).__init__(*args, **kwargs)  File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 98, in __init__    super(InputDevice, self).__init__(pin, pin_factory=pin_factory)  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 521, in __init__    pin = self.pin_factory.pin(pin)  File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 111, in pin    pin = self.pin_class(self, n)  File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 132, in __init__    GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
After googling a bit, I get the impression that gpiozero is not compatible with Buster.

All comments would be appreciated

Statistics: Posted by Gerald_D — Wed Apr 24, 2024 5:30 am



Viewing all articles
Browse latest Browse all 4845

Trending Articles