devicesequence

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package devicesequence models the draft device-native row language. It only parses and inspects caller-owned data; it has no transport or execution path.

Index

Examples

Constants

View Source
const (
	RAM             = "ram"
	Flash           = "flash"
	FirmwareMatched = "firmware-matched"
	ModelOnly       = "model-only"
	Unresolved      = "unresolved"
	Unknown         = "unknown"
)
View Source
const (
	ExclusivePlaybackEnd = "exclusive"
	InclusivePlaybackEnd = "inclusive"
)
View Source
const (
	Contract          = "nb1-device-sequence/draft-1"
	ColorSpace        = "device-rgb8"
	MaxBytes          = 65536
	MaxLines          = 32
	TickMS            = 10
	WireMaxDurationMS = 65535 * TickMS
)
View Source
const GIDStandardLayout = "gid-standard-report-id-slot/v1"
View Source
const MaxObservedReportBytes = 256

Variables

View Source
var ErrInvalid = errors.New("invalid device sequence")

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Model             string `json:"model"`
	Firmware          int    `json:"firmware"`
	ReferenceFirmware int    `json:"reference_firmware"`
	Applicability     string `json:"applicability"`
	RAMLines          *int   `json:"ram_lines"`
	FlashLines        *int   `json:"flash_lines"`
	UsableFlashLines  *int   `json:"usable_flash_lines"`
	// Nil means the firmware fader's applicable duration bound is unresolved.
	MaxDurationMS *int     `json:"max_duration_ms"`
	Sources       []string `json:"sources"`
}

Capabilities is trusted, server-supplied reference data, never an author JSON field. An SDK/provider adapter will supply it; this package has no hardware database, device resolver or qualification registry. Sources remain evidence, not proof of the actual firmware image or permission to write.

type Compiled

type Compiled struct {
	Sequence Sequence `json:"sequence"`
	Digest   string   `json:"sequence_digest"`
	// Exact input bytes are caller-owned; normalization never overwrites them.
	OriginalJSON json.RawMessage `json:"-"`
}

func CompileJSON

func CompileJSON(data []byte) (Compiled, error)

CompileJSON accepts only the independent author sequence. Target memory, repeat, startup, initial, on_finish and separate fade/hold are not its fields.

Example
result, err := CompileJSON([]byte(`{"contract":"nb1-device-sequence/draft-1","color_space":"device-rgb8","lines":[{"led":0,"color":"red","duration_ms":500}]}`))
if err != nil {
	panic(err)
}
fmt.Println(result.Sequence.Lines[0].Color, result.Sequence.Lines[0].DurationMS)
Output:
#ff0000 500

type DecodedRow

type DecodedRow struct {
	Position      int     `json:"position"`
	LEDCode       byte    `json:"led_code"`
	RGB8          [3]byte `json:"rgb8"`
	DurationTicks uint16  `json:"duration_ticks"`
}

type EncodedRow

type EncodedRow struct {
	Position      int     `json:"position"`
	LEDCode       byte    `json:"led_code"`
	RGB8          [3]byte `json:"rgb8"`
	DurationTicks uint16  `json:"duration_ticks"`
}

type InputError

type InputError struct{ Issue }

func (*InputError) Error

func (e *InputError) Error() string

func (*InputError) Unwrap

func (e *InputError) Unwrap() error

type Inspection

type Inspection struct {
	Snapshot         Snapshot     `json:"snapshot"`
	Consistency      string       `json:"consistency"`
	DecodedRows      []DecodedRow `json:"decoded_rows"`
	MissingPositions []int        `json:"missing_positions"`
	Sequence         *Sequence    `json:"sequence"`
	SequenceDigest   *string      `json:"sequence_digest"`
	DecodingStatus   string       `json:"decoding_status"`
	Deployable       bool         `json:"deployable"`
	Issues           []Issue      `json:"issues"`
}

func InspectSnapshot

func InspectSnapshot(input Snapshot) (Inspection, error)

InspectSnapshot preserves raw observations before author validation. A complete raw snapshot can contain unrepresentable zero-time or special rows. Partial/error/unknown-layout observations never produce a complete sequence. No read, import, replay or device operation takes place here.

Example
result, err := InspectSnapshot(Snapshot{RequestedRange: Range{0, 1}, Complete: true, Rows: []RowObservation{{Position: 0, Layout: GIDStandardLayout, ReadAttempted: true, ReturnedLength: 8, Response: []byte{1, 'R', 0, 0, 0, 0, 0, 0}}}})
if err != nil {
	panic(err)
}
fmt.Println(result.Snapshot.Complete, result.Sequence == nil, result.DecodingStatus)
Output:
true true unrepresentable

type Issue

type Issue struct {
	Code    string `json:"code"`
	Path    string `json:"path"`
	Message string `json:"message"`
}

type LED

type LED byte

LED uses the same numeric channel selection in JSON and native rows. Zero selects all outputs; one and two select individual physical channels.

func (LED) MarshalJSON

func (led LED) MarshalJSON() ([]byte, error)

func (*LED) UnmarshalJSON

func (led *LED) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts exactly the integer tokens 0, 1 and 2.

type Line

type Line struct {
	LED        LED    `json:"led"`
	Color      string `json:"color"`
	DurationMS int    `json:"duration_ms"`
}

type Placement

type Placement struct {
	Contract               string       `json:"contract"`
	Target                 string       `json:"target"`
	SequenceDigest         string       `json:"sequence_digest"`
	ProfileDigest          string       `json:"profile_digest"`
	RequiredLines          int          `json:"required_lines"`
	AvailableLines         *int         `json:"available_lines"`
	PhysicalFlashLines     *int         `json:"physical_flash_lines"`
	EncodingStatus         string       `json:"encoding_status"`
	CapacityStatus         string       `json:"capacity_status"`
	FirmwareApplicability  string       `json:"firmware_applicability"`
	OperationQualification string       `json:"operation_qualification"`
	Deployable             bool         `json:"deployable"`
	Range                  *Range       `json:"range"`
	Rows                   []EncodedRow `json:"rows"`
	Issues                 []Issue      `json:"issues"`
}

func PlanPlacementJSON

func PlanPlacementJSON(data []byte, target string, start int, caps Capabilities) (Placement, error)

PlanPlacementJSON inspects addressability, encoding and target capacity. It does not plan a Flash commit or a playback range. It never emits HID reports. No hardware qualification registry/executor exists yet, so Deployable remains false even when the known encoding, capacity and reference firmware agree.

type PlaybackFields

type PlaybackFields struct {
	Mode         *byte `json:"mode"`
	Start        *byte `json:"start"`
	End          *byte `json:"end"`
	Count        *byte `json:"count"`
	NextPosition *byte `json:"next_position"`
}

type PlaybackInspection

type PlaybackInspection struct {
	Observation PlaybackObservation `json:"observation"`
	Complete    bool                `json:"complete"`
	Fields      PlaybackFields      `json:"raw_fields"`
	// ConfiguredRange describes registers, not an active job or lit row.
	ConfiguredRange *Range  `json:"configured_range"`
	ProfileDigest   string  `json:"profile_digest"`
	DecodingStatus  string  `json:"decoding_status"`
	Deployable      bool    `json:"deployable"`
	Issues          []Issue `json:"issues"`
}

func InspectPlayback

func InspectPlayback(input PlaybackObservation, profile PlaybackProfile) (PlaybackInspection, error)

InspectPlayback performs no reads or writes and does not manufacture a completed job, current row, repeat mode or visual completion from S bytes. Complete concerns the observation only, independently of its interpretation.

type PlaybackObservation

type PlaybackObservation struct {
	Layout         string `json:"layout"`
	ReadAttempted  bool   `json:"read_attempted"`
	ReturnedLength int    `json:"returned_length"`
	Response       []byte `json:"response"`
	ReadError      string `json:"read_error,omitempty"`
}

PlaybackObservation retains the reported GID prefix, not a USB wire capture. An error may accompany a valid prefix; it must remain visible to the caller.

type PlaybackPlan

type PlaybackPlan struct {
	ProfileDigest string `json:"profile_digest"`
	Range         Range  `json:"range"`
	Repeat        Repeat `json:"repeat"`
	// These are fields for an eventual adapter, not a ready-to-send report.
	InclusiveEnd  *int    `json:"inclusive_end"`
	WireCount     *byte   `json:"wire_count"`
	Representable bool    `json:"representable"`
	Deployable    bool    `json:"deployable"`
	Issues        []Issue `json:"issues"`
}

func PlanPlayback

func PlanPlayback(r Range, repeat Repeat, caps Capabilities) (PlaybackPlan, error)

PlanPlayback is separate from placement: uploading line0 is valid, while playing line0 alone is ambiguous in the historic p end=0 protocol.

type PlaybackProfile

type PlaybackProfile struct {
	Capabilities Capabilities `json:"capabilities"`
	EndEncoding  string       `json:"end_encoding"`
}

PlaybackProfile is trusted provider input, not an author or HTTP request. EndEncoding must come from reviewed firmware evidence, never model guessing. Matched reference source does not establish physical operation qualification.

type Range

type Range struct {
	StartLine int `json:"start_line"`
	LineCount int `json:"line_count"`
}

type Repeat

type Repeat struct {
	Mode  string `json:"mode"`
	Count *int   `json:"count,omitempty"`
}

type RowObservation

type RowObservation struct {
	Position       int    `json:"position"`
	Layout         string `json:"layout"`
	ReadAttempted  bool   `json:"read_attempted"`
	ReturnedLength int    `json:"returned_length"`
	Response       []byte `json:"response"`
	ReadError      string `json:"read_error,omitempty"`
}

RowObservation retains only bytes the transport says it returned. This is a GID buffer observation, not a claim to capture the physical USB transaction. Position is the requested absolute address, not inferred from response[7].

type Sequence

type Sequence struct {
	Contract   string `json:"contract"`
	ColorSpace string `json:"color_space"`
	Lines      []Line `json:"lines"`
}

type Snapshot

type Snapshot struct {
	RequestedRange Range `json:"requested_range"`
	// A false collector flag cannot be promoted to complete by the decoder.
	Complete bool             `json:"complete"`
	Rows     []RowObservation `json:"rows"`
}

Jump to

Keyboard shortcuts

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