Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 12, 2025
1 parent efc060f commit f62c87b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ replace github.com/grid-x/modbus => github.com/evcc-io/modbus v0.0.0-20241027151

replace github.com/lorenzodonini/ocpp-go => github.com/evcc-io/ocpp-go v0.0.0-20241230132027-815870498cc3

replace github.com/mlnoga/rct => github.com/Maschga/rct v0.1.2-0.20250109193706-eb89ae8367b0
replace github.com/mlnoga/rct => github.com/Maschga/rct v0.1.2-0.20250112094625-b2df451c7ef9
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Maschga/rct v0.1.2-0.20250109193706-eb89ae8367b0 h1:2SFP1mVFv9ei1EegScobPLo2PE/boYC4oRp4mVzup1M=
github.com/Maschga/rct v0.1.2-0.20250109193706-eb89ae8367b0/go.mod h1:0lfd2mmBnBzIvuzYtdhG+2371u+cUfIxsYErm4P9KRI=
github.com/Maschga/rct v0.1.2-0.20250112094625-b2df451c7ef9 h1:rr2Rk9DNdyFCN8OEIVlxkSt9ftgO1MRWj+3ar39Ldu0=
github.com/Maschga/rct v0.1.2-0.20250112094625-b2df451c7ef9/go.mod h1:0lfd2mmBnBzIvuzYtdhG+2371u+cUfIxsYErm4P9KRI=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
Expand Down
15 changes: 4 additions & 11 deletions meter/rct.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,22 @@ func (m *RCT) queryFloat(id rct.Identifier) (float64, error) {

// setBatteryMode implements the api.BatteryController interface
func (m *RCT) setBatteryMode(mode api.BatteryMode) error {
write := func(id rct.Identifier, data []byte) error {
b := rct.NewDatagramBuilder()
b.Build(&rct.Datagram{rct.Write, id, data})
_, err := m.conn.Send(b)
return err
}

switch mode {
case api.BatteryNormal:
return write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetInternal})
return m.conn.Write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetInternal})

case api.BatteryHold:
return write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetConstant})
return m.conn.Write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetConstant})

case api.BatteryCharge:
if err := write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetExternal}); err != nil {
if err := m.conn.Write(rct.PowerMngSocStrategy, []byte{rct.SOCTargetExternal}); err != nil {
return err
}

data := make([]byte, 4)
binary.BigEndian.PutUint32(data, math.Float32bits(0.95))

return write(rct.PowerMngSocTargetSet, []byte{rct.SOCTargetExternal})
return m.conn.Write(rct.PowerMngSocTargetSet, []byte{rct.SOCTargetExternal})

default:
return api.ErrNotAvailable
Expand Down

0 comments on commit f62c87b

Please sign in to comment.