diff --git a/cmd/confighandler.go b/cmd/confighandler.go index e12a46b8..d4afcdc1 100644 --- a/cmd/confighandler.go +++ b/cmd/confighandler.go @@ -158,7 +158,7 @@ func (conf *DeviceConfigHandler) createDeviceForManager( } sort.SearchStrings(sunspecTypes, meterType) - if _, ok := manager.Conn.(*meters.TCP); ok || isSunspec { + if isSunspec { meter = sunspec.NewDevice(meterType) } else { var err error @@ -171,12 +171,6 @@ func (conf *DeviceConfigHandler) createDeviceForManager( return meter } -// isRTUDevice checks if type is a known RTU device type -func (conf *DeviceConfigHandler) isRTUDevice(meterType string) bool { - _, ok := rs485.Producers[strings.ToUpper(meterType)] - return ok -} - // CreateDevice creates new device and adds it to the connection manager func (conf *DeviceConfigHandler) CreateDevice(devConf DeviceConfig) { if devConf.Adapter == "" { @@ -235,10 +229,9 @@ func (conf *DeviceConfigHandler) CreateDeviceFromSpec(deviceDef string) { log.Fatalf("Error parsing device id %s: %v. See -h for help.", devID, err) } - // RTU flag is inferred if the device is of RTU type. - // It is used to implicitly create an RTUOverTCP instead of a TCP connection - rtu := conf.isRTUDevice(meterType) - manager := conf.ConnectionManager(connSpec, rtu, 0, "") + // If this is an RTU over TCP device, a default RTU over TCP should already + // have been created of the --rtu flag was specified. We'll not re-check this here. + manager := conf.ConnectionManager(connSpec, false, 0, "") meter := conf.createDeviceForManager(manager, meterType) if err := manager.Add(uint8(id), meter); err != nil { diff --git a/docs/mbmd_inspect.md b/docs/mbmd_inspect.md index 6b33c819..a0efb904 100644 --- a/docs/mbmd_inspect.md +++ b/docs/mbmd_inspect.md @@ -20,10 +20,10 @@ mbmd inspect [flags] Valid types are: RTU ABB ABB A/B-Series meters - BE Bernecker Engineering MPM3PM meters DZG DZG Metering GmbH DVH4013 meters INEPRO Inepro Metering Pro 380 JANITZA Janitza B-Series meters + MPM Bernecker Engineering MPM3PM meters SBC Saia Burgess Controls ALE3 meters SDM Eastron SDM630 SDM220 Eastron SDM220 diff --git a/docs/mbmd_run.md b/docs/mbmd_run.md index cab70bf4..7f25ccf2 100644 --- a/docs/mbmd_run.md +++ b/docs/mbmd_run.md @@ -19,10 +19,10 @@ mbmd run [flags] Valid types are: RTU ABB ABB A/B-Series meters - BE Bernecker Engineering MPM3PM meters DZG DZG Metering GmbH DVH4013 meters INEPRO Inepro Metering Pro 380 JANITZA Janitza B-Series meters + MPM Bernecker Engineering MPM3PM meters SBC Saia Burgess Controls ALE3 meters SDM Eastron SDM630 SDM220 Eastron SDM220 diff --git a/meters/rs485/mpm3pm.go b/meters/rs485/mpm3pm.go index b1dd500c..0ca00c60 100644 --- a/meters/rs485/mpm3pm.go +++ b/meters/rs485/mpm3pm.go @@ -9,7 +9,7 @@ func init() { } const ( - METERTYPE_BE = "BE" + METERTYPE_MPM = "MPM" ) type MPM3MPProducer struct { @@ -50,7 +50,7 @@ func NewMPM3MPProducer() Producer { // Type implements Producer interface func (p *MPM3MPProducer) Type() string { - return METERTYPE_BE + return METERTYPE_MPM } // Description implements Producer interface @@ -60,7 +60,7 @@ func (p *MPM3MPProducer) Description() string { func (p *MPM3MPProducer) snip(iec Measurement, readlen uint16, transform RTUTransform, scaler ...float64) Operation { snip := Operation{ - FuncCode: ReadInputReg, + FuncCode: ReadHoldingReg, OpCode: p.Opcodes[iec], ReadLen: readlen, Transform: transform,