SunSpec Rust Implementation
This Rust crate contains code for accessing SunSpec compliant devices in a safe and convenient way.
Highlights
- Pure Rust library
- No unsafe code
- Panic free
- All communication is done via tokio-modbus without wrapping it in some kind of abstraction layer.
- Supports Modbus TCP and RTU (via
tokio-modbus
). - Implements "Device Information Model Discovery" as defined in the SunSpec specification.
- Fully typed models generated from the JSON files contained in the SunSpec models repository
- Fully typed enums
- Fully typed bitfields
- Fully documented. Even the generated models.
- Reading of complete models in a single request.
Nested and repeating groups are not supported, yet.
Features
Feature | Description | Extra dependencies | Default |
---|---|---|---|
tokio |
Enable tokio_modbus support |
tokio-modbus |
yes |
Examples
The examples
directory in the code repository contains the unabridged code.
Example code for accessing data from a three phase inverter using the model 103
use ;
use Parser;
use Itertools;
use ;
use sleep;
use ;
async
FAQ
How does this crate differ from crates like tokio-sunspec
, sunspec-models
, sunspec_rs
?
-
This crate generates all code using Rust code via the official SunSpec models repository with a code generator that was written in Rust, too.
-
All generated models are plain Rust structs. A single Modbus call can return the complete data for a model rather than having to fetch points individually.
-
All public types are documented. Even the generated models.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.