{"id":15743479,"url":"https://github.com/warthog618/go-gpiosim","last_synced_at":"2026-03-07T03:03:44.249Z","repository":{"id":168603180,"uuid":"643975852","full_name":"warthog618/go-gpiosim","owner":"warthog618","description":"A Go library for creating and controlling GPIO simulators for testing users of the Linux GPIO uAPI. ","archived":false,"fork":false,"pushed_at":"2025-01-25T08:43:45.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T07:13:34.368Z","etag":null,"topics":["gpio","linux","mocking","simulator","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/warthog618.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-22T14:42:46.000Z","updated_at":"2025-01-25T08:43:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dc4d648-1404-4570-9c7d-ab42e50a79d0","html_url":"https://github.com/warthog618/go-gpiosim","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"bbe4b676f5fa03223b5f9e2f0ffbc228529950f4"},"previous_names":["warthog618/go-gpiosim"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/warthog618/go-gpiosim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgo-gpiosim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgo-gpiosim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgo-gpiosim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgo-gpiosim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/warthog618","download_url":"https://codeload.github.com/warthog618/go-gpiosim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgo-gpiosim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30206341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"online","status_checked_at":"2026-03-07T02:00:06.765Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","linux","mocking","simulator","testing-tools"],"created_at":"2024-10-04T03:04:22.936Z","updated_at":"2026-03-07T03:03:44.227Z","avatar_url":"https://github.com/warthog618.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2023 Kent Gibson \u003cwarthog618@gmail.com\u003e\n\nSPDX-License-Identifier: CC0-1.0\n--\u003e\n# gpiosim\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/warthog618/go-gpiosim/go.yml?logo=github\u0026branch=master)](https://github.com/warthog618/go-gpiosim/actions/workflows/go.yml)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/warthog618/go-gpiosim)](https://pkg.go.dev/github.com/warthog618/go-gpiosim)\n[![Go Report Card](https://goreportcard.com/badge/github.com/warthog618/go-gpiosim)](https://goreportcard.com/report/github.com/warthog618/go-gpiosim)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/warthog618/go-gpiosim/blob/master/LICENSE)\n\nA Go library for creating and controlling GPIO simulators for testing users of\nthe Linux GPIO uAPI (both v1 and v2).\n\nThe simulators are provided by the Linux [**gpio-sim**](https://www.kernel.org/doc/html/latest/admin-guide/gpio/gpio-sim.html) kernel module and so require a\nrecent kernel (5.19 or later) built with **CONFIG_GPIO_SIM**.\n\nSimulators contain one or more **Chip**s, each with a collection of lines being\nsimulated. Configuring a simulator involves adding **Bank**s, eash representing a\nchip, to **NewSim**, which will construct the corresponding simulator using\n**gpio-sim** and take it live.\n\nOnce live, the **Chip** exposes lines which may be manipulated to drive the\nGPIO uAPI from the kernel side.\nFor input lines, applying a pull using **Chip** pull methods controls the level\nof the simulated line.  For output lines, the **Chip.Level** method returns\nthe level the simulated line is being driven to by userspace.\n\nFor tests that only require vanilla lines on a single chip, the **Simpleton**\nprovides a slightly simpler interface.\n\nClosing the **Sim** deconstructs the simulator, removing the **gpio-sim**\nconfiguration and the corresponding gpiochips.\n\nConfiguring a simulator involves *configfs*, and manipulating the chips once live\ninvolves *sysfs*, so root permissions are typically required to run a simulator.\n\n## Example Usage\n\nCreating a simulator with two chips, with 8 and 42 lines respectively, each with\nseveral named lines and some hogged lines:\n\n```go\ns, err := gpiosim.NewSim(\n\tgpiosim.WithName(\"gpiosim_test\"),\n\tgpiosim.WithBank(gpiosim.NewBank(\"left\", 8,\n\t\tgpiosim.WithNamedLine(3, \"LED0\"),\n\t\tgpiosim.WithNamedLine(5, \"BUTTON1\"),\n\t\tgpiosim.WithHoggedLine(2, \"piggy\", gpiosim.HogDirectionOutputLow),\n\t)),\n\tgpiosim.WithBank(gpiosim.NewBank(\"right\", 42,\n\t\tgpiosim.WithNamedLine(3, \"BUTTON2\"),\n\t\tgpiosim.WithNamedLine(4, \"LED2\"),\n\t\tgpiosim.WithHoggedLine(7, \"hogster\", gpiosim.HogDirectionOutputHigh),\n\t\tgpiosim.WithHoggedLine(9, \"piggy\", gpiosim.HogDirectionInput),\n\t)),\n)\ndefer s.Close()\nc := \u0026sim.Chips[0]\nc.Pullup(5);\nlevel, err := c.Level(3);\n```\n\nUse a **Simpleton** to create a single chip simulator with 12 lines, for where multiple chips or\nnamed lines are not required:\n\n```go\ns, err := gpiosim.NewSimpleton(12)\ns.SetPull(5, 1)\nlevel, err := s.Level(3)\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](https://github.com/warthog618/go-gpiosim/blob/master/LICENSES/Apache-2.0.txt) or\n  \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](https://github.com/warthog618/go-gpiosim/blob/master/LICENSES/MIT.txt) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwarthog618%2Fgo-gpiosim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwarthog618%2Fgo-gpiosim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwarthog618%2Fgo-gpiosim/lists"}