usart

package
v0.0.0-...-fa7f932 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package usart implements a framing protocol for messages sent over UART.

Index

Constants

This section is empty.

Variables

View Source
var ErrEndpointUnavailable = errors.New("endpoint not available")

ErrEndpointUnavailable is returned if the device returns an endpoint error, which means we are talking to the wrong endpoint (firmware vs. bootloader).

Functions

This section is empty.

Types

type Communication

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

Communication implements a framing protocol for messages sent over UART.

func NewCommunication

func NewCommunication(
	device io.ReadWriteCloser,
	cmd byte,
) *Communication

NewCommunication creates a new Communication. cmd is the U2F CMD byte which is sent and which is expected in responses.

func (*Communication) Close

func (communication *Communication) Close()

Close closes the underlying device.

func (*Communication) Query

func (communication *Communication) Query(request []byte) ([]byte, error)

Query sends a request and waits for the response. Blocking.

func (*Communication) ReadFrame

func (communication *Communication) ReadFrame() ([]byte, error)

ReadFrame reads a message encoded in a usart frame.

func (*Communication) SendFrame

func (communication *Communication) SendFrame(msg []byte) error

SendFrame sends one message enclosed in a usart frame.

Jump to

Keyboard shortcuts

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