Phase 1 of package refactor. Moves all source modules into pm3py/core/ with file renames (hf_14a→hf_iso14a, hf_15→hf_iso15, hf_mf→hf_mfc) and client attribute normalization (hf.a14→hf.iso14a, hf.mf→hf.mfc). pm3py/__init__.py re-exports from core for backward compat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 lines
660 B
Python
18 lines
660 B
Python
from pm3py.core.protocol import crc16_a
|
|
|
|
def test_crc16_a_empty():
|
|
assert crc16_a(b"") == 0x6363 # init 0xC6C6 reflected = 0x6363
|
|
|
|
def test_crc16_a_known_vector():
|
|
# Verified against C implementation: compute_crc(CRC_14443_A, ...)
|
|
# "123456789" is the standard CRC check string
|
|
data = b"123456789"
|
|
assert crc16_a(data) == 0xBF05
|
|
|
|
def test_crc16_a_ping_preamble():
|
|
# A CMD_PING preamble: magic=0x61334d50, length|ng=0x8020, cmd=0x0109
|
|
preamble = bytes.fromhex("504d3361208001090102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
|
crc = crc16_a(preamble)
|
|
assert isinstance(crc, int)
|
|
assert 0 <= crc <= 0xFFFF
|