Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around devices without end model like some SMA inverters. #20

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

mger1
Copy link
Contributor

@mger1 mger1 commented Dec 5, 2024

Some devices like SMA STP10.0-3SE-40 do not have an end model and discovery fails wit an IllegalDataAddress modbus error.

Work around that by pretending an end model was found when an IllegalDataAddress error occurs during discovery and at least one valid model has been found before.

Some devices like SMA STP10.0-3SE-40 do not have an end model and discovery fails. Work around that by pretending an end model was found when an IllegalDataAddress error occurs and at least one valid model has been found before.
@bikeshedder bikeshedder merged commit 713bbc9 into bikeshedder:main Dec 10, 2024
2 checks passed
@bikeshedder
Copy link
Owner

Oh wow, what a mess!

@bikeshedder
Copy link
Owner

I cleaned up the code a bit and released 0.7.2 on crates.io including this change:

sunspec/src/client/async.rs

Lines 162 to 172 in c4a2f2c

let [model_id, len] = match res {
// End model found. Exit the loop.
Ok([0xFFFF, _]) => break,
// Some devices like SMA STP10.0-3SE-40 do not have an end model
// and discovery fails with an IllegalDataAddress modbus error.
// Work around that by pretending an end model was found when an
// IllegalDataAddress error occurs during discovery and at least
// one valid model has been found before.
Err(ModbusError::IllegalDataAddress) if model_count > 0 => break,
x => x,
}?;

📦 https://crates.io/crates/sunspec/0.7.2

Thanks a lot!

@bikeshedder
Copy link
Owner

I just released sunspec 0.8.0 which updates tokio-modbus to version 0.16 and adds multi-device support. This workaround is also included:

📦 https://crates.io/crates/sunspec/0.8.0

@mger1 mger1 deleted the no_end_model branch December 12, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants