4 releases

0.2.2 Mar 22, 2023
0.2.1 Mar 17, 2023
0.2.0 Mar 14, 2023
0.1.0 Mar 2, 2023

#693 in Hardware support

41 downloads per month

Apache-2.0

185KB
3.5K SLoC

tokio-sunspec

A pure Rust SunSpec library based on tokio.

Crates.io Apache 2.0 licensed

Features

  • Pure Rust library
  • Non-blocking
  • TCP Client
  • RTU Client
  • Model discovery
  • Type safe SunSpec models
  • Repeating models

Installation

[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

let socket_addr = "<ip-address>: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

Fruther notice

This lib only implements the SunSpec part. The connection via modbus is done by the tokio-modbus lib.

License

Copyright (c) 2023 Lukas Kirner

Apache-2.0

Dependencies

~0.3–9.5MB
~87K SLoC