nx_crc16.nx
buildroot/runtime/nx_crc16.nx
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
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
structs
| none |
consts
| 31 | const CR_POLY_CCITT: i64 = 0x1021 |
| 32 | const CR_POLY_IBM: i64 = 0x8005 |
| 33 | const CR_INIT_FFFF: i64 = 0xFFFF |
| 34 | const CR_INIT_0000: i64 = 0x0000 |
| 35 | const CR_U16_MASK: i64 = 0xFFFF |
functions
| 38 | func crc16_reflect8(b: i64) -> i64 |
| 51 | func crc16_reflect16(x: i64) -> i64 |
| 65 | func crc16_ccitt(bytes: *u8, n: i64) -> i64 called by 1: main |
| 87 | func crc16_modbus(bytes: *u8, n: i64) -> i64 called by 1: main |
| 108 | func main() -> i64 |