code wiki / (root) / nx_crc16.nx

nx_crc16.nx

buildroot/runtime/nx_crc16.nx

3327 B115 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

crc16.nx -- CRC-16 variants (CCITT, IBM, MODBUS). Used by serial / wire protocols where 16-bit checksums are adequate (link-layer error detection). Three common variants shipped: CCITT-FALSE (poly 0x1021, init 0xFFFF, no reflection) Used by: XMODEM, MAVLink, DNP3, Bluetooth HCI IBM (poly 0x8005, init 0x0000, reflected) Used by: Modbus RTU, USB token CRC, ISO/IEC 13239 MODBUS (poly 0x8005, init 0xFFFF, reflected) Used by: Modbus serial framing All NOT cryptographic. Burst-error detection only. Invariants: CR1 Pure functions; no global state; deterministic. CR2 Result fits in low 16 bits of i64. CR3 Bit-by-bit implementation (no 256-entry table) -- slower than tabulated variants but ~50 LoC instead of 50 LoC + 256-byte data + per-variant table.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_crc16.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main crc16_ccitt crc16_modbus

structs

none

consts

31const CR_POLY_CCITT: i64 = 0x1021
32const CR_POLY_IBM: i64 = 0x8005
33const CR_INIT_FFFF: i64 = 0xFFFF
34const CR_INIT_0000: i64 = 0x0000
35const CR_U16_MASK: i64 = 0xFFFF

functions

38func crc16_reflect8(b: i64) -> i64
51func crc16_reflect16(x: i64) -> i64
65func crc16_ccitt(bytes: *u8, n: i64) -> i64
called by 1: main
87func crc16_modbus(bytes: *u8, n: i64) -> i64
called by 1: main
108func main() -> i64