Skip to content

Some basic updates #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
116 changes: 33 additions & 83 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).

<!-- next-header -->
## [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.

<!-- next-url -->
[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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysfs-pwm"
version = "0.2.0"
version = "0.1.0"
authors = [
"Rust Embedded WG Linux Team <embedded-linux@teams.rust-embedded.org>",
"Paul Osborne <osbpau@gmail.com>"
Expand All @@ -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]
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -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="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/rust-embedded/rust-sysfs-pwm/compare/{{tag_name}}...HEAD", exactly=1},
]
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn pwm_capture_parse<T: FromStr>(chip: &PwmChip, pin: u32, name: &str) -> Result

impl PwmChip {
pub fn new(number: u32) -> Result<PwmChip> {
fs::metadata(&format!("/sys/class/pwm/pwmchip{}", number))?;
fs::metadata(format!("/sys/class/pwm/pwmchip{}", number))?;
Ok(PwmChip { number })
}

Expand All @@ -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
))
Expand All @@ -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
))
Expand Down Expand Up @@ -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()))
}
}

Expand Down