diff --git a/CHANGELOG.md b/CHANGELOG.md index b61d6d5e1..1d470b081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- fix `hf felica raw` - wrong length calculationes. Thanks @dxl for the solutions! (@iceman1001) - Added basic QR code generation support. Thanks @mistial-dev for the idea! (@iceman1001) - Added identification of NDEF/Open print tag record (@iceman1001) - Added support for Bruce dump files [.rfid] (@iceman1001) diff --git a/armsrc/felica.c b/armsrc/felica.c index d924cc0b7..fe16a3605 100644 --- a/armsrc/felica.c +++ b/armsrc/felica.c @@ -572,26 +572,31 @@ void felica_sendraw(const PacketCommandNG *c) { if ((param & FELICA_RAW) == FELICA_RAW) { - // 2 sync, 1 len, 2crc == 5 + // 2 sync, 1 len, 2 crc == 5 uint8_t *buf = BigBuf_calloc(len + 5); // add sync bits buf[0] = 0xb2; buf[1] = 0x4d; - buf[2] = len; + + // len (number of bytes) + 1 for len byte itself + buf[2] = len + 1; // copy command - memcpy(buf + 2, c->data.asBytes, len); + memcpy(buf + 3, c->data.asBytes, len); if ((param & FELICA_APPEND_CRC) == FELICA_APPEND_CRC) { // Don't append crc on empty bytearray... - if (len > 0) { - AddCrc(buf + 2, len); + if (len) { + // n bytes + len 1 byte + AddCrc(buf + 2, len + 1); } } if (g_dbglevel >= DBG_DEBUG) { Dbprintf("Transmit Frame (no CRC shown):"); - Dbhexdump(len, buf, 0); + // 0,1,2, n + Dbhexdump(len + 1 + 2, buf, 0); + // total buffer length: len + 1 len byte + 2 sync bytes + 2 crc bytes Dbprintf("Buffer Length: %i", buf[2] + 4); };