X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/fa5afb5e90e6fa672ce2b9af3c7b8cf7a58b34c6..03548b64a8d7b407b4ae6464c5ffc551be8fc0be:/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py diff --git a/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py b/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py index 19dc98f..caf0d62 100644 --- a/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py +++ b/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py @@ -1,9 +1,13 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT """Custom PulseIn Class to read PWM signals""" import time import subprocess import os import atexit import random +import struct import sysv_ipc DEBUG = False @@ -49,9 +53,15 @@ class PulseIn: "Message queue creation failed" ) from sysv_ipc.ExistentialError + # Check if OS is 64-bit + if struct.calcsize("P") * 8 == 64: # pylint: disable=no-member + libgpiod_filename = "libgpiod_pulsein64" + else: + libgpiod_filename = "libgpiod_pulsein" + dir_path = os.path.dirname(os.path.realpath(__file__)) cmd = [ - dir_path + "/libgpiod_pulsein", + dir_path + "/" + libgpiod_filename, "--pulses", str(maxlen), "--queue", @@ -64,7 +74,7 @@ class PulseIn: if DEBUG: print(cmd) - self._process = subprocess.Popen(cmd) + self._process = subprocess.Popen(cmd) # pylint: disable=consider-using-with procs.append(self._process) # wait for it to start up