Sunspec: share block reads across values on the same connection (#33011)

This commit is contained in:
andig 2026-08-20 16:40:13 +02:00 • committed by GitHub
parent 1a0a05c9ad
commit de0bac2bc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 210 additions and 1 deletions

View file

@ -73,7 +73,9 @@ func NewModbusSunspecFromConfig(ctx context.Context, other map[string]any) (Plug
devices := sunspecDevices.Get(conn)
if devices == nil {
devices, err = sunsdev.DeviceTree(conn)
// the device tree captures the client gosunspec uses for all further
// block reads and writes, hence wrap it in the deduplicating cache
devices, err = sunsdev.DeviceTree(newSunspecCachedClient(conn))
if err != nil && !errors.Is(err, meters.ErrPartiallyOpened) {
return nil, err
}