core

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: LGPL-3.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	VendorT1            = 0x534c
	ProductT1Firmware   = 0x0001
	VendorT2            = 0x1209
	ProductT2Bootloader = 0x53C0
	ProductT2Firmware   = 0x53C1
)

Variables

View Source
var (
	ErrWrongPrevSession = errors.New("wrong previous session")
	ErrSessionNotFound  = errors.New("session not found")
	ErrMalformedData    = errors.New("malformed data")
	ErrOtherCall        = errors.New("other call in progress")
)

Functions

This section is empty.

Types

type CallMode

type CallMode int
const (
	CallModeRead      CallMode = 0
	CallModeWrite     CallMode = 1
	CallModeReadWrite CallMode = 2
)

type Core

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

func New

func New(bus USBBus, log *memorywriter.MemoryWriter, allowStealing, reset bool) *Core

func (*Core) Acquire

func (c *Core) Acquire(
	path, prev string,
	debug bool,
) (string, error)

func (*Core) Call

func (c *Core) Call(
	body []byte,
	session string,
	mode CallMode,
	debug bool,
	ctx context.Context,
) ([]byte, error)

func (*Core) Enumerate

func (c *Core) Enumerate() ([]EnumerateEntry, error)

func (*Core) Listen

func (c *Core) Listen(entries []EnumerateEntry, ctx context.Context) ([]EnumerateEntry, error)

func (*Core) Release

func (c *Core) Release(session string, debug bool) error

type DeviceType

type DeviceType int
const (
	TypeT1Hid        DeviceType = 0
	TypeT1Webusb     DeviceType = 1
	TypeT1WebusbBoot DeviceType = 2
	TypeT2           DeviceType = 3
	TypeT2Boot       DeviceType = 4
	TypeEmulator     DeviceType = 5
)

type EnumerateEntries

type EnumerateEntries []EnumerateEntry

func (EnumerateEntries) Len

func (entries EnumerateEntries) Len() int

func (EnumerateEntries) Less

func (entries EnumerateEntries) Less(i, j int) bool

func (EnumerateEntries) Sort

func (entries EnumerateEntries) Sort()

func (EnumerateEntries) Swap

func (entries EnumerateEntries) Swap(i, j int)

type EnumerateEntry

type EnumerateEntry struct {
	Path    string     `json:"path"`
	Vendor  int        `json:"vendor"`
	Product int        `json:"product"`
	Type    DeviceType `json:"-"`     // used only in status page, not in JSON
	Debug   bool       `json:"debug"` // has debug enabled?

	Session      *string `json:"session"`
	DebugSession *string `json:"debugSession"`
}

type USBBus

type USBBus interface {
	Enumerate() ([]USBInfo, error)
	Connect(
		path string,
		debug bool,
		reset bool,
	) (USBDevice, error)
	Has(path string) bool

	Close() // called on program exit
}

type USBDevice

type USBDevice interface {
	io.ReadWriter
	Close(disconnected bool) error
}

type USBInfo

type USBInfo struct {
	Path      string
	VendorID  int
	ProductID int
	Type      DeviceType
	Debug     bool // has debug enabled?
}

Jump to

Keyboard shortcuts

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