readers

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeDriverID added in v2.7.0

func NormalizeDriverID(id string) string

NormalizeDriverID removes underscores from driver IDs to provide backwards compatibility with the legacy underscore format (e.g., "simple_serial"). This allows both "simple_serial" and "simpleserial" to work interchangeably.

Types

type Capability

type Capability string
const (
	CapabilityWrite   Capability = "write"
	CapabilityDisplay Capability = "display"
)

type DriverMetadata

type DriverMetadata struct {
	ID                string
	Description       string
	DefaultEnabled    bool
	DefaultAutoDetect bool
}

type Reader

type Reader interface {
	// Metadata returns static configuration for this driver.
	Metadata() DriverMetadata
	// IDs returns the device string prefixes supported by this reader.
	IDs() []string
	// Open any necessary connections to the device and start polling.
	// Takes a device connection string and a channel to send scanned tokens.
	Open(config.ReadersConnect, chan<- Scan) error
	// Close any open connections to the device and stop polling.
	Close() error
	// Detect attempts to search for a connected device and returns the device
	// connection string. If no device is found, an empty string is returned.
	// Takes a list of currently connected device strings.
	Detect([]string) string
	// Device returns the device connection string.
	Device() string
	// Connected returns true if the device is connected and active.
	Connected() bool
	// Info returns a string with information about the connected device.
	Info() string
	// Write sends a string to the device to be written to a token, if
	// that device supports writing. Blocks until completion or timeout.
	Write(string) (*tokens.Token, error)
	// CancelWrite sends a request to cancel an active write request.
	CancelWrite()
	// Capabilities returns the list of capabilities supported by this reader.
	Capabilities() []Capability
	// OnMediaChange is called when the active media changes.
	OnMediaChange(*models.ActiveMedia) error
}

type Scan

type Scan struct {
	Error       error
	Token       *tokens.Token
	Source      string
	ReaderError bool // True when Token is nil due to reader error/disconnect vs normal token removal
}

Directories

Path Synopsis
shared
Package testutils provides common testing utilities for reader tests.
Package testutils provides common testing utilities for reader tests.

Jump to

Keyboard shortcuts

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