{"id":16064672,"url":"https://github.com/eldruin/smbus-pec-rs","last_synced_at":"2025-03-18T05:30:47.703Z","repository":{"id":57667758,"uuid":"285873972","full_name":"eldruin/smbus-pec-rs","owner":"eldruin","description":"Rust Portable SMBus Packet Error Code Algorithm Implementation","archived":false,"fork":false,"pushed_at":"2021-05-23T21:13:51.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-16T05:28:21.314Z","etag":null,"topics":["algorithm","checksum","crc","crc8","embedded","i2c","rust","smbus","smbus-pec"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eldruin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-07T16:26:27.000Z","updated_at":"2023-04-11T19:08:21.000Z","dependencies_parsed_at":"2022-08-30T17:21:49.750Z","dependency_job_id":null,"html_url":"https://github.com/eldruin/smbus-pec-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fsmbus-pec-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fsmbus-pec-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fsmbus-pec-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fsmbus-pec-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eldruin","download_url":"https://codeload.github.com/eldruin/smbus-pec-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902819,"owners_count":20366358,"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":["algorithm","checksum","crc","crc8","embedded","i2c","rust","smbus","smbus-pec"],"created_at":"2024-10-09T05:09:04.995Z","updated_at":"2025-03-18T05:30:47.199Z","avatar_url":"https://github.com/eldruin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust Portable SMBus Packet Error Code Algorithm\n\n[![crates.io](https://img.shields.io/crates/v/smbus-pec.svg)](https://crates.io/crates/smbus-pec)\n[![Docs](https://docs.rs/smbus-pec/badge.svg)](https://docs.rs/smbus-pec)\n[![Build Status](https://github.com/eldruin/smbus-pec-rs/workflows/Build/badge.svg)](https://github.com/eldruin/smbus-pec-rs/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/eldruin/smbus-pec-rs/badge.svg?branch=master)](https://coveralls.io/github/eldruin/smbus-pec-rs?branch=master)\n\nThis is a portable minimal implementation of the [System Management Bus (SMBus)][smbus]\n[Packet Error Code][smbus-pec] calculation algorithm intended for use in `no_std`.\n\nSMBus 1.1 and later defines an optional Packet Error Checking mode. When used, an extra byte\nis appended to all transmissions containing a Packet Error Code (PEC).\n\nThe PEC is calculated over the whole transmission including address and read/write bit.\n\nThe polynomial used is `x^8 + x^2 + x + 1`, which corresponds to [CRC-8-ATM HEC][crc8]\ninitialized to zero.\n\n## How this crate compares to others\n\nThere is a number of crates implementing CRC algorithms but their intention is to\nbe configurable, generic, use acceleration via SIMD instructions, etc.\n\nThis crate provides a portable and non-configurable implementation of exactly one\nalgorithm: The one used for SMBus PEC (optionally using a pre-calculated lookup table).\n\nThis should allow the compiler to make good optimizations and allows for use of the\nalgorithm in any target architecture with minimal code bloat.\n\nThis makes this crate specially well suited for use in `no_std` environments.\n\n## Pre-calculated lookup table\n\nA faster version of the algorithm is provided through the use of a pre-calculated\nlookup table. This can be enabled through the `lookup-table` feature.\n\nWith this feature enabled a table of 256 pre-calculated `u8` values will be included\nwhich avoids bit-by-bit calculation at the cost of the space needed to store it.\n\n## Usage\n\n```rust\nuse smbus_pec::pec;\n\nconst ADDRESS: u8 = 0x5A;\nconst REGISTER: u8 = 0x06;\n\nfn main() {\n    let pec_write = pec(\u0026[ADDRESS \u003c\u003c 1, REGISTER, 0xAB, 0xCD]);\n    println!(\"PEC: {}\", pec_write); // prints 95\n\n    let data = [ADDRESS \u003c\u003c 1, REGISTER, (ADDRESS \u003c\u003c 1) + 1, 38, 58];\n    let pec_write_read = pec(\u0026data);\n    println!(\"PEC: {}\", pec_write_read); // prints 102\n}\n```\n\n## Support\n\nFor questions, issues, feature requests, other changes, or just feedback, please file an\n[issue in the github project](https://github.com/eldruin/smbus-pec-rs/issues).\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contributing\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\nbe dual licensed as above, without any additional terms or conditions.\n\n[crc8]: https://en.wikipedia.org/wiki/CRC-8\n[smbus]: https://en.wikipedia.org/wiki/System_Management_Bus\n[smbus-pec]: https://en.wikipedia.org/wiki/System_Management_Bus#Packet_Error_Checking\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fsmbus-pec-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feldruin%2Fsmbus-pec-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fsmbus-pec-rs/lists"}