rfid-silion-compat
Async Rust reader library for Silion RFID reader protocol communication.
This crate provides:
- A high-level reader API (
SilionReader) for common reader operations - Async inventory session support
- Optional native serial transport (
tokio-serial) - Optional browser Web Serial + wasm-bindgen JS bindings
- Supporting low-level protocol modules (
command,parsers,frame) for advanced use
The protocol implementation follows Silion reader protocol docs: https://en.silion.com.cn/En/doc_center/ModuleAPI_Docs/Communication_Protocol_Doc/html/Protocol_Introduction.html
Crate Features
serial: enables native serial transport viatokio-serialweb-serial: enables wasm/browser support and JS bindings (forwasm32targets)
Default features are empty.
Requirements
Core Rust development:
- Rust toolchain (stable)
For browser/wasm workflows:
wasm-pack- Node.js + npm
Install wasm-pack:
Install
Add to your project:
Enable native serial support when needed:
Or directly in Cargo.toml:
[]
= { = "*", = ["serial"] }
= { = "1", = ["macros", "rt-multi-thread"] }
Quick Start
Build protocol packets
High-level reader API with mock transport
Native serial reader example
Minimal Rust API usage
use SerialTransport;
use SilionReader;
async
Build with the serial feature enabled.
For API-oriented documentation, see crate-level rustdoc in src/lib.rs and module docs in src/silion_reader.rs, src/command.rs, src/parsers.rs, and src/frame.rs.
Browser and Web Serial
A browser demo is available in examples/web/README.md.
Build browser output directly:
Then serve:
Open http://localhost:8080 in a browser with Web Serial support.
Build npm Package from wasm
Use the helper script:
What it does:
- Reads version from Cargo.toml
- Runs
wasm-pack build --target bundler --release -- --features web-serial - Updates
pkg/package.jsonto match Cargo version
Publish package:
NPM Package (JavaScript/TypeScript)
This repository also ships an npm package for browser-based JS/TS usage:
- Package name:
rfid-silion-compat - npm-focused docs: npm/README.md
Validate Locally
Contributing and Governance
- Contributing guide: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security policy: SECURITY.md
- Changelog: CHANGELOG.md
License
Licensed under either of:
- MIT (LICENSE-MIT)
- Apache-2.0 (LICENSE-APACHE)
Project Layout
- src/lib.rs: exports and crate-level docs
- src/silion_reader.rs: high-level async reader API
- src/client.rs: transport-level async client
- src/session.rs: async inventory session API
- src/serial.rs: native serial transport (
serialfeature) - src/web_serial.rs: browser Web Serial transport (
web-serial+ wasm32) - src/web_bindings.rs: wasm-bindgen JS bindings
- examples/: runnable examples