From b229e560bcf167e431f6eecc0e49bd9dc435c449 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:36:37 +0100 Subject: [PATCH 1/9] Add changelog --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 CHANGELOG.md 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 From fc66d5feccf30258417bd18e766252111a4bdd6d Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:37:54 +0100 Subject: [PATCH 2/9] Add support for cargo-release --- release.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 release.toml 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 From 34d86264687fa6cf86245702f272f39c9918e802 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:40:44 +0100 Subject: [PATCH 3/9] Update copyright --- LICENSE-MIT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. - From 883dcac01f2af6cec0ab2bf937ab6252c377962a Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:41:07 +0100 Subject: [PATCH 4/9] Add crate metadata --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f5acdd1..b442292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] From b48ae69c404d43a708264f5b3f3db2267d7a9214 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:54:09 +0100 Subject: [PATCH 5/9] Fix clippy warnings --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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())) } } From 42466f936ed5b97de608dd25013e6ce97e5b0e71 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:54:23 +0100 Subject: [PATCH 6/9] Remove link --- README.md | 1 - 1 file changed, 1 deletion(-) 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) From 9525fcdaa64fd0cd63ef8a0cb5e05cfa6e6af645 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 6 Feb 2025 18:57:00 +0100 Subject: [PATCH 7/9] Update CI --- .github/workflows/ci.yml | 94 ++++++++++------------------------------ 1 file changed, 24 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee78978..389561e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,17 +19,17 @@ 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 @@ -44,19 +44,13 @@ jobs: 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 @@ -68,33 +62,14 @@ jobs: ci-linux-msrv: name: CI 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 @@ -106,54 +81,33 @@ jobs: TARGET: [x86_64-apple-darwin] 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 }} - - uses: actions-rs/cargo@v1 - with: - command: build - args: --target=${{ matrix.TARGET }} + - run: cargo build --target=${{ matrix.TARGET }} 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 From fc937c9c1db4eb4db8cb927fe3ea3405f0b99ec7 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Fri, 7 Feb 2025 12:00:35 +0100 Subject: [PATCH 8/9] Revert to last published version ahead of release --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b442292..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 " From 4a64050ae63384d298010976d48a8fd72523b5c0 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Fri, 7 Feb 2025 12:12:35 +0100 Subject: [PATCH 9/9] Simplify CI --- .github/workflows/ci.yml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 389561e..4036ca0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,9 +35,6 @@ jobs: - 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 @@ -60,7 +57,7 @@ jobs: args: --target=${{ matrix.TARGET }} ci-linux-msrv: - name: CI + name: CI-MSRV runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -72,22 +69,21 @@ jobs: - 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@v4 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} + - uses: dtolnay/rust-toolchain@stable + - run: cargo build - - run: cargo build --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