melsecfx

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	STX byte = 0x02
	ETX byte = 0x03
	EOT byte = 0x04
	ENQ byte = 0x05
	ACK byte = 0x06
	LF  byte = 0x0A
	CL  byte = 0x0C
	CR  byte = 0x0D
	NAK byte = 0x15
)

Variables

This section is empty.

Functions

func CalcChecksum

func CalcChecksum(payload []byte) []byte

Types

type Command

type Command int
const (
	ByteRead  Command = 0
	ByteWrite Command = 1
	ForceOn   Command = 7
	ForceOff  Command = 8
)

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) Debug

func (l DefaultLogger) Debug(msg string)

func (DefaultLogger) Error

func (l DefaultLogger) Error(msg string)

type FXPLCClient

type FXPLCClient struct {
	Logger
	// contains filtered or unexported fields
}

func NewFXPLCClient

func NewFXPLCClient(transport ITransport, opts ...FXPLCClientOption) *FXPLCClient

func (*FXPLCClient) Close

func (c *FXPLCClient) Close() error

func (*FXPLCClient) ReadBit

func (c *FXPLCClient) ReadBit(ctx context.Context, register RegisterDef) (bool, error)

func (*FXPLCClient) ReadBytes

func (c *FXPLCClient) ReadBytes(ctx context.Context, addr int, count int) ([]byte, error)

func (*FXPLCClient) ReadInt

func (c *FXPLCClient) ReadInt(ctx context.Context, register RegisterDef) (int, error)

func (*FXPLCClient) ReadMultipleBit

func (c *FXPLCClient) ReadMultipleBit(ctx context.Context, register RegisterDef, num int) ([]bool, error)

func (*FXPLCClient) ReadMultipleNumber

func (c *FXPLCClient) ReadMultipleNumber(ctx context.Context, register RegisterDef, numberType NumberType, num int) ([]interface{}, error)

func (*FXPLCClient) ReadNumber

func (c *FXPLCClient) ReadNumber(ctx context.Context, register RegisterDef, numberType NumberType) (interface{}, error)

func (*FXPLCClient) WriteBit

func (c *FXPLCClient) WriteBit(ctx context.Context, register RegisterDef, value bool) error

func (*FXPLCClient) WriteBytes

func (c *FXPLCClient) WriteBytes(ctx context.Context, addr int, values []byte) error

func (*FXPLCClient) WriteInt

func (c *FXPLCClient) WriteInt(ctx context.Context, register RegisterDef, value int) error

func (*FXPLCClient) WriteNumber

func (c *FXPLCClient) WriteNumber(ctx context.Context, register RegisterDef, value interface{}, numberType NumberType) error

type FXPLCClientOption

type FXPLCClientOption func(*FXPLCClient)

func WithLogger

func WithLogger(logger Logger) FXPLCClientOption

type ITransport

type ITransport interface {
	Write(ctx context.Context, data []byte) error
	// Read(ctx context.Context, size int) ([]byte, error)
	Read(data []byte) (int, error)
	Close() error
}

type Logger

type Logger interface {
	Debug(msg string)
	Error(msg string)
}

type NoResponseError

type NoResponseError struct{}

func (*NoResponseError) Error

func (e *NoResponseError) Error() string

type NotSupportedCommandError

type NotSupportedCommandError struct{}

func (*NotSupportedCommandError) Error

func (e *NotSupportedCommandError) Error() string

type NumberType

type NumberType int
const (
	WordSigned NumberType = iota
	DoubleWordSigned
	WordUnsigned
	DoubleWordUnsigned
	Float
)

func (NumberType) FormatStr

func (n NumberType) FormatStr() string

func (NumberType) Size

func (n NumberType) Size() int

type RegisterDef

type RegisterDef struct {
	Type RegisterType
	Num  int
}

func RegisterDefParse

func RegisterDefParse(definition string) RegisterDef

func (RegisterDef) GetBitImageAddress

func (r RegisterDef) GetBitImageAddress() (int, int)

func (RegisterDef) String

func (r RegisterDef) String() string

type RegisterType

type RegisterType string
const (
	State   RegisterType = "S"
	Input   RegisterType = "X"
	Output  RegisterType = "Y"
	Timer   RegisterType = "T"
	Memory  RegisterType = "M"
	Data    RegisterType = "D"
	Counter RegisterType = "C"
)

type ResponseMalformedError

type ResponseMalformedError struct{}

func (*ResponseMalformedError) Error

func (e *ResponseMalformedError) Error() string

type SerialTransport

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

func NewDefaultSerialTransport

func NewDefaultSerialTransport(address string) *SerialTransport

func NewSerialTransport

func NewSerialTransport(address string, baudRate int, dataBits byte, parity serial.Parity, stopBits int) *SerialTransport

func (*SerialTransport) Close

func (t *SerialTransport) Close() error

func (*SerialTransport) Read

func (t *SerialTransport) Read(data []byte) (int, error)

func (*SerialTransport) Write

func (t *SerialTransport) Write(ctx context.Context, data []byte) error

Jump to

Keyboard shortcuts

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