Documentation ¶
Index ¶
- Constants
- func CRC(data []byte) uint16
- type Proto2
- func (p *Proto2) Action() error
- func (p *Proto2) Ping(ident int) error
- func (p *Proto2) ReadData(ident int, addr int, n int) ([]byte, error)
- func (p *Proto2) RegWrite(ident int, address int, data []byte, expectResponse bool) error
- func (p *Proto2) SetBuffered(buffered bool)
- func (p *Proto2) WriteData(ident int, address int, data []byte, expectResponse bool) error
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 ¶
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 ¶
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 ¶
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) SetBuffered ¶
Click to show internal directories.
Click to hide internal directories.