sunspec: add bool getter (#31482)

This commit is contained in:
andig 2026-07-05 12:07:10 +02:00 • committed by GitHub
parent 6cce4b789f
commit c3692046b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 195 additions and 23 deletions

View file

@ -17,8 +17,8 @@ func Backoff() *backoff.ExponentialBackOff {
return backoff.NewExponentialBackOff(backoff.WithInitialInterval(20*time.Millisecond), backoff.WithMaxElapsedTime(10*time.Second))
}
// decodeMask converts a bit mask in decimal or hex format to uint64
func decodeMask(mask string) (uint64, error) {
// DecodeMask converts a bit mask in decimal or hex format to uint64
func DecodeMask(mask string) (uint64, error) {
mask = strings.ToLower(mask)
if mask == "" {

View file

@ -92,7 +92,7 @@ func (r Register) DecodeFunc() (func([]byte) float64, error) {
case "uint16nan":
return decodeNaN16(asFloat64(encoding.Uint16), 1<<16-1), nil
case "bool16":
mask, err := decodeMask(r.BitMask)
mask, err := DecodeMask(r.BitMask)
if err != nil {
return nil, err
}