Documentation ¶
Index ¶
- func BytesToFloat32(bytes []byte) float32
- func BytesToUint16(bytes []byte) []uint16
- func BytesToUint32(bytes []byte) []uint32
- func CrcModbus(data []byte) (crc uint16)
- func DecodeFloat32s(bytes *[]byte, num uint) (vals []float32, err error)
- func DecodeUint16s(bytes *[]byte, num uint) (vals []uint16, err error)
- func DecodeUint32s(bytes *[]byte, num uint) (vals []uint32, err error)
- func EncodeFloat32(bytes *[]byte, value float32)
- func EncodeUint16(bytes *[]byte, value uint16)
- func EncodeUint32(bytes *[]byte, value uint32)
- func Float32ToBytes(value float32) []byte
- func SetDataWithRegisterAndNumber(frame Framer, register uint16, number uint16)
- func SetDataWithRegisterAndNumberAndBytes(frame Framer, register uint16, number uint16, bytes []byte)
- func SetDataWithRegisterAndNumberAndValues(frame Framer, register uint16, number uint16, values []uint16)
- func Uint16ToBytes(values []uint16) []byte
- func Uint32ToBytes(values []uint32) []byte
- type Exception
- type Framer
- type RTUFrame
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToFloat32 ¶
BytesToFloat32 converts a big endian array of bytes to an array of float32
func BytesToUint16 ¶
BytesToUint16 converts a big endian array of bytes to an array of unit16s
func BytesToUint32 ¶
BytesToUint32 converts a big endian array of bytes to an array of unit32s
func EncodeFloat32 ¶
func EncodeUint16 ¶
func EncodeUint32 ¶
func Float32ToBytes ¶
Float32ToBytes converts an array of float32 to a big endian array of bytes
func SetDataWithRegisterAndNumber ¶
SetDataWithRegisterAndNumber sets the RTUFrame Data byte field to hold a register and number of registers
func SetDataWithRegisterAndNumberAndBytes ¶
func SetDataWithRegisterAndNumberAndBytes(frame Framer, register uint16, number uint16, bytes []byte)
SetDataWithRegisterAndNumberAndBytes sets the TCPFrame Data byte field to hold a register and number of registers and coil bytes
func SetDataWithRegisterAndNumberAndValues ¶
func SetDataWithRegisterAndNumberAndValues(frame Framer, register uint16, number uint16, values []uint16)
SetDataWithRegisterAndNumberAndValues sets the TCPFrame Data byte field to hold a register and number of registers and values
func Uint16ToBytes ¶
Uint16ToBytes converts an array of uint16s to a big endian array of bytes
func Uint32ToBytes ¶
Uint32ToBytes converts an array of uint32s to a big endian array of bytes
Types ¶
type Exception ¶
type Exception uint8
Exception codes.
var ( // Success operation successful. Success Exception // IllegalFunction function code received in the query is not recognized or allowed by slave. IllegalFunction Exception = 1 // IllegalDataAddress data address of some or all the required entities are not allowed or do not exist in slave. IllegalDataAddress Exception = 2 // IllegalDataValue value is not accepted by slave. IllegalDataValue Exception = 3 // SlaveDeviceFailure Unrecoverable error occurred while slave was attempting to perform requested action. SlaveDeviceFailure Exception = 4 // AcknowledgeSlave has accepted request and is processing it, but a long duration of time is required. This response is returned to prevent a timeout error from occurring in the master. Master can next issue a Poll Program Complete message to determine whether processing is completed. AcknowledgeSlave Exception = 5 // SlaveDeviceBusy is engaged in processing a long-duration command. Master should retry later. SlaveDeviceBusy Exception = 6 // NegativeAcknowledge Slave cannot perform the programming functions. Master should request diagnostic or error information from slave. NegativeAcknowledge Exception = 7 // MemoryParityError Slave detected a parity error in memory. Master can retry the request, but service may be required on the slave device. MemoryParityError Exception = 8 GatewayPathUnavailable Exception = 10 // GatewayTargetDeviceFailedtoRespond Specialized for Modbus gateways. Sent when slave fails to respond. GatewayTargetDeviceFailedtoRespond Exception = 11 )
func GetException ¶
GetException retunrns the Modbus exception or Success (indicating not exception).
type Framer ¶
type Framer interface { Bytes() []byte Copy() Framer GetData() []byte GetFunction() uint8 SetException(exception *Exception) SetData(data []byte) }
Framer is the interface that wraps Modbus frames.
type RTUFrame ¶
RTUFrame is the Modbus TCP frame.
func NewRTUFrame ¶
NewRTUFrame converts a packet to a Modbus RTU frame.
func (*RTUFrame) GetFunction ¶
GetFunction returns the Modbus function code.
func (*RTUFrame) SetData ¶
SetData sets the RTUFrame Data byte field and updates the frame length accordingly.
func (*RTUFrame) SetException ¶
SetException sets the Modbus exception code in the frame.