core

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithArduinoCli added in v2.3.0

func WithArduinoCli(arduinoCli cli.Cli) func(c *ArdiCore)

WithArduinoCli allows an injectable arduino cli interface

Types

type ArdiConfig

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

ArdiConfig represents core module for ardi.json manipulation

func NewArdiConfig

func NewArdiConfig(confPath string, initialConfig types.ArdiConfig, logger *log.Logger) *ArdiConfig

NewArdiConfig returns core json module for handling ardi.json config

func (*ArdiConfig) AddBoardURL

func (a *ArdiConfig) AddBoardURL(url string) error

AddBoardURL to ardi.json

func (*ArdiConfig) AddBuild

func (a *ArdiConfig) AddBuild(name, sketch, fqbn string, baud int, buildProps []string) error

AddBuild to ardi.json

func (*ArdiConfig) AddLibrary

func (a *ArdiConfig) AddLibrary(name, version string) error

AddLibrary to ardi.json

func (*ArdiConfig) AddPlatform

func (a *ArdiConfig) AddPlatform(platform, version string) error

AddPlatform to ardi.json

func (*ArdiConfig) GetBoardURLS

func (a *ArdiConfig) GetBoardURLS() []string

GetBoardURLS returns board urls specified in config

func (*ArdiConfig) GetBuilds

func (a *ArdiConfig) GetBuilds() map[string]types.ArdiBuild

GetBuilds returns builds specified in config

func (*ArdiConfig) GetCompileOpts

func (a *ArdiConfig) GetCompileOpts(buildName string) (*cli.CompileOpts, error)

GetCompileOpts returns appropriate compile options for an ardi build

func (*ArdiConfig) GetLibraries

func (a *ArdiConfig) GetLibraries() map[string]string

GetLibraries returns libraries specired in config

func (*ArdiConfig) GetPlatforms

func (a *ArdiConfig) GetPlatforms() map[string]string

GetPlatforms returns platforms specified in config

func (*ArdiConfig) ListBoardURLS

func (a *ArdiConfig) ListBoardURLS()

ListBoardURLS lists all board urls in config

func (*ArdiConfig) ListBuilds

func (a *ArdiConfig) ListBuilds(builds []string)

ListBuilds lists build specifications in ardi.json

func (*ArdiConfig) ListLibraries

func (a *ArdiConfig) ListLibraries()

ListLibraries lists installed libraries

func (*ArdiConfig) ListPlatforms

func (a *ArdiConfig) ListPlatforms()

ListPlatforms lists all board urls in config

func (*ArdiConfig) RemoveBoardURL

func (a *ArdiConfig) RemoveBoardURL(url string) error

RemoveBoardURL from ardi.json

func (*ArdiConfig) RemoveBuild

func (a *ArdiConfig) RemoveBuild(build string) error

RemoveBuild removes specified build from ardi.json

func (*ArdiConfig) RemoveLibrary

func (a *ArdiConfig) RemoveLibrary(name string) error

RemoveLibrary from ardi.json

func (*ArdiConfig) RemovePlatform

func (a *ArdiConfig) RemovePlatform(platform string) error

RemovePlatform from ardi.json

type ArdiCore

type ArdiCore struct {
	Cli       *cli.Wrapper
	Config    *ArdiConfig
	CliConfig *ArdiYAML
	Watcher   *WatchCore
	Board     *BoardCore
	Compiler  *CompileCore
	Uploader  *UploadCore
	Lib       *LibCore
	Platform  *PlatformCore
	// contains filtered or unexported fields
}

ArdiCore represents the core package of ardi

func NewArdiCore

func NewArdiCore(opts NewArdiCoreOpts, options ...ArdiCoreOption) *ArdiCore

NewArdiCore returns a new ardi core

func (*ArdiCore) GetBaudFromArgs added in v2.3.0

func (c *ArdiCore) GetBaudFromArgs(baudArg int, args []string) int

GetBaudFromArgs return baud rate from the given args

func (*ArdiCore) GetCompileOptsFromArgs added in v2.3.0

func (c *ArdiCore) GetCompileOptsFromArgs(fqbn string, buildProps []string, showProps bool, args []string) ([]*cli.CompileOpts, error)

GetCompileOptsFromArgs return a list of compile opts from the given args

func (*ArdiCore) GetSketchPathsFromArgs added in v2.3.0

func (c *ArdiCore) GetSketchPathsFromArgs(args []string) (string, string, error)

GetSketchPathsFromArgs returns sketchDir and sketchPath from given args

type ArdiCoreOption added in v2.3.0

type ArdiCoreOption = func(c *ArdiCore)

ArdiCoreOption represents options for ArdiCore

func WithCoreSerialPortManager added in v2.3.0

func WithCoreSerialPortManager(port SerialPort) ArdiCoreOption

WithCoreSerialPortManager allows an injectable serial port interface

type ArdiSerialPort

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

ArdiSerialPort represents our serial port wrapper

func (*ArdiSerialPort) Close added in v2.3.0

func (p *ArdiSerialPort) Close()

Close closees serial port logger

func (*ArdiSerialPort) SetTargets added in v2.3.0

func (p *ArdiSerialPort) SetTargets(device string, baud int)

SetTargets sets the device and baud targets

func (*ArdiSerialPort) Streaming added in v2.3.0

func (p *ArdiSerialPort) Streaming() bool

Streaming returns whether or not we are attached to the port and streaming logs

func (*ArdiSerialPort) Watch

func (p *ArdiSerialPort) Watch() error

Watch connects to a serial port and prints any logs received.

type ArdiYAML

type ArdiYAML struct {
	Config types.ArduinoCliSettings
	// contains filtered or unexported fields
}

ArdiYAML represents core module for data config file manipulations

func NewArdiYAML

func NewArdiYAML(confPath string, initalConfig types.ArduinoCliSettings) *ArdiYAML

NewArdiYAML returns core yaml module for handling data config file

func (*ArdiYAML) AddBoardURL

func (a *ArdiYAML) AddBoardURL(url string) error

AddBoardURL add a board url to data config file

func (*ArdiYAML) RemoveBoardURL

func (a *ArdiYAML) RemoveBoardURL(url string) error

RemoveBoardURL remove a board url from data config file

type BoardCore

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

BoardCore module for board commands

func NewBoardCore

func NewBoardCore(logger *log.Logger, options ...BoardCoreOption) *BoardCore

NewBoardCore module instance for board commands

func (*BoardCore) FQBNS

func (c *BoardCore) FQBNS(query string) error

FQBNS lists all available boards with associated fqbns

func (*BoardCore) Platforms

func (c *BoardCore) Platforms(query string) error

Platforms lists all available boards with associated platorms

type BoardCoreOption added in v2.3.0

type BoardCoreOption = func(c *BoardCore)

BoardCoreOption represents options for the BoardCore

func WithBoardCliWrapper added in v2.3.0

func WithBoardCliWrapper(wrapper *cli.Wrapper) BoardCoreOption

WithBoardCliWrapper allows an injectable cli wrapper

type CompileCore

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

CompileCore represents core module for compile commands

func NewCompileCore

func NewCompileCore(logger *log.Logger, options ...CompileCoreOption) *CompileCore

NewCompileCore instance of core module for compile commands

func (*CompileCore) Compile

func (c *CompileCore) Compile(opts cli.CompileOpts) error

Compile compiles a given project sketch

func (*CompileCore) IsCompiling

func (c *CompileCore) IsCompiling() bool

IsCompiling returns if core is currently compiling

func (*CompileCore) StopWatching added in v2.3.0

func (c *CompileCore) StopWatching()

StopWatching stop watching for file changes

func (*CompileCore) WatchForChanges

func (c *CompileCore) WatchForChanges(opts cli.CompileOpts) error

WatchForChanges watches sketch for changes and recompiles

type CompileCoreOption added in v2.3.0

type CompileCoreOption = func(c *CompileCore)

CompileCoreOption represents options for the CompileCore

func WithCompileCoreCliWrapper added in v2.3.0

func WithCompileCoreCliWrapper(cliWrapper *cli.Wrapper) CompileCoreOption

WithCompileCoreCliWrapper allows an injectable cli wrapper

type FileWatcher

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

FileWatcher watches sketch files for changes and runs user defined actions

func NewFileWatcher

func NewFileWatcher(file string, logger *log.Logger) (*FileWatcher, error)

NewFileWatcher returns a new sketch watcher instance

func (*FileWatcher) AddListener

func (f *FileWatcher) AddListener(l Listener)

AddListener adds an action to run on file change

func (*FileWatcher) Close

func (f *FileWatcher) Close()

Close fully closes file watcher (cannot be restarted)

func (*FileWatcher) Restart

func (f *FileWatcher) Restart()

Restart restarts the file watcher after being stopped

func (*FileWatcher) Stop

func (f *FileWatcher) Stop()

Stop stops the os watcher

func (*FileWatcher) Watch

func (f *FileWatcher) Watch() error

Watch watches the file for changes and runs user defined actions

type LibCore

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

LibCore core module for lib commands

func NewLibCore

func NewLibCore(logger *log.Logger, options ...LibCoreOption) *LibCore

NewLibCore Lib instance

func (*LibCore) Add

func (c *LibCore) Add(lib string) (string, string, error)

Add library for project

func (*LibCore) ListInstalled

func (c *LibCore) ListInstalled() error

ListInstalled lists all installed libraries

func (*LibCore) Remove

func (c *LibCore) Remove(library string) error

Remove library from project

func (*LibCore) Search

func (c *LibCore) Search(searchArg string) error

Search all available libraries with optional search filter

type LibCoreOption added in v2.3.0

type LibCoreOption = func(c *LibCore)

LibCoreOption represents options for LibCore

func WithLibCliWrapper added in v2.3.0

func WithLibCliWrapper(wrapper *cli.Wrapper) LibCoreOption

WithLibCliWrapper allows an injectable cli wrapper

type Listener

type Listener = func()

Listener represents and action to run on file change

type NewArdiCoreOpts

type NewArdiCoreOpts struct {
	ArdiConfig         types.ArdiConfig
	ArduinoCliSettings types.ArduinoCliSettings
	CliSettingsPath    string
	Logger             *log.Logger
	Ctx                context.Context
}

NewArdiCoreOpts options fore creating new ardi core

type PlatformCore

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

PlatformCore module for platform commands

func NewPlatformCore

func NewPlatformCore(logger *log.Logger, options ...PlatformCoreOption) *PlatformCore

NewPlatformCore platform module instance

func (*PlatformCore) Add

func (c *PlatformCore) Add(platform string) (string, string, error)

Add installs specified platforms

func (*PlatformCore) ListAll

func (c *PlatformCore) ListAll() error

ListAll lists all available platforms

func (*PlatformCore) ListInstalled

func (c *PlatformCore) ListInstalled() error

ListInstalled lists only installed platforms

func (*PlatformCore) Remove

func (c *PlatformCore) Remove(platform string) (string, error)

Remove uninstalls specified platforms

type PlatformCoreOption added in v2.3.0

type PlatformCoreOption = func(c *PlatformCore)

PlatformCoreOption represents options for PlatformCore

func WithPlatformCliWrapper added in v2.3.0

func WithPlatformCliWrapper(wrapper *cli.Wrapper) PlatformCoreOption

WithPlatformCliWrapper allows and injectable cli wrapper

type SerialPort

type SerialPort interface {
	SetTargets(d string, b int)
	Watch() error
	Close()
	Streaming() bool
}

SerialPort represents a board port on which to stream logs

func NewArdiSerialPort

func NewArdiSerialPort(logger *log.Logger) SerialPort

NewArdiSerialPort returns instance of serial port wrapper

type UploadCore

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

UploadCore represents core module for ardi upload commands

func NewUploadCore

func NewUploadCore(logger *log.Logger, options ...UploadCoreOption) *UploadCore

NewUploadCore returns new ardi upload core

func (*UploadCore) Attach

func (c *UploadCore) Attach()

Attach attaches to the associated board port and prints logs

func (*UploadCore) Detach added in v2.3.0

func (c *UploadCore) Detach()

Detach detaches from the associated board port

func (*UploadCore) IsUploading

func (c *UploadCore) IsUploading() bool

IsUploading returns whether or not core is currently uploading

func (*UploadCore) SetPortTargets added in v2.3.0

func (c *UploadCore) SetPortTargets(device string, baud int)

SetPortTargets sets the device and baud for the port manager

func (*UploadCore) Upload

func (c *UploadCore) Upload(board *cli.BoardWithPort, buildDir string) error

Upload compiled sketches to the specified board

type UploadCoreOption added in v2.3.0

type UploadCoreOption = func(c *UploadCore)

UploadCoreOption reprents options for UploadCore

func WithUploadCoreCliWrapper added in v2.3.0

func WithUploadCoreCliWrapper(wrapper *cli.Wrapper) UploadCoreOption

WithUploadCoreCliWrapper allows an injectable cli wrapper

func WithUploaderSerialPortManager added in v2.3.0

func WithUploaderSerialPortManager(portManager SerialPort) UploadCoreOption

WithUploaderSerialPortManager allows and injectable serial port manager

type WatchCore

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

WatchCore represents core module for adi go commands

func NewWatchCore

func NewWatchCore(logger *log.Logger, options ...WatchCoreOption) *WatchCore

NewWatchCore returns new Project instance

func (*WatchCore) SetTargets

func (w *WatchCore) SetTargets(targets WatchCoreTargets) error

SetTargets sets the board and compile options for the watcher

func (*WatchCore) Stop

func (w *WatchCore) Stop()

Stop deletes watcher and unattaches from port

func (*WatchCore) Watch

func (w *WatchCore) Watch() error

Watch responds to changes in a given sketch file by automatically recompiling and re-uploading.

type WatchCoreOption added in v2.3.0

type WatchCoreOption = func(c *WatchCore)

WatchCoreOption represents options for WatchCore

func WithWatchCoreCompiler added in v2.3.0

func WithWatchCoreCompiler(compiler *CompileCore) WatchCoreOption

WithWatchCoreCompiler allows an injectable CompileCore

func WithWatchCoreUploader added in v2.3.0

func WithWatchCoreUploader(uploader *UploadCore) WatchCoreOption

WithWatchCoreUploader allows an injectable UploadCore

type WatchCoreTargets

type WatchCoreTargets struct {
	Board       *cli.BoardWithPort
	CompileOpts *cli.CompileOpts
	Baud        int
}

WatchCoreTargets targets for watching, recompiling, and reuploading

Jump to

Keyboard shortcuts

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