Skip to content

Splitter interface

Latest

Choose a tag to compare

@aldas aldas released this 14 Apr 08:12
5154c59

What's Changed

Request builder can be provided with custom splitter implementation or default splitter with custom splitting callback

	b := modbus.NewRequestBuilderWithConfig(modbus.BuilderDefaults{
		ServerAddress: "tcp://172.25.28.29:8899",
		FunctionCode:  packet.FunctionReadHoldingRegisters,
		UnitID:        1,
		Protocol:      modbus.ProtocolTCP,
		Interval:      modbus.Duration(5 * time.Second),
		Splitter: modbus.DefaultSplitter{
			ShouldSplitFunc: func(batch modbus.SplitBatch, address uint16, size uint16) bool {
				// split to new request when addresses are not consecutive
				return int(address) - int(batch.StartAddress + batch.Quantity - 1) > 1
			},
		},
	})

Changes

  • CI: add Go 1.26 to CI flow by @aldas in #33
  • add Splitter interface and default implementation by @aldas in #35
  • improve test by @aldas in #36
  • Changelog for 0.5.0 release by @aldas in #37

Full Changelog: v0.4.0...v0.5.0