xb

package
v0.0.0-...-328052d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadChunk

func ReadChunk(r *bufio.Reader) (byte, []byte, error)

func WriteChunk

func WriteChunk(w io.Writer, typeCode byte, data []byte) error

Types

type Client

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

func NewClient

func NewClient(r io.Reader, w io.Writer) (*Client, error)

func (*Client) I2C

func (c *Client) I2C(cfg I2CConfig) i2c.Bus

func (*Client) Pin

func (c *Client) Pin(n int) driver.Pin

func (*Client) PinCount

func (c *Client) PinCount() int

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) SPI

func (c *Client) SPI(cfg SPIConfig) (spi.Controller, error)
type Header struct {
	Magic     byte
	Type      byte
	Length    uint32
	HeaderCRC uint32
	DataCRC   uint32
}

func (*Header) CRC

func (h *Header) CRC() uint32

type I2CConfig

type I2CConfig struct {
	SDA, SCL uint8
}

type Request

type Request struct {
	Cmd uint8 `json:"c,omitempty"`

	Pin   uint8 `json:"p,omitempty"`
	State bool  `json:"s,omitempty"`

	I2CAddr  uint16 `json:"a,omitempty"`
	DataByte byte   `json:"b,omitempty"`
	ReadN    uint16 `json:"n,omitempty"`

	Data []byte `json:"d,omitempty"`

	I2CConfig *I2CConfig `json:"i2c,omitempty"`
	SPIConfig *SPIConfig `json:"spi,omitempty"`
}

type Response

type Response struct {
	Err      string `json:"e,omitempty"`
	State    bool   `json:"s,omitempty"`
	PinCount uint8  `json:"n,omitempty"`
	DataByte byte   `json:"b,omitempty"`
	Data     []byte `json:"d,omitempty"`
}

type SPIConfig

type SPIConfig struct {
	Mode uint8
	Baud uint32

	MISO, MOSI, SCLK uint8
}

type Server

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

func NewServer

func NewServer(r io.Reader, w io.Writer, dev driver.Pinner) *Server

func (*Server) Serve

func (s *Server) Serve() error

Jump to

Keyboard shortcuts

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