Alphatec: add modbus delay (#10760)
20ms fixed delay between Modbus operations.
This commit is contained in:
parent
519b8dfb3b
commit
29dbd629a3
2 changed files with 12 additions and 15 deletions
|
|
@ -47,32 +47,25 @@ func init() {
|
|||
|
||||
// NewAlphatecFromConfig creates a Alphatec charger from generic config
|
||||
func NewAlphatecFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
cc := struct {
|
||||
modbus.Settings `mapstructure:",squash"`
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Settings: modbus.Settings{
|
||||
ID: 1,
|
||||
},
|
||||
cc := modbus.Settings{
|
||||
ID: 1,
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewAlphatec(cc.URI, cc.Device, cc.Comset, cc.Baudrate, modbus.ProtocolFromRTU(cc.RTU), cc.ID, cc.Timeout)
|
||||
return NewAlphatec(cc.URI, cc.Device, cc.Comset, cc.Baudrate, modbus.ProtocolFromRTU(cc.RTU), cc.ID)
|
||||
}
|
||||
|
||||
// NewAlphatec creates Alphatec charger
|
||||
func NewAlphatec(uri, device, comset string, baudrate int, proto modbus.Protocol, slaveID uint8, timeout time.Duration) (api.Charger, error) {
|
||||
func NewAlphatec(uri, device, comset string, baudrate int, proto modbus.Protocol, slaveID uint8) (api.Charger, error) {
|
||||
conn, err := modbus.NewConnection(uri, device, comset, baudrate, proto, slaveID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if timeout > 0 {
|
||||
conn.Timeout(timeout)
|
||||
}
|
||||
conn.Delay(20 * time.Millisecond)
|
||||
|
||||
if !sponsor.IsAuthorized() {
|
||||
return nil, api.ErrSponsorRequired
|
||||
|
|
|
|||
|
|
@ -2,16 +2,20 @@ template: alphatec
|
|||
products:
|
||||
- brand: Alphatec
|
||||
description:
|
||||
generic: Wallbox Mini/ AW1eM
|
||||
generic: Wallbox Mini/Power
|
||||
- brand: Alphatec
|
||||
description:
|
||||
generic: Ladesäule Twin
|
||||
requirements:
|
||||
description:
|
||||
de: Die Hauptplatine benötigt eine aktuelle Firmware. Eine aktuelle Softwareversion kann man daran erkennen, dass die Seriennummer auf dem braunen Relais mit 2022 beginnt oder auf den kleinen weißen Relais eine 15 steht. Andernfalls bitte direkt an den Hersteller wenden.
|
||||
en: The motherboard requires current firmware. You can recognize a current software version by the fact that the serial number on the brown relay starts with 2022 or there is a 15 on the small white relays. Otherwise, please contact the manufacturer directly.
|
||||
evcc: ["sponsorship"]
|
||||
params:
|
||||
- name: modbus
|
||||
choice: ["rs485"]
|
||||
baudrate: 9600
|
||||
comset: 8N1
|
||||
- name: timeout
|
||||
render: |
|
||||
type: alphatec
|
||||
{{- include "modbus" . }}
|
||||
timeout: {{ .timeout }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue