{"id":17088503,"url":"https://github.com/temoto/gpio-cdev-go","last_synced_at":"2025-04-12T22:06:02.675Z","repository":{"id":57499360,"uuid":"189804737","full_name":"temoto/gpio-cdev-go","owner":"temoto","description":"Linux 4.8+ GPIO interface (gpiochip char dev) for pure Go","archived":false,"fork":false,"pushed_at":"2023-01-07T12:04:20.000Z","size":63,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T22:05:57.030Z","etag":null,"topics":["gpio-library","hardware","linux","status-active"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/temoto.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-02T04:32:41.000Z","updated_at":"2024-11-12T03:13:52.000Z","dependencies_parsed_at":"2023-02-07T02:52:06.455Z","dependency_job_id":null,"html_url":"https://github.com/temoto/gpio-cdev-go","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/temoto%2Fgpio-cdev-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/temoto%2Fgpio-cdev-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/temoto%2Fgpio-cdev-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/temoto%2Fgpio-cdev-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/temoto","download_url":"https://codeload.github.com/temoto/gpio-cdev-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637769,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpio-library","hardware","linux","status-active"],"created_at":"2024-10-14T13:37:54.716Z","updated_at":"2025-04-12T22:06:02.656Z","avatar_url":"https://github.com/temoto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What\n\ngpio-cdev-go is pure Go library to access Linux 4.8+ GPIO chardev interface. [![GoDoc](https://godoc.org/github.com/temoto/gpio-cdev-go?status.svg)](https://godoc.org/github.com/temoto/gpio-cdev-go)\n\nTested on:\n- ARMv6,7 RaspberryPi 1, OrangePi Lite\n- ARM64 RaspberryPi 3 B+\n\nIf you know how to make this work useful for more people, please take a minute to communicate:\n- https://github.com/temoto/gpio-cdev-go/issues/new\n- temotor@gmail.com\n\nUltimate success would be to merge this functionality into periph.io lib.\n\n\n# Usage\n\nLow level, bare ioctl API is provided by set of `Raw*` functions.\n\nHigh-level wrapper (see api.go) is recommended way to use library.\n\n```\n// Open GPIO chip device.\n// Default consumer tag will be used if one is not provided to line management functions.\nchip, err := gpio.Open(\"/dev/gpiochip0\", \"default-consumer\")\ndefer chip.Close()\n\n// Set lines via either `SetBulk(values ...byte)`\n// or create setter closure with `SetFunc(line) -\u003e func(bool)`\n// Either way you should call `Flush()` to commit changes to hardware.\npins, err := chip.OpenLines(\n  gpio.GPIOHANDLE_REQUEST_OUTPUT, \"hd44780\",\n  nRS, nRW, nE, nD4, nD5, nD6, nD7,\n)\ndefer pins.Close()\n\npins.SetBulk(1, 0, 0, 1, 1, 1, 1)\nerr := pins.Flush()\n\nset_pin_d4 := pins.SetFunc(nD4)\nset_pin_d4(true)\nerr := pins.Flush()\n\n// Reading current lines state\npins, err := chip.OpenLines(gpio.GPIOHANDLE_REQUEST_INPUT, \"consumer\", uint32(line))\ndefer pins.Close()\ndata, err := pins.Read()\nlineActive := data.Values[0] == 1\n\n// Waiting for edge. REQUEST_INPUT flag is implied.\nlineEvent, err := chip.GetLineEvent(uint32(notifyLine), /*RequestFlag*/ 0,\n  gpio.GPIOEVENT_REQUEST_RISING_EDGE, \"consumer\")\ndefer lineEvent.Close()\ncurrentValue, err := lineEvent.Read()\neventData, err := lineEvent.Wait(timeout) // 0 to block forever\nok := eventData.ID == GPIOEVENT_EVENT_RISING_EDGE\n```\n\n\n# Possible issues\n\n- may leak `req.fd` descriptors, TODO test\n\n\n# Testing\n\n* get 2 free GPIO pins\n* jumper them\n* set environment variables and run tests\n```\nexport GPIO_TEST_DEV=\"/dev/gpiochip0\"\nexport GPIO_TEST_PIN=\"19\"\nexport GPIO_TEST_PIN_LOOP=\"16\"\ngo test ./...\n```\n\n\n# Flair\n\n[![Build status](https://travis-ci.org/temoto/gpio-cdev-go.svg?branch=master)](https://travis-ci.org/temoto/gpio-cdev-go)\n[![Coverage](https://codecov.io/gh/temoto/gpio-cdev-go/branch/master/graph/badge.svg)](https://codecov.io/gh/temoto/gpio-cdev-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/temoto/gpio-cdev-go)](https://goreportcard.com/report/github.com/temoto/gpio-cdev-go)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemoto%2Fgpio-cdev-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftemoto%2Fgpio-cdev-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemoto%2Fgpio-cdev-go/lists"}