control

package
v0.0.0-...-a41b70d Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Control

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

Control handles sending commands to and receiving responses from a robot control connection.

func New

func New(f *finder.Finder, l *logger.Logger) (*Control, error)

New returns a new Control instance with no associated ip. The given finder will be used to detect a robot broadcasting its ip in the network.

func (*Control) Close

func (c *Control) Close() error

Close tries to close the connection to the robot control port. Returns a nil error on success and a non-nil error on failure.

func (*Control) IP

func (c *Control) IP() (net.IP, error)

IP is a convenience function to get the robot ip. Returns the robot ip associated with this control instance and a nil error on success and a non-nil error on failure.

func (*Control) Open

func (c *Control) Open() error

Open tries to open the connection to the robot control port. Returns a nil error on success and a non-nil error on failure.

func (*Control) ReceiveData

func (c *Control) ReceiveData() (string, error)

ReceiveData reads any data available through the control connection. This is usually the result of executing a command sent with SendData(). Returns the available data and a nil error on success and a non-nil error on failure

func (*Control) SendAndReceiveData

func (c *Control) SendAndReceiveData(data string) (string, error)

SendAndReceiveData is a convenience method to send data and get the response data at once. Returns the received data and a nil error on success and a non-nil error on failure.

func (*Control) SendData

func (c *Control) SendData(data string) error

SendData sends data to the control connection. The data should be the a fully-formed plain-text SDK command. Returns a nil error on success and a non-nil error on failure.

func (*Control) SendDataExpectOk

func (c *Control) SendDataExpectOk(data string) error

SendDataExpectOk is a convenience method to send data and make sure we got an ok response back. Returns a nil error on success and a non-nil error on failure.

func (*Control) SendDataExpectOkAsync

func (c *Control) SendDataExpectOkAsync(data string) error

SendDataExpectOkAsync is a convenience method to send data and check we got an ok response back. The response is received asynchronously and checked if it is ok. If it is not ok, the information is logged. Any errors when receiving the response are also logged. This should be used whenever tbe latency of receiving a reply would interfere with the program. Returns a nil error on sending success and a non-nil error on failure.

Jump to

Keyboard shortcuts

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