package modbus

import (
	"golib/v3/gnet"
)

func ReadRegister(b []byte, register, quantity int) []byte {
	start := register * 2
	if quantity == 0 {
		quantity = 1
	}
	end := start + quantity*2
	return b[start:end]
}

func ReadRegisterSingle(b []byte, register int) []byte {
	return ReadRegister(b, register, 1)
}

func ReadRegisterBit(b []byte, register int, splitter gnet.BitSplitter) gnet.BitSplit {
	return splitter.BitSplit(ReadRegister(b, register, 1))
}
