serial

package
v0.0.0-...-88de618 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command byte

Command indicates the command that should be executed on the board to be provisioned.

const (
	SketchInfo Command = iota + 1
	CSR
	Locked
	GetLocked
	WriteCrypto
	BeginStorage
	SetDeviceID
	SetYear
	SetMonth
	SetDay
	SetHour
	SetValidity
	SetCertSerial
	SetAuthKey
	SetSignature
	EndStorage
	ReconstructCert
)

type MsgType

type MsgType byte

MsgType indicates the type of the packet.

const (
	None MsgType = iota
	Cmd
	Data
	Response
)

type Serial

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

Serial is a wrapper of serial port interface that features specific functions to send provisioning commands through the serial port to an arduino device.

func NewSerial

func NewSerial() *Serial

NewSerial instantiate and returns a Serial instance. The Serial Connect method should be called before using its send/receive functions.

func (*Serial) Close

func (s *Serial) Close() error

Close should be used when the Serial connection isn't used anymore. After that, Serial could Connect again to any port.

func (*Serial) Connect

func (s *Serial) Connect(address string) error

Connect tries to connect Serial to a specific serial port.

func (*Serial) Send

func (s *Serial) Send(ctx context.Context, cmd Command, payload []byte) error

Send allows to send a provisioning command to a connected arduino device.

func (*Serial) SendReceive

func (s *Serial) SendReceive(ctx context.Context, cmd Command, payload []byte) ([]byte, error)

SendReceive allows to send a provisioning command to a connected arduino device. Then, it waits for a response from the device and, if any, returns it. If no response is received after 2 seconds, an error is returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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