Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* rust-embedded/embedded-linux
31 changes: 31 additions & 0 deletions .github/bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 1
status = [
"CI (stable, aarch64-unknown-linux-gnu)",
"CI (stable, arm-unknown-linux-gnueabi)",
"CI (stable, armv7-unknown-linux-gnueabihf)",
"CI (stable, i686-unknown-linux-gnu)",
"CI (stable, i686-unknown-linux-musl)",
"CI (stable, mips-unknown-linux-gnu)",
"CI (stable, mips64-unknown-linux-gnuabi64)",
"CI (stable, mips64el-unknown-linux-gnuabi64)",
"CI (stable, mipsel-unknown-linux-gnu)",
"CI (stable, powerpc-unknown-linux-gnu)",
"CI (stable, powerpc64le-unknown-linux-gnu)",
"CI (stable, s390x-unknown-linux-gnu)",
"CI (stable, x86_64-unknown-linux-gnu)",
"CI (stable, x86_64-unknown-linux-musl)",
"CI (stable, x86_64-apple-darwin)",

"CI (stable, --features=async-tokio, x86_64-unknown-linux-gnu)",
"CI (stable, --features=mio-evented, x86_64-unknown-linux-gnu)",

"CI (1.46.0, --features=async-tokio, x86_64-unknown-linux-gnu)",
"CI (1.46.0, --features=mio-evented, x86_64-unknown-linux-gnu)",
"CI (1.46.0, x86_64-unknown-linux-gnu)",
"CI (1.46.0, x86_64-apple-darwin)",

"checks"
]
timeout_sec = 7200
129 changes: 129 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: CI

env:
RUSTFLAGS: '--deny warnings'

jobs:
ci-linux:
name: CI
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable]
FEATURES: ["", "--features=async-tokio", "--features=mio-evented"]
TARGET:
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabi
- armv7-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- mips-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-gnu
- powerpc-unknown-linux-gnu
# - powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- s390x-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl

include:
# MSRV
- rust: 1.46.0
TARGET: x86_64-unknown-linux-gnu

# Test nightly but don't fail
- rust: nightly
TARGET: x86_64-unknown-linux-gnu
experimental: true

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.TARGET }}
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --target=${{ matrix.TARGET }} ${{ matrix.FEATURES }}

- name: Test
uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target=${{ matrix.TARGET }} ${{ matrix.FEATURES }}

ci-macos:
name: CI-macOS
runs-on: macos-11

strategy:
matrix:
rust: [stable, 1.46.0]
TARGET: [x86_64-apple-darwin]

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.TARGET }}
override: true

- uses: actions-rs/cargo@v1
with:
command: build
args: --target=${{ matrix.TARGET }}

checks:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt

- name: Doc
uses: actions-rs/cargo@v1
with:
command: doc

- name: Formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
runs-on: ubuntu-latest
env:
RUSTFLAGS: '--allow warnings'
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.46.0
components: clippy

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### Changed

- Migrated to 'tokio' crate.
- Minimmum supported Rust version updated to 1.31
- [breaking-change] Renamed `use_tokio` feature `async-tokio`.
- Migrated to 'tokio' crate.
- Updated `nix` to version 0.22.
- Minimmum supported Rust version updated to 1.46.0.

## [0.5.3] - 2018-04-19

Expand Down
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[package]
name = "sysfs_gpio"
version = "0.5.4"
authors = ["Paul Osborne <[email protected]>"]
authors = [
"Paul Osborne <[email protected]>",
"The Embedded Linux Team <[email protected]>",
]
license = "MIT/Apache-2.0"
repository = "https://github.com/rust-embedded/rust-sysfs-gpio"
homepage = "https://github.com/rust-embedded/rust-sysfs-gpio"
documentation = "http://rust-embedded.github.io/rust-sysfs-gpio/"
documentation = "https://docs.rs/sysfs_gpio/"
description = "Provides access to GPIOs using the Linux sysfs interface."
readme = "README.md"

[features]
mio-evented = ["mio"]
use_tokio = ["futures", "tokio", "mio-evented"]
async-tokio = ["futures", "tokio", "mio-evented"]

[dependencies]
futures = { version = "0.1", optional = true }
nix = "0.14.0"
nix = "0.22"
mio = { version = "0.6", optional = true }
tokio = { version = "0.1", optional = true }
1 change: 1 addition & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2015 Paul Osborne
Copyright (c) 2021 The Rust Embedded Linux Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ The following features are planned for the library:
- [x] Support for configuring interrupts on GPIO
- [x] Support for polling on GPIO with configured interrupt
- [x] Support for asynchronous polling using `mio` or `tokio` (requires
enabling the `mio-evented` or `use_tokio` crate features, respectively)
enabling the `mio-evented` or `async-tokio` crate features, respectively)

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.31 and up. It *might*
This crate is guaranteed to compile on stable Rust 1.46.0 and up. It *might*
compile with older versions but that may change in any new patch release.

## Cross Compiling
Expand Down
18 changes: 9 additions & 9 deletions examples/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
extern crate futures;
#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
extern crate sysfs_gpio;
#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
extern crate tokio;

#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
use std::env;

#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
use futures::{lazy, Future, Stream};

#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
use sysfs_gpio::{Direction, Edge, Pin};

#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
fn stream(pin_nums: Vec<u64>) -> sysfs_gpio::Result<()> {
// NOTE: this currently runs forever and as such if
// the app is stopped (Ctrl-C), no cleanup will happen
Expand Down Expand Up @@ -44,7 +44,7 @@ fn stream(pin_nums: Vec<u64>) -> sysfs_gpio::Result<()> {
Ok(())
}

#[cfg(feature = "use_tokio")]
#[cfg(feature = "async-tokio")]
fn main() {
let pins: Vec<u64> = env::args()
.skip(1)
Expand All @@ -57,7 +57,7 @@ fn main() {
}
}

#[cfg(not(feature = "use_tokio"))]
#[cfg(not(feature = "async-tokio"))]
fn main() {
println!("This example requires the `tokio` feature to be enabled.");
}
14 changes: 1 addition & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ pub enum Error {
}

impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::Io(ref e) => e.description(),
Error::Unexpected(_) => "An Unexpected Error Occurred",
Error::InvalidPath(_) => "A Provided Path was invalid",
Error::Unsupported(_) => "Operation is not supported on target os",
}
}

fn cause(&self) -> Option<&dyn std::error::Error> {
match *self {
Error::Io(ref e) => Some(e),
Expand Down Expand Up @@ -53,9 +44,6 @@ impl convert::From<io::Error> for Error {
#[cfg(not(target_os = "wasi"))]
impl convert::From<nix::Error> for Error {
fn from(e: nix::Error) -> Error {
match e {
nix::Error::Sys(errno) => Error::Io(errno.into()),
other => Error::Unexpected(format!("{:?}", other)), // should just be dealing with errno case
}
Error::Io(e.into())
}
}
Loading