protocol

package
v0.4.48 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestStart          utilities.ActionCode = "RequestStart"
	RetransmitLastMessage utilities.ActionCode = "RetransmitLastMessage"
)
View Source
const (
	DATA protocolMessageType = iota
	EOF
	ERROR
	DISCONNECT
)
View Source
const (
	LineReceived utilities.ActionCode = "LineReceived"
	JustAck      utilities.ActionCode = "JustAck"
	FrameNumber  utilities.ActionCode = "FrameNumber"
)
View Source
const (
	ETBHeaderStarted = "ETB"
	ETXReceived      = "ETX"
	SBRecordStarted  = "SB"
	MRecordStarted   = "M"
	QDRecordStarted  = "QD"
	QRRecordStarted  = "QR"
	DRecordStarted   = "D"
	DBRecordStarted  = "DB"
	DERecordStarted  = "DE"
	DQRecordStarted  = "DQ"
)

Variables

View Source
var (
	ReceiverDoesNotRespond   = errors.New("receiver does not react on sent message")
	ReceivedMessageIsInvalid = errors.New("received message is invalid")
)
View Source
var Rules []utilities.Rule = []utilities.Rule{
	{FromState: utilities.Init, Symbols: []byte{utilities.EOT}, ToState: utilities.Init, Scan: false},

	{FromState: utilities.Init, Symbols: []byte{0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, ToState: utilities.Init, Scan: false},
	{FromState: utilities.Init, Symbols: []byte{utilities.ENQ}, ToState: 1, Scan: false, ActionCode: JustAck},

	{FromState: 1, Symbols: []byte{utilities.STX}, ToState: 99, Scan: false},

	{FromState: 99, Symbols: []byte("01234567"), ToState: 100, Scan: true, ActionCode: FrameNumber},
	{FromState: 99, Symbols: utilities.PrintableChars8Bit, ToState: 2, Scan: true, ActionCode: FrameNumber},
	{FromState: 100, Symbols: utilities.PrintableChars8Bit, ToState: 2, Scan: true},

	{FromState: 2, Symbols: utilities.PrintableChars8Bit, ToState: 2, Scan: true},
	{FromState: 2, Symbols: []byte{utilities.ETX}, ToState: 10, Scan: false, ActionCode: LineReceived},
	{FromState: 2, Symbols: []byte{utilities.ETB}, ToState: 20, Scan: false, ActionCode: LineReceived},

	{FromState: 20, Symbols: []byte("0123456789ABCDEFabcdef"), ToState: 20, Scan: true},
	{FromState: 20, Symbols: []byte{utilities.CR}, ToState: 21, Scan: false, ActionCode: utilities.CheckSum},
	{FromState: 21, Symbols: []byte{utilities.LF}, ToState: 22, Scan: false, ActionCode: JustAck},
	{FromState: 22, Symbols: []byte{utilities.STX}, ToState: 99, Scan: false},

	{FromState: 10, Symbols: []byte("0123456789ABCDEFabcdef"), ToState: 10, Scan: true},
	{FromState: 10, Symbols: []byte{utilities.CR}, ToState: 11, Scan: false, ActionCode: utilities.CheckSum},
	{FromState: 11, Symbols: []byte{utilities.LF}, ToState: 12, Scan: false, ActionCode: JustAck},
	{FromState: 12, Symbols: []byte{utilities.STX}, ToState: 99, Scan: false},
	{FromState: 12, Symbols: []byte{utilities.EOT}, ToState: utilities.Init, Scan: false, ActionCode: utilities.Finished},
}
View Source
var Timeout error = fmt.Errorf("Timeout")

Functions

This section is empty.

Types

type AU6XXProtocolSettings added in v0.4.41

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

func DefaultAU6XXProtocolSettings added in v0.4.41

func DefaultAU6XXProtocolSettings() *AU6XXProtocolSettings

func (AU6XXProtocolSettings) DisableChecksumValidation added in v0.4.41

func (s AU6XXProtocolSettings) DisableChecksumValidation() *AU6XXProtocolSettings

func (AU6XXProtocolSettings) DisableRealTimeDataTransmission added in v0.4.41

func (s AU6XXProtocolSettings) DisableRealTimeDataTransmission() *AU6XXProtocolSettings

func (AU6XXProtocolSettings) EnableChecksumValidation added in v0.4.41

func (s AU6XXProtocolSettings) EnableChecksumValidation() *AU6XXProtocolSettings

func (AU6XXProtocolSettings) EnableRealTimeDataTransmission added in v0.4.41

func (s AU6XXProtocolSettings) EnableRealTimeDataTransmission() *AU6XXProtocolSettings

func (AU6XXProtocolSettings) SetAcknowledgementTimeout added in v0.4.41

func (s AU6XXProtocolSettings) SetAcknowledgementTimeout(duration time.Duration) *AU6XXProtocolSettings

SetAcknowledgementTimeout should be between 0.5ms to max 2.5s Default is 500ms

func (AU6XXProtocolSettings) SetEndByte added in v0.4.41

func (AU6XXProtocolSettings) SetLineBreakByte added in v0.4.41

func (s AU6XXProtocolSettings) SetLineBreakByte(lineBreak byte) *AU6XXProtocolSettings

func (AU6XXProtocolSettings) SetSendTimeoutDuration added in v0.4.41

func (s AU6XXProtocolSettings) SetSendTimeoutDuration(duration time.Duration) *AU6XXProtocolSettings

func (AU6XXProtocolSettings) SetStartByte added in v0.4.41

func (s AU6XXProtocolSettings) SetStartByte(start byte) *AU6XXProtocolSettings

type Implementation added in v0.1.2

type Implementation interface {

	// Stop end end whatever you are doing
	Interrupt()

	// Receive - asynch.
	Receive(conn net.Conn) ([]byte, error)

	// Send - asynch
	Send(conn net.Conn, data [][]byte) (int, error)

	//  Create a new Instance of this class duplicating all settings
	NewInstance() Implementation
}

func AU6XXProtocol added in v0.4.41

func AU6XXProtocol(settings ...*AU6XXProtocolSettings) Implementation

func Lis1A1Protocol added in v0.2.2

func Lis1A1Protocol(settings ...*Lis1A1ProtocolSettings) Implementation

func Logger added in v0.4.34

func Logger(protocol Implementation) Implementation

func LoggerWithAdapter added in v0.4.43

func LoggerWithAdapter(protocol Implementation, logAdapter LogAdapter) Implementation

func MLLP added in v0.2.2

func MLLP(settings ...*MLLPProtocolSettings) Implementation

func PK7xxProtocol added in v0.4.47

func PK7xxProtocol() Implementation

func Raw added in v0.1.2

func Raw(settings ...*RawProtocolSettings) Implementation

func STXETX added in v0.1.2

func STXETX(settings ...*STXETXProtocolSettings) Implementation

type Lis1A1ProtocolSettings added in v0.2.2

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

func DefaultLis1A1ProtocolSettings added in v0.2.2

func DefaultLis1A1ProtocolSettings() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) DisableFrameNumber added in v0.3.0

func (s Lis1A1ProtocolSettings) DisableFrameNumber() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) DisableStrictChecksum added in v0.3.0

func (s Lis1A1ProtocolSettings) DisableStrictChecksum() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) DisableStrictFrameOrder added in v0.3.0

func (s Lis1A1ProtocolSettings) DisableStrictFrameOrder() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) EnableFrameNumber added in v0.3.0

func (s Lis1A1ProtocolSettings) EnableFrameNumber() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) EnableStrictChecksum added in v0.3.0

func (s Lis1A1ProtocolSettings) EnableStrictChecksum() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) EnableStrictFrameOrder added in v0.3.0

func (s Lis1A1ProtocolSettings) EnableStrictFrameOrder() *Lis1A1ProtocolSettings

func (Lis1A1ProtocolSettings) SetSendTimeOutDuration added in v0.3.0

func (s Lis1A1ProtocolSettings) SetSendTimeOutDuration(timeout time.Duration) *Lis1A1ProtocolSettings

type LogAdapter added in v0.4.43

type LogAdapter interface {
	// contains filtered or unexported methods
}

type LogType added in v0.4.43

type LogType string
const LogTypeClos LogType = "clos"
const LogTypeFail LogType = "fail"
const LogTypeInfo LogType = "info"
const LogTypeRecv LogType = "recv"
const LogTypeSend LogType = "send"

type MLLPProtocolSettings added in v0.2.2

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

func DefaultMLLPProtocolSettings added in v0.2.2

func DefaultMLLPProtocolSettings() *MLLPProtocolSettings

func (*MLLPProtocolSettings) SetEndByte added in v0.2.2

func (set *MLLPProtocolSettings) SetEndByte(endByte byte) *MLLPProtocolSettings

func (*MLLPProtocolSettings) SetStartByte added in v0.2.2

func (set *MLLPProtocolSettings) SetStartByte(startByte byte) *MLLPProtocolSettings

type ProcessState added in v0.2.2

type ProcessState struct {
	State           int
	LastMessage     string
	LastChecksum    string
	MessageLog      []string
	ProtocolMessage protocolMessage
	// contains filtered or unexported fields
}

type RawProtocolSettings added in v0.1.2

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

func DefaultRawProtocolSettings added in v0.1.2

func DefaultRawProtocolSettings() *RawProtocolSettings

type STXETXProtocolSettings added in v0.1.2

type STXETXProtocolSettings struct {
}

func DefaultSTXETXProtocolSettings added in v0.1.2

func DefaultSTXETXProtocolSettings() *STXETXProtocolSettings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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