v2

package
v0.0.0-...-be9965c Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2016 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// Instruction Types
	Ping         byte = 0x01
	ReadData     byte = 0x02
	WriteData    byte = 0x03
	RegWrite     byte = 0x04
	Action       byte = 0x05
	FactoryReset byte = 0x06 // All data to factory default settings
	Reboot       byte = 0x08 // Reboot device
	Status       byte = 0x55
	SyncRead     byte = 0x82
	SyncWrite    byte = 0x83
	BulkRead     byte = 0x92
	BulkWrite    byte = 0x93

	// Send an instruction to all servos
	BroadcastIdent int = 0xFE // 254
)

Variables

This section is empty.

Functions

Types

type Proto2

type Proto2 struct {
	Network io.ReadWriter
}

func New

func New(network io.ReadWriter) *Proto2

func (*Proto2) Action

func (p *Proto2) Action() error

Action broadcasts the ACTION instruction, which initiates any previously bufferred instructions. Doesn't wait for a status packet in response, because they are not sent in response to broadcast instructions.

func (*Proto2) Ping

func (p *Proto2) Ping(ident int) error

Ping sends the PING instruction to the given Servo ID, and waits for the response. Returns an error if the ping fails, or nil if it succeeds.

func (*Proto2) ReadData

func (p *Proto2) ReadData(ident int, addr int, n int) ([]byte, error)

ReadData reads a slice of n bytes from the control table of the given servo ID. Use the bytesToInt function to convert the output to something more useful.

func (*Proto2) RegWrite

func (p *Proto2) RegWrite(ident int, address int, data []byte, expectResponse bool) error

func (*Proto2) SetBuffered

func (p *Proto2) SetBuffered(buffered bool)

func (*Proto2) WriteData

func (p *Proto2) WriteData(ident int, address int, data []byte, expectResponse bool) error

Jump to

Keyboard shortcuts

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