serialpacket

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTimeout      = Error("Command Timeout")
	ErrorNack         = Error("Command rejected")
	ErrorSyncFailed   = Error("Invaild sync response")
	ErrorNotConnected = Error("Not connected")
)
View Source
const AddressDefault = 0xFF

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func CreateProtocol

func CreateProtocol(port io.ReadWriteCloser, key []byte) *Bus

func (*Bus) CloseProtocol

func (s *Bus) CloseProtocol() error

func (*Bus) GetDefaultDevice

func (s *Bus) GetDefaultDevice() *Device

func (*Bus) GetDevice

func (s *Bus) GetDevice(address uint8) *Device

func (*Bus) ProtocolHandler

func (s *Bus) ProtocolHandler() error

func (*Bus) SetUnsolicitedHandler

func (s *Bus) SetUnsolicitedHandler(cb func(msgType MessageType, buf []byte))

type Device

type Device struct {
	sync.Mutex

	Timeout int
	// contains filtered or unexported fields
}

func (*Device) Connect

func (s *Device) Connect() ([]byte, error)

func (*Device) ConnectForce

func (s *Device) ConnectForce(serial []byte) ([]byte, error)

func (*Device) Disconnect

func (s *Device) Disconnect()

func (*Device) GetDeviceSerial

func (s *Device) GetDeviceSerial() ([]byte, error)

func (*Device) GetSystemTime

func (s *Device) GetSystemTime() (uint64, error)

func (*Device) SendCommand

func (s *Device) SendCommand(cmd MessageType, payload []byte, timeout int) ([]byte, error)

func (*Device) TestComm

func (s *Device) TestComm() error

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type MessageType

type MessageType byte

Jump to

Keyboard shortcuts

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