monitor

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 10 Imported by: 1

README

Pluggable Monitor Protocol Handler

Go Reference

This project is a library to ease implementation of pluggable discoveries for the Arduino CLI following the official specification.

Reference implementation

The dummy-monitor folder contains a reference pluggable monitor implementation.

Security

If you think you found a vulnerability or other security-related bug in this project, please read our security policy and report the bug to our Security Team 🛡️ Thank you!

e-mail contact: security@arduino.cc

License

Copyright (c) 2021 ARDUINO SA (www.arduino.cc)

The software is released under the GNU General Public License, which covers the main body of the serial-monitor code. The terms of this license can be found at: https://www.gnu.org/licenses/gpl-3.0.en.html

See LICENSE.txt for details.

Documentation

Overview

Package monitor is a library for handling the Arduino Pluggable-Monitor protocol (https://github.com/arduino/tooling-rfcs/blob/main/RFCs/0004-pluggable-monitor.md#pluggable-monitor-api-via-stdinstdout)

The library implements the state machine and the parsing logic to communicate with a pluggable-monitor client. All the commands issued by the client are conveniently translated into function calls, in particular the Monitor interface are the only functions that must be implemented to get a fully working pluggable monitor using this library.

A usage example is provided in the dummy-monitor package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor interface {
	// Hello is called once at startup to provide the userAgent string
	// and the protocolVersion negotiated with the client.
	Hello(userAgent string, protocolVersion int) error

	// Describe is called to obtain the description of the communication port
	Describe() (*PortDescriptor, error)

	// Configure allows to set the configuration parameters for the communication port
	Configure(parameterName string, value string) error

	// Open allows to open a communication with the board using TCP/IP
	Open(boardPort string) (io.ReadWriter, error)

	// Close will close the currently open port and TCP/IP connection
	Close() error

	// Quit is called just before the server terminates. This function can be
	// used by the monitor as a last chance to gracefully close resources.
	Quit()
}

Monitor is an interface that represents the business logic that a pluggable monitor must implement. The communication protocol is completely hidden and it's handled by a MonitorServer.

type PortDescriptor

type PortDescriptor struct {
	Protocol               string                              `json:"protocol,omitempty"`
	ConfigurationParameter map[string]*PortParameterDescriptor `json:"configuration_parameters,omitempty"`
}

PortDescriptor is a struct to describe the characteristic of a port

type PortParameterDescriptor

type PortParameterDescriptor struct {
	Label    string   `json:"label,omitempty"`
	Type     string   `json:"type,omitempty"`
	Values   []string `json:"value,omitempty"`
	Selected string   `json:"selected,omitempty"`
}

PortParameterDescriptor contains characteristics for every parameter

type Server

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

A Server is a pluggable monitor protocol handler, it must be created using the NewServer function.

func NewServer

func NewServer(impl Monitor) *Server

NewServer creates a new monitor server backed by the provided pluggable monitor implementation. To start the server use the Run method.

func (*Server) Run

func (d *Server) Run(in io.Reader, out io.Writer) error

Run starts the protocol handling loop on the given input and output stream, usually `os.Stdin` and `os.Stdout` are used. The function blocks until the `QUIT` command is received or the input stream is closed. In case of IO error the error is returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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