{"id":15743353,"url":"https://github.com/warthog618/gpiosim-rs","last_synced_at":"2025-03-13T09:32:59.366Z","repository":{"id":65377255,"uuid":"562360380","full_name":"warthog618/gpiosim-rs","owner":"warthog618","description":"A Rust library for creating and controlling GPIO simulators for testing users of the Linux GPIO uAPI.","archived":false,"fork":false,"pushed_at":"2025-01-25T07:02:48.000Z","size":136,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T19:51:39.277Z","etag":null,"topics":["gpio","linux","mocking","simulator","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":"LICENSES/Apache-2.0.txt","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}},"created_at":"2022-11-06T04:58:25.000Z","updated_at":"2025-01-25T07:02:52.000Z","dependencies_parsed_at":"2024-04-06T02:23:08.257Z","dependency_job_id":"8176ebf8-9831-4c1c-9e2f-aad391f61835","html_url":"https://github.com/warthog618/gpiosim-rs","commit_stats":{"total_commits":63,"total_committers":1,"mean_commits":63.0,"dds":0.0,"last_synced_commit":"3a6fd3b8686d1bd1d95d1929e85edf30ebbe3f48"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgpiosim-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgpiosim-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgpiosim-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/warthog618%2Fgpiosim-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/warthog618","download_url":"https://codeload.github.com/warthog618/gpiosim-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243377975,"owners_count":20281324,"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","linux","mocking","simulator","testing-tools"],"created_at":"2024-10-04T03:03:12.861Z","updated_at":"2025-03-13T09:32:59.026Z","avatar_url":"https://github.com/warthog618.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2022 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/gpiosim-rs/rust.yml?logo=github\u0026branch=master)](https://github.com/warthog618/gpiosim-rs/actions/workflows/rust.yml)\n[![github](https://img.shields.io/badge/github-warthog618/gpiosim--rs-8da0cb.svg?logo=github)](https://github.com/warthog618/gpiosim-rs)\n[![crate](https://img.shields.io/crates/v/gpiosim.svg?color=fc8d62\u0026logo=rust)](https://crates.io/crates/gpiosim)\n![LICENSE](https://img.shields.io/crates/l/gpiosim.svg)\n\nA Rust 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 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. A **Builder** is responsible for constructing the **Sim** and taking it live.\nConfiguring a simulator involves adding **Bank**s, representing the\nchip, to the builder.\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.get_level** method returns\nthe level the simulated line is being driven to by userspace.\n\nFor tests that only require lines on a single chip, the **Simpleton**\nprovides a slightly simpler interface.\n\nDropping 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 a hogged line:\n\n```rust\nuse gpiosim::{Bank, Direction, Level};\n\nlet sim = gpiosim::builder()\n    .with_name(\"some unique name\")\n    .with_bank(\n        Bank::new(8, \"left\")\n            .name(3, \"LED0\")\n            .name(5, \"BUTTON1\")\n            .hog(2, \"hogster\", Direction::OutputLow)\n        )\n    .with_bank(\n        Bank::new(42, \"right\")\n            .name(3, \"BUTTON2\")\n            .name(4, \"LED2\")\n            .hog(7, \"hogster\", Direction::OutputHigh),\n    )\n    .live()?;\n\nlet chips = sim.chips();\nlet c = \u0026chips[0];\nc.set_pull(5, Level::High);\nlet level = c.get_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```rust\nlet s = gpiosim::Simpleton::new(12);\ns.set_pull(5, Level::High);\nlet level = s.get_level(3)?;\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](https://github.com/warthog618/gpiosim-rs/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/gpiosim-rs/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%2Fgpiosim-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwarthog618%2Fgpiosim-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwarthog618%2Fgpiosim-rs/lists"}