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 ¶
- Constants
- Variables
- type Capabilities
- type Compiled
- type DecodedRow
- type EncodedRow
- type InputError
- type Inspection
- type Issue
- type LED
- type Line
- type Placement
- type PlaybackFields
- type PlaybackInspection
- type PlaybackObservation
- type PlaybackPlan
- type PlaybackProfile
- type Range
- type Repeat
- type RowObservation
- type Sequence
- type Snapshot
Examples ¶
Constants ¶
const ( RAM = "ram" Flash = "flash" FirmwareMatched = "firmware-matched" ModelOnly = "model-only" Unresolved = "unresolved" Unknown = "unknown" )
const ( ExclusivePlaybackEnd = "exclusive" InclusivePlaybackEnd = "inclusive" )
const ( Contract = "nb1-device-sequence/draft-1" ColorSpace = "device-rgb8" MaxBytes = 65536 MaxLines = 32 TickMS = 10 WireMaxDurationMS = 65535 * TickMS )
const GIDStandardLayout = "gid-standard-report-id-slot/v1"
const MaxObservedReportBytes = 256
Variables ¶
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 ¶
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 EncodedRow ¶
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 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) UnmarshalJSON ¶
UnmarshalJSON accepts exactly the integer tokens 0, 1 and 2.
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 ¶
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 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 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 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"`
}