fix "hf felica raw" length of buffer calculations. Added some more comments to explain whats going on. Thanks to @dxl for the solutions!

This commit is contained in:
iceman1001
2025-11-10 13:50:59 +01:00
parent fd06c38a89
commit f1c97c0526
2 changed files with 12 additions and 6 deletions
+1
View File
@@ -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)
+11 -6
View File
@@ -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);
};