phy

package
v0.0.0-...-ae9fff6 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PHY

type PHY struct {
	// Port is the device used to communicate with the target.
	Port io.ReadWriteCloser

	// RXHandlePresense is an optional callback that is called when a target device may be present.
	RXHandlePresense func(byte) error

	// RXHandlePacket is a callback that is called each time a valid packet is received. Please note
	// that, depending on your hardware configuration, you may receive your own packets.
	RXHandlePacket func(addrSource uint8, addrDest uint8, payload []byte) error

	// TXDisableScrambler disables scrambling on outgoing packets when set.
	TXDisableScrambler bool

	// TXSendBreak is a callback that should send a low state on the serial line for at least
	// the given duration. If your hardware does not allow duration control, ensure it is at
	// least 70ms.
	TXSendBreak func(t time.Duration) error
	// contains filtered or unexported fields
}

PHY implements functions for receiving and transmitting data to ISDT BattGO devices.

func NewSerialSimple

func NewSerialSimple(portName string) (*PHY, error)

NewSerialSimple is a convenience function that sets the PHY up for a standard serial port.

func (*PHY) Close

func (b *PHY) Close() error

Close stops Run() and also closes the underlying io.Closer

func (*PHY) Run

func (b *PHY) Run() error

Run needs to be called to start listening for packets on the line. It will return when there is an error or Close() is called.

func (*PHY) TXSendPacket

func (b *PHY) TXSendPacket(addrSource uint8, addrDest uint8, payload []byte) error

TXSendPacket encode and sends a packet to the remote device.

Jump to

Keyboard shortcuts

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