https://github.com/lukaskirner/tokio-sunspec
A tokio-based SunSpec library
https://github.com/lukaskirner/tokio-sunspec
client library modbus non-blocking rust sunspec tokio
Last synced: about 1 year ago
JSON representation
A tokio-based SunSpec library
- Host: GitHub
- URL: https://github.com/lukaskirner/tokio-sunspec
- Owner: lukaskirner
- License: apache-2.0
- Created: 2022-12-28T20:38:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-22T14:31:23.000Z (about 3 years ago)
- Last Synced: 2025-03-12T15:51:26.533Z (over 1 year ago)
- Topics: client, library, modbus, non-blocking, rust, sunspec, tokio
- Language: Rust
- Homepage:
- Size: 65.4 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tokio-sunspec
A pure [Rust](https://www.rust-lang.org)
[SunSpec](https://en.wikipedia.org/wiki/SunSpec) library
based on [tokio](https://tokio.rs).
[](https://crates.io/crates/tokio-sunspec)
[](./LICENSE)
## Features
- [x] Pure Rust library
- [x] Non-blocking
- [x] TCP Client
- [x] RTU Client
- [x] Model discovery
- [x] Type safe SunSpec models
- [ ] Repeating models
## Installation
```toml
[dependencies]
tokio-sunspec = "*"
```
## Examples
The `src/models/` folder contains all pre generated models which may be available by the device. If you need to add your own model you can generate one with included Python script in the `scripts` folder.
### TCP Connect example for SMA Inverter
```rust
let socket_addr = ":502".parse().unwrap();
let device_id: u8 = 126;
let start_addr: u16 = 40000;
let mut client = tokio_sunspec::connect_tcp(socket_addr, device_id, start_addr).await?;
let res = client.read_point(model1::Mn).await?;
assert_eq!(res, "SMA");
```
## Protocol-Specification
- [SunSpec Information Model Specification (PDF)](https://sunspec.org/wp-content/uploads/2015/06/SunSpec-Information-Models-12041.pdf)
## Fruther notice
This lib only implements the SunSpec part. The connection via modbus is done by the [tokio-modbus](https://github.com/slowtec/tokio-modbus) lib.
## License
Copyright (c) 2023 Lukas Kirner
[Apache-2.0](LICENSE.md)