fdxb

package
v0.662.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fdxb decodes the ISO 11784/11785 FDX-B data block — the 134.2 kHz LF transponder format used by animal / pet microchips (and many "biothermo" and asset transponders). It recovers the country code, the 38-bit national identification number, the application flags, and validates the CRC-16.

Input is the *de-stuffed* FDX-B data block (the bytes a demodulator such as Proxmark3's `lf fdxb` emits as the raw ID block) — MSB-first within each byte. The on-air framing (the 11-bit preamble and the control '1' inserted after every 8 data bits) is the demodulator's concern and is deliberately out of scope here: this package decodes the data block, not the raw RF bitstream, so its output is deterministic and independently verifiable.

Layout of the 104-bit data block (all multi-bit fields are LSB-first, the FDX-B convention):

bits   0..37   national code (38 bits)
bits  38..47   country code (10 bits)
bit   48       data-block-status flag (1 => 24-bit extended block present)
bit   49       animal-application flag
bits  50..63   reserved
bits  64..79   CRC-16 (over the first 8 bytes / 64 bits)
bits  80..103  extended data block (24 bits)

Wrap-vs-native: native. The decode is fixed bit/byte extraction plus a CRC-16; no third-party dependency is warranted. The field layout, the LSB-first bit order, and the CRC-16 parameters (CCITT polynomial 0x1021, init 0x0000, refin=false, refout=true, over the first 8 bytes) are taken from the Proxmark3 reference (common/crc16.c crc16_fdxb + client cmdlffdxb.c) and were verified byte-for-byte against two real decoded tags: country 528 / national 140000795552 (raw ID 05 D9 4D 19 04 21 00 01) and country 999 / national 1500030037 (CRC 0x8A1C) — not recalled.

No confidently-wrong output: the CRC-16 is the integrity gate (the national and country codes are double-anchored and the computed CRC reproduces a published vector). The animal flag (bit 49, per the priority1design FDX-B reference) is surfaced as a secondary field and the reserved / extended bits are surfaced raw — a frame whose CRC fails is reported as such, never asserted as a real tag.

Deferred: a full ISO-3166 country-code → name table (the numeric code is surfaced, with a note when it falls in the 900-999 manufacturer/test range); the semantics of the 24-bit extended data block (vendor-specific).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FDXB

type FDXB struct {
	NationalCode      uint64   `json:"national_code"`
	CountryCode       int      `json:"country_code"`
	CountryNote       string   `json:"country_note,omitempty"`
	AnimalApplication bool     `json:"animal_application"`
	DataBlockPresent  bool     `json:"data_block_present"`
	IDBlockHex        string   `json:"id_block_hex"`
	CRCComputed       string   `json:"crc16_computed"`
	CRCStored         string   `json:"crc16_stored,omitempty"`
	CRCValid          *bool    `json:"crc16_valid,omitempty"`
	ExtendedHex       string   `json:"extended_data_hex,omitempty"`
	Notes             []string `json:"notes,omitempty"`
}

FDXB is a decoded FDX-B data block.

func Decode

func Decode(b []byte) (*FDXB, error)

Decode decodes an FDX-B data block: at least the 8-byte ID block; 10 bytes to additionally validate the CRC-16; 13 bytes to additionally surface the extended data block.

func DecodeHex

func DecodeHex(s string) (*FDXB, error)

DecodeHex decodes a hex-encoded FDX-B data block. ':' / '-' / '_' / whitespace separators are ignored.

Jump to

Keyboard shortcuts

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