Documentation
¶
Overview ¶
Package linecode decodes raw line-code bitstreams into the data bits they carry. It is the reverse-engineering layer between a raw capture and the protocol decoders: when bringing up a decoder for an unknown OOK/FSK or RFID bitstream, "is this Manchester, and if so what's the data?" is a constant first question, and doing it by hand is error-prone.
Wrap-vs-native judgement ¶
Native. Manchester is a fixed bi-phase mapping over bit pairs; decoding is a pair walk with a validity check. The project already does this inline inside several protocol decoders (em4100, z-wave, m-bus, weather, tpms); this exposes it as a reusable RE primitive.
Verifiable / no confidently-wrong output ¶
Valid Manchester contains only the bit pairs 01 and 10 — a 00 or 11 pair is illegal — so a non-Manchester (or mis-aligned) stream is flagged by its invalid pairs rather than mis-decoded. The two naming conventions (IEEE 802.3 and G.E. Thomas) invert each other, an ambiguity that cannot be resolved from the bits alone, so BOTH decodes are returned and the operator (who knows the protocol) picks — never a silent guess. Both bit alignments (starting at bit 0 or skipping a leading half-bit) are tried, and the fully-valid alignment(s) are highlighted — the RE hint.
Covered / deferred ¶
Covered: standard Manchester, both conventions, both alignments, with a validity gate. Differential Manchester / biphase-mark-space (stateful) and NRZI are deliberately deferred.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeManchesterIEEE ¶
EncodeManchesterIEEE renders data bits as an IEEE-802.3 Manchester stream (0 -> "01", 1 -> "10") — the inverse of the IEEE column, for round-tripping.
Types ¶
type ManchesterCandidate ¶
type ManchesterCandidate struct {
Alignment int `json:"alignment"` // 0 = from the first bit, 1 = skipping a leading half-bit
Valid bool `json:"valid"` // all pairs were 01 or 10
InvalidPairs []int `json:"invalid_pairs,omitempty"`
IEEE8023 string `json:"ieee_802_3"` // 10->1, 01->0
Thomas string `json:"thomas"` // 01->1, 10->0 (G.E. Thomas)
}
ManchesterCandidate is one decode attempt at a given bit alignment.
type ManchesterResult ¶
type ManchesterResult struct {
InputBits int `json:"input_bits"`
Candidates []ManchesterCandidate `json:"candidates"`
Notes []string `json:"notes,omitempty"`
}
ManchesterResult holds the candidate decodes for both alignments.
func DecodeManchester ¶
func DecodeManchester(bits string) (*ManchesterResult, error)
DecodeManchester decodes a raw '0'/'1' bitstream as standard Manchester, trying both bit alignments and returning both convention mappings.