Skip to main content

No project description provided

Project description

license pypi language

python3-gpiod

It is a pure Python library and has no dependencies on other packages !!

Installation

python3 -m pip install -U --user pip gpiod

help command

>>> import gpiod
>>> help(gpiod)
>>> help(gpiod.chip)
>>> help(gpiod.line)
>>> help(gpiod.chip.open)

open(self, device, how:int=1)
    @brief Open a GPIO chip.

    @param device: String or int describing the GPIO chip.
    @param how:    Indicates how the chip should be opened.

    If the object already holds a reference to an open chip, it will be
    closed and the reference reset.

    Usage:
        chip.open("/dev/gpiochip0")
        chip.open(0, chip.OPEN_BY_NUMBER)

Test

python3 -m gpiod.test.blink <chip> <line offset>
python3 -m gpiod.test.bulk_blink <chip> <line offset1> [<line offset2> ...]
python3 -m gpiod.test.sequential_blink <chip> <line offset1> \
    [<line offset2> ...]
python3 -m gpiod.test.button <chip> <line offset> [rising|falling|both]
python3 -m gpiod.test.bulk_button <chip> <line offset> [<line offset2> ...]
    <[rising|falling|both]>

Blink example

Python3

import gpiod
import sys
import time

if len(sys.argv) > 2:
    LED_CHIP = sys.argv[1]
    LED_LINE_OFFSET = int(sys.argv[2])
else:
    print('''Usage:
    python3 blink.py <chip> <line offset>''')
    sys.exit()

chip = gpiod.chip(LED_CHIP)
led = chip.get_line(LED_LINE_OFFSET)

config = gpiod.line_request()
config.consumer = "Blink"
config.request_type = gpiod.line_request.DIRECTION_OUTPUT

led.request(config)

print(led.consumer)

while True:
    led.set_value(0)
    time.sleep(0.1)
    led.set_value(1)
    time.sleep(0.1)

C++

#include <chrono>
#include <cstdlib>
#include <gpiod.hpp>
#include <iostream>
#include <string>
#include <thread>

int main(int argc, char **argv) {
    std::string LED_CHIP;
    int         LED_LINE_OFFSET;

    if(argc > 2) {
        LED_CHIP        = argv[1];
        LED_LINE_OFFSET = std::stoi(argv[2]);
    } else {
        std::cout << "Usage:" << std::endl
                  << "    ./blink <chip> <line offset>" << std::endl;
        std::exit(0);
    }

    gpiod::chip chip(LED_CHIP);
    gpiod::line led = chip.get_line(LED_LINE_OFFSET);

    gpiod::line_request config;
    config.consumer     = "Blink";
    config.request_type = gpiod::line_request::DIRECTION_OUTPUT;

    led.request(config);

    std::cout << led.consumer() << std::endl;

    while(1) {
        led.set_value(0);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        led.set_value(1);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
    }
}
g++ -o blink test.cpp -lgpiodcxx

Changelog

Ref: CHANGELOG

python3-gpiod (1.2.3) unstable; urgency=medium

  • github: fix pylint option
  • README: remove gpiod installation

-- Hyeonki Hong hhk7734@gmail.com Wed, 29 Apr 2020 17:25:39 +0900

python3-gpiod (1.2.2) unstable; urgency=medium

  • github: add python lint action
  • libgpiod: implement gpio.h and ioctl.h
  • Fix huge amount of functions to remove libgpiod dependency

-- Hyeonki Hong hhk7734@gmail.com Wed, 29 Apr 2020 17:00:49 +0900

python3-gpiod (1.2.1) unstable; urgency=medium

  • libgpiodcxx: document line class
  • pylint: create .pylintrc and run black
  • libgpiodcxx: fix issue using list as default argument
  • libgpiod: add gpiod_line_is_requested

-- Hyeonki Hong hhk7734@gmail.com Thu, 23 Apr 2020 14:48:10 +0900

python3-gpiod (1.2.0) unstable; urgency=medium

  • libgpiodcxx: document chip class
  • libgpiod: fix issue that fail to load libgpiod.so

-- Hyeonki Hong hhk7734@gmail.com Thu, 16 Apr 2020 21:05:58 +0900

python3-gpiod (1.1.2) unstable; urgency=medium

  • pypi: version up due to pypi version problem

-- Hyeonki Hong hhk7734@gmail.com Thu, 16 Apr 2020 20:55:27 +0900

python3-gpiod (1.1.1) unstable; urgency=medium

  • libgpiodcxx: fix issue where line_bulk.get_values does not return result

-- Hyeonki Hong hhk7734@gmail.com Thu, 16 Apr 2020 20:44:47 +0900

python3-gpiod (1.1.0) unstable; urgency=medium

  • libgpiod: API: start certain enums from 1

-- Hyeonki Hong hhk7734@gmail.com Wed, 15 Apr 2020 15:40:56 +0900

python3-gpiod (1.0.1) unstable; urgency=medium

  • libgpiodcxx: use gpiod_line_event_get_fd in line.event_get_fd

-- Hyeonki Hong hhk7734@gmail.com Wed, 15 Apr 2020 15:31:19 +0900

python3-gpiod (1.0.0) unstable; urgency=medium

  • libgpiod: call libgpiod.so using ctypes
  • libgpiodcxx: implement chip class
  • libgpiodcxx: implement line class
  • libgpiodcxx: implement line_bulk class
  • libgpiodcxx: implement line_event class
  • libgpiodcxx: implement line_request class

-- Hyeonki Hong hhk7734@gmail.com Wed, 15 Apr 2020 03:47:31 +0900

python3-gpiod (0.6.0) unstable; urgency=medium

  • Fix issue where 'setup.py clean' is not executed
  • Correct error messages to be noticeable
  • Fix iterator in line_bulk class

-- Hyeonki Hong hhk7734@gmail.com Thu, 02 Apr 2020 14:55:17 +0900

python3-gpiod (0.5.4) unstable; urgency=medium

  • Update README.md

-- Hyeonki Hong hhk7734@gmail.com Mon, 30 Mar 2020 20:04:10 +0900

python3-gpiod (0.5.3) unstable; urgency=medium

  • Add std::bitset<32> type caster

-- Hyeonki Hong hhk7734@gmail.com Thu, 26 Mar 2020 11:39:33 +0900

python3-gpiod (0.5.2) unstable; urgency=medium

  • Add documentation for tested methods
  • Add test code
  • Update README.md

-- Hyeonki Hong hhk7734@gmail.com Fri, 20 Mar 2020 13:17:41 +0900

python3-gpiod (0.5.1) unstable; urgency=medium

  • Move xxx class into xxx_wrapper.h
  • Add blink test module

-- Hyeonki Hong hhk7734@gmail.com Fri, 20 Mar 2020 00:58:05 +0900

python3-gpiod (0.5.0) unstable; urgency=medium

  • Add pybind11/chrono.h for std::chrono
  • Prevent installation if libgpiodcxx v1.0 or lower
  • Add xxx_lines into chip class
  • Add operators
  • Add MAX_LINES attribute
  • Fix issue where 'setup.py sdist' is not executed

-- Hyeonki Hong hhk7734@gmail.com Sat, 14 Mar 2020 02:37:13 +0900

python3-gpiod (0.4.1) unstable; urgency=medium

  • Fix issue where pip does not install dependencies

-- Hyeonki Hong hhk7734@gmail.com Thu, 12 Mar 2020 19:11:24 +0900

python3-gpiod (0.4.0) unstable; urgency=medium

  • Add libgpiodcxx version check
  • Remove -std=c++11 option
  • Add line_bulk, chip_iter, line_iter classes

-- Hyeonki Hong hhk7734@gmail.com Thu, 12 Mar 2020 14:18:16 +0900

python3-gpiod (0.3.0) unstable; urgency=medium

  • Add open, reset function
  • Add LICENSE
  • Create README.md

-- Hyeonki Hong hhk7734@gmail.com Wed, 11 Mar 2020 18:58:14 +0900

python3-gpiod (0.2.0) unstable; urgency=medium

  • Add chip, line_request, line, line_event class

-- Hyeonki Hong hhk7734@gmail.com Wed, 11 Mar 2020 13:28:45 +0900

python3-gpiod (0.1.0) unstable; urgency=medium

  • Add initial setup files

-- Hyeonki Hong hhk7734@gmail.com Tue, 10 Mar 2020 15:40:13 +0900

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpiod-1.2.3.tar.gz (20.8 kB view details)

Uploaded Source

File details

Details for the file gpiod-1.2.3.tar.gz.

File metadata

  • Download URL: gpiod-1.2.3.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for gpiod-1.2.3.tar.gz
Algorithm Hash digest
SHA256 f9e8d6662fb0981f6b62804227949ffe349b5d4c97383b9f447710139ec482eb
MD5 06f3cd69609080cd48eb6fa04b37798d
BLAKE2b-256 0de347a67452ab7b7f0615f1192b1b5815a1e55fa694adf558061ecce7793b3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page