internal

package
v2.0.0-...-d0d923d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Products lib.Map[Product]

Functions

func CRC16

func CRC16(bs []byte) uint16

CRC16 Calculate Cyclical Redundancy Checking.

func LoadProduct

func LoadProduct(m *types.Product) error

func LoadProducts

func LoadProducts() error

func Offline

func Offline(pid, id string)

func Online

func Online(pid, id string)

Types

type Messenger

type Messenger struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*Messenger) Ask

func (m *Messenger) Ask(request []byte, response []byte) (int, error)

func (*Messenger) AskAtLeast

func (m *Messenger) AskAtLeast(request []byte, response []byte, min int) (int, error)

func (*Messenger) Read

func (m *Messenger) Read(response []byte) (int, error)

func (*Messenger) ReadAtLeast

func (m *Messenger) ReadAtLeast(response []byte, min int) (int, error)

type Modbus

type Modbus interface {
	Read(slave uint8, code uint8, addr uint16, size uint16) ([]byte, error)
	Write(slave uint8, code uint8, addr uint16, buf []byte) error
}

type ParallelTCP

type ParallelTCP struct {
	// contains filtered or unexported fields
}

ParallelTCP Modbus-TCP协议

func NewParallelTCP

func NewParallelTCP(tunnel define.Conn, opts string) *ParallelTCP

func (*ParallelTCP) OnData

func (m *ParallelTCP) OnData(buf []byte)

func (*ParallelTCP) Read

func (m *ParallelTCP) Read(slave uint8, code uint8, addr uint16, size uint16) ([]byte, error)

func (*ParallelTCP) Write

func (m *ParallelTCP) Write(slave uint8, code uint8, addr uint16, buf []byte) error

type Product

type Product struct {
	*types.Product
	// contains filtered or unexported fields
}

func GetProduct

func GetProduct(id string) *Product

type RTU

type RTU struct {
	// contains filtered or unexported fields
}

RTU Modbus-RTU协议

func NewRTU

func NewRTU(tunnel define.Conn, opts string) *RTU

func (*RTU) Read

func (m *RTU) Read(slave uint8, code uint8, addr uint16, size uint16) ([]byte, error)

func (*RTU) Write

func (m *RTU) Write(slave uint8, code uint8, addr uint16, buf []byte) error

type TCP

type TCP struct {
	// contains filtered or unexported fields
}

TCP Modbus-TCP协议

func NewTCP

func NewTCP(tunnel define.Conn, opts string) *TCP

func (*TCP) Read

func (m *TCP) Read(slave uint8, code uint8, addr uint16, size uint16) ([]byte, error)

func (*TCP) Write

func (m *TCP) Write(slave uint8, code uint8, addr uint16, buf []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL