gobot: gobot.io/x/gobot/platforms/firmata/client Index | Files

package client

import "gobot.io/x/gobot/platforms/firmata/client"

Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol.

Index

Package Files

client.go

Constants

const (
    Input  = 0x00
    Output = 0x01
    Analog = 0x02
    Pwm    = 0x03
    Servo  = 0x04
)

Pin Modes

const (
    ProtocolVersion          byte = 0xF9
    SystemReset              byte = 0xFF
    DigitalMessage           byte = 0x90
    DigitalMessageRangeStart byte = 0x90
    DigitalMessageRangeEnd   byte = 0x9F
    AnalogMessage            byte = 0xE0
    AnalogMessageRangeStart  byte = 0xE0
    AnalogMessageRangeEnd    byte = 0xEF
    ReportAnalog             byte = 0xC0
    ReportDigital            byte = 0xD0
    PinMode                  byte = 0xF4
    StartSysex               byte = 0xF0
    EndSysex                 byte = 0xF7
    CapabilityQuery          byte = 0x6B
    CapabilityResponse       byte = 0x6C
    PinStateQuery            byte = 0x6D
    PinStateResponse         byte = 0x6E
    AnalogMappingQuery       byte = 0x69
    AnalogMappingResponse    byte = 0x6A
    StringData               byte = 0x71
    I2CRequest               byte = 0x76
    I2CReply                 byte = 0x77
    I2CConfig                byte = 0x78
    FirmwareQuery            byte = 0x79
    I2CModeWrite             byte = 0x00
    I2CModeRead              byte = 0x01
    I2CModeContinuousRead    byte = 0x02
    I2CModeStopReading       byte = 0x03
    ServoConfig              byte = 0x70
)

Sysex Codes

Variables

var (
    ErrConnected = errors.New("client is already connected")
)

Errors

type Client Uses

type Client struct {
    FirmwareName    string
    ProtocolVersion string

    ConnectTimeout time.Duration

    gobot.Eventer
    // contains filtered or unexported fields
}

Client represents a client connection to a firmata board

func New Uses

func New() *Client

New returns a new Client

func (*Client) AnalogMappingQuery Uses

func (b *Client) AnalogMappingQuery() error

AnalogMappingQuery sends the AnalogMappingQuery sysex code.

func (*Client) AnalogWrite Uses

func (b *Client) AnalogWrite(pin int, value int) error

AnalogWrite writes value to pin.

func (*Client) CapabilitiesQuery Uses

func (b *Client) CapabilitiesQuery() error

CapabilitiesQuery sends the CapabilityQuery sysex code.

func (*Client) Connect Uses

func (b *Client) Connect(conn io.ReadWriteCloser) (err error)

Connect connects to the Client given conn. It first resets the firmata board then continuously polls the firmata board for new information when it's available.

func (*Client) Connected Uses

func (b *Client) Connected() bool

Connected returns the current connection state of the Client

func (*Client) Connecting Uses

func (b *Client) Connecting() bool

Connecting returns true when the client is connecting

func (*Client) DigitalWrite Uses

func (b *Client) DigitalWrite(pin int, value int) error

DigitalWrite writes value to pin.

func (*Client) Disconnect Uses

func (b *Client) Disconnect() (err error)

Disconnect disconnects the Client

func (*Client) FirmwareQuery Uses

func (b *Client) FirmwareQuery() error

FirmwareQuery sends the FirmwareQuery sysex code.

func (*Client) I2cConfig Uses

func (b *Client) I2cConfig(delay int) error

I2cConfig configures the delay in which a register can be read from after it has been written to.

func (*Client) I2cRead Uses

func (b *Client) I2cRead(address int, numBytes int) error

I2cRead reads numBytes from address once.

func (*Client) I2cWrite Uses

func (b *Client) I2cWrite(address int, data []byte) error

I2cWrite writes data to address.

func (*Client) PinStateQuery Uses

func (b *Client) PinStateQuery(pin int) error

PinStateQuery sends a PinStateQuery for pin.

func (*Client) Pins Uses

func (b *Client) Pins() []Pin

Pins returns all available pins

func (*Client) ProtocolVersionQuery Uses

func (b *Client) ProtocolVersionQuery() error

ProtocolVersionQuery sends the ProtocolVersion sysex code.

func (*Client) ReportAnalog Uses

func (b *Client) ReportAnalog(pin int, state int) error

ReportAnalog enables or disables analog reporting for pin, a non zero state enables reporting

func (*Client) ReportDigital Uses

func (b *Client) ReportDigital(pin int, state int) error

ReportDigital enables or disables digital reporting for pin, a non zero state enables reporting

func (*Client) Reset Uses

func (b *Client) Reset() error

Reset sends the SystemReset sysex code.

func (*Client) ServoConfig Uses

func (b *Client) ServoConfig(pin int, max int, min int) error

ServoConfig sets the min and max pulse width for servo PWM range

func (*Client) SetPinMode Uses

func (b *Client) SetPinMode(pin int, mode int) error

SetPinMode sets the pin to mode.

func (*Client) WriteSysex Uses

func (b *Client) WriteSysex(data []byte) (err error)

WriteSysex writes an arbitrary Sysex command to the microcontroller.

type I2cReply Uses

type I2cReply struct {
    Address  int
    Register int
    Data     []byte
}

I2cReply represents the response from an I2cReply message

type Pin Uses

type Pin struct {
    SupportedModes []int
    Mode           int
    Value          int
    State          int
    AnalogChannel  int
}

Pin represents a pin on the firmata board

Package client imports 8 packages (graph) and is imported by 2 packages. Updated 2017-12-22. Refresh now. Tools for package owners.