discovery

package
v0.35.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Alive int = iota
	Idling
	Running
	Syncing
	Dead
)

To work correctly a Pluggable Discovery must respect the state machine specified on the documentation: https://arduino.github.io/arduino-cli/latest/pluggable-discovery-specification/#state-machine States a PluggableDiscovery can be in

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type        string
	Port        *Port
	DiscoveryID string
}

Event is a pluggable discovery event

type PluggableDiscovery

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

PluggableDiscovery is a tool that detects communication ports to interact with the boards.

func New

func New(id string, args ...string) *PluggableDiscovery

New create and connect to the given pluggable discovery

func (*PluggableDiscovery) GetID

func (disc *PluggableDiscovery) GetID() string

GetID returns the identifier for this discovery

func (*PluggableDiscovery) List

func (disc *PluggableDiscovery) List() ([]*Port, error)

List executes an enumeration of the ports and returns a list of the available ports at the moment of the call.

func (*PluggableDiscovery) Quit

func (disc *PluggableDiscovery) Quit()

Quit terminates the discovery. No more commands can be accepted by the discovery.

func (*PluggableDiscovery) Run

func (disc *PluggableDiscovery) Run() (err error)

Run starts the discovery executable process and sends the HELLO command to the discovery to agree on the pluggable discovery protocol. This must be the first command to run in the communication with the discovery. If the process is started but the HELLO command fails the process is killed.

func (*PluggableDiscovery) Start

func (disc *PluggableDiscovery) Start() error

Start initializes and start the discovery internal subroutines. This command must be called before List or StartSync.

func (*PluggableDiscovery) StartSync

func (disc *PluggableDiscovery) StartSync(size int) (<-chan *Event, error)

StartSync puts the discovery in "events" mode: the discovery will send "add" and "remove" events each time a new port is detected or removed respectively. After calling StartSync an initial burst of "add" events may be generated to report all the ports available at the moment of the start. It also creates a channel used to receive events from the pluggable discovery. The event channel must be consumed as quickly as possible since it may block the discovery if it becomes full. The channel size is configurable.

func (*PluggableDiscovery) State

func (disc *PluggableDiscovery) State() int

State returns the current state of this PluggableDiscovery

func (*PluggableDiscovery) Stop

func (disc *PluggableDiscovery) Stop() error

Stop stops the discovery internal subroutines and possibly free the internally used resources. This command should be called if the client wants to pause the discovery for a while.

func (*PluggableDiscovery) String

func (disc *PluggableDiscovery) String() string

type Port

type Port struct {
	Address       string          `json:"address"`
	AddressLabel  string          `json:"label"`
	Protocol      string          `json:"protocol"`
	ProtocolLabel string          `json:"protocolLabel"`
	HardwareID    string          `json:"hardwareId,omitempty"`
	Properties    *properties.Map `json:"properties"`
}

Port contains metadata about a port to connect to a board.

func PortFromRPCPort

func PortFromRPCPort(o *rpc.Port) (p *Port)

PortFromRPCPort converts an *rpc.Port to a *Port

func (*Port) Clone

func (p *Port) Clone() *Port

Clone creates a copy of this Port

func (*Port) Equals

func (p *Port) Equals(o *Port) bool

Equals returns true if the given port has the same address and protocol of the current port.

func (*Port) String

func (p *Port) String() string

func (*Port) ToRPC

func (p *Port) ToRPC() *rpc.Port

ToRPC converts Port into rpc.Port

Directories

Path Synopsis
discovery_client is a command line UI client to test pluggable discoveries.
discovery_client is a command line UI client to test pluggable discoveries.

Jump to

Keyboard shortcuts

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