diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee78978..4036ca0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,44 +19,35 @@ jobs: rust: [stable] TARGET: - aarch64-unknown-linux-gnu + - aarch64-unknown-linux-musl - arm-unknown-linux-gnueabi + - arm-unknown-linux-gnueabihf - 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 + # - loongarch64-unknown-linux-gnu - powerpc-unknown-linux-gnu # - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu - s390x-unknown-linux-gnu - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl include: - - rust: 1.28.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 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} - target: ${{ matrix.TARGET }} - override: true + target: ${{ matrix.target }} - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --target=${{ matrix.TARGET }} + - run: cargo build --target=${{ matrix.TARGET }} - name: Test uses: actions-rs/cargo@v1 @@ -66,94 +57,53 @@ jobs: args: --target=${{ matrix.TARGET }} ci-linux-msrv: - name: CI + name: CI-MSRV runs-on: ubuntu-latest - strategy: - matrix: - rust: [1.28.0] - TARGET: - - x86_64-unknown-linux-gnu - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: ${{ matrix.rust }} - target: ${{ matrix.TARGET }} - override: true + toolchain: 1.28.0 - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --target=${{ matrix.TARGET }} - - - name: Test - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: test - args: --target=${{ matrix.TARGET }} + - run: cargo build + - run: cargo test ci-macos: - name: CI - runs-on: macos-11 - - strategy: - matrix: - rust: [stable, 1.28.0] - TARGET: [x86_64-apple-darwin] + name: CI-macOS + runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build - - 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 }} + ci-macos-msrv: + name: CI-macOS-MSRV + runs-on: macos-13 # Latest for Intel-based CPUs + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.28.0 + - run: cargo build checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable 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 + - run: cargo doc + - run: cargo fmt --all -- --check clippy: runs-on: ubuntu-latest env: RUSTFLAGS: '--allow warnings' steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.84.1 with: - profile: minimal - toolchain: 1.62.0 components: clippy - - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + - run: cargo clippy --all-targets diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fd8a8ef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + + +## [Unreleased] - ReleaseDate + +### Added +- Add ability to read capture file descriptor #18 +- Add functions for polarity get/set #16 +- Add `get_duty_cycle` and `set_duty_cycle` methods #13 +- Add getter for checking state of `enable` + +### Fixed +- Fix addition of explicit `dyn` +- Handle errors in closure for function `with_exported` #14 + +### Removed +- Remove implementation of deprecated `Error::description` function + +## [0.1.0] - 2016-03-02 + +- Initial release. + + +[Unreleased]: https://github.com/rust-embedded/rust-sysfs-pwm/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/rust-embedded/rust-sysfs-pwm/releases/tag/v0.1.0 diff --git a/Cargo.toml b/Cargo.toml index f5acdd1..d2bfb25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sysfs-pwm" -version = "0.2.0" +version = "0.1.0" authors = [ "Rust Embedded WG Linux Team ", "Paul Osborne " @@ -17,5 +17,7 @@ which there is an appropriate driver loaded in the kernel. See https://www.kernel.org/doc/Documentation/pwm.txt """ readme = "README.md" +categories = ["embedded", "hardware-support"] +keywords = ["linux", "pwm"] [dependencies] diff --git a/LICENSE-MIT b/LICENSE-MIT index c70652f..c89e96f 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,5 +1,6 @@ The MIT License (MIT) +Copyright (c) 2025 Rust Embedded WG Linux Team Copyright (c) 2015 Paul Osborne Permission is hereby granted, free of charge, to any person obtaining a copy @@ -19,4 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index 74e089d..539ac7c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Build Status](https://github.com/rust-embedded/rust-sysfs-pwm/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-sysfs-pwm/actions) [![Version](https://img.shields.io/crates/v/sysfs-pwm.svg)](https://crates.io/crates/sysfs-pwm) ![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.28+-blue.svg) -[![License](https://img.shields.io/crates/l/sysfs-pwm.svg)](README.md#license) - [API Documentation](https://docs.rs/sysfs-pwm) diff --git a/release.toml b/release.toml new file mode 100644 index 0000000..135bb46 --- /dev/null +++ b/release.toml @@ -0,0 +1,7 @@ +pre-release-replacements = [ + {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, + {file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1}, + {file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1}, + {file="CHANGELOG.md", search="", replace="\n## [Unreleased] - ReleaseDate\n", exactly=1}, + {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-embedded/rust-sysfs-pwm/compare/{{tag_name}}...HEAD", exactly=1}, +] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7d4d477..8cfe204 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,7 +89,7 @@ fn pwm_capture_parse(chip: &PwmChip, pin: u32, name: &str) -> Result impl PwmChip { pub fn new(number: u32) -> Result { - fs::metadata(&format!("/sys/class/pwm/pwmchip{}", number))?; + fs::metadata(format!("/sys/class/pwm/pwmchip{}", number))?; Ok(PwmChip { number }) } @@ -109,7 +109,7 @@ impl PwmChip { pub fn export(&self, number: u32) -> Result<()> { // only export if not already exported - if fs::metadata(&format!( + if fs::metadata(format!( "/sys/class/pwm/pwmchip{}/pwm{}", self.number, number )) @@ -123,7 +123,7 @@ impl PwmChip { } pub fn unexport(&self, number: u32) -> Result<()> { - if fs::metadata(&format!( + if fs::metadata(format!( "/sys/class/pwm/pwmchip{}/pwm{}", self.number, number )) @@ -205,7 +205,7 @@ impl Pwm { if t.len() == 2 { Ok((t[0], t[1])) } else { - Err(error::Error::Unexpected(format!("Failed exporting"))) + Err(error::Error::Unexpected("Failed exporting".to_string())) } }