bikeshedder / sunspec

Rust crate for accessing SunSpec compliant devices in a safe and convenient way.
Apache License 2.0
4 stars 3 forks source link

Enable discovery to continue if reading a holding register hangs #4

Closed tazle closed 1 month ago

tazle commented 5 months ago

Hi,

We are dealing with a device that claims to be Sunpec-compliant, but fails to respond to reads of holding register 0, making it impossible to use the standard discovery process as implemented in the sunspec module.

Some options to resolve the issue: 1) Time out reads, so the process could proceed from 0 onwards 2) Enable specifying the starting address for discovery

bikeshedder commented 5 months ago

I think I'll add a discovery config struct for those two things:

struct Discovery {
    /// Addresses to check for the SunS identifier (default: [0, 40000, 50000])
    info_model_addrs: Vec<u16>,
    /// Timeout to be applied for every `read_holding_register` call
    read_timeout: Duration,
}
tazle commented 5 months ago

This sounds excellent.

bikeshedder commented 1 month ago

Sorry for taking so long. I completely forgot about that. I implemented that feature some time ago but simply forgot to push and release it. :facepalm:

bikeshedder commented 1 month ago

@tazle I just pushed sunspec 0.5.0 to crates.io:

I'm not too happy about having to carry a context and config structure around. I think a 0.6 release will add an actual Client structure which is a bit more ergonomic to use.

tazle commented 1 month ago

Thank you! I'll check it out when I next touch our sunspec-utilizing code.