(libnfc-less-bitutils-more-ponies) Get rid of bitutils.[hc] (part 1).
- New API function append_iso14443a_crc(); - Add a PRINT_HEX macro for driver debugging (replaces print_hex function from bitutils.c); - Move bit-mirroring related functions to libnfc/mirror-subr.[hc]; - Move iso14443 related functions to libnfc/iso14443-subr.c; - Move libnfc/bitutils.c hex-dumping code to examples/nfc-utils.c; - Replace calls to swap_endian32() and swap_endian64() functions with calls to bswap32() and bswap64 provided by endian.h. And while I am here: - Fix the DBG macro so that it does not throw warning at compile time.
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "acr122.h"
|
||||
#include "../drivers.h"
|
||||
#include "../bitutils.h"
|
||||
|
||||
// Bus
|
||||
#include <winscard.h>
|
||||
@@ -279,8 +278,7 @@ bool acr122_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||
memcpy(abtTxBuf+5,pbtTx,szTxLen);
|
||||
szRxBufLen = sizeof(abtRxBuf);
|
||||
#ifdef DEBUG
|
||||
printf(" TX: ");
|
||||
print_hex(abtTxBuf,szTxLen+5);
|
||||
PRINT_HEX("TX", abtTxBuf,szTxLen+5);
|
||||
#endif
|
||||
|
||||
if (pas->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED)
|
||||
@@ -305,8 +303,7 @@ bool acr122_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRxBuf,szRxBufLen);
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
// When the answer should be ignored, just return a succesful result
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "../drivers.h"
|
||||
#include "../bitutils.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -236,8 +235,7 @@ bool arygon_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||
abtTxBuf[szTxLen+7] = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" TX: ");
|
||||
print_hex(abtTxBuf,szTxLen+8);
|
||||
PRINT_HEX("TX", abtTxBuf,szTxLen+8);
|
||||
#endif
|
||||
if (!uart_send((serial_port)nds,abtTxBuf,szTxLen+8)) {
|
||||
ERR("%s", "Unable to transmit data. (TX)");
|
||||
@@ -250,8 +248,7 @@ bool arygon_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRxBuf,szRxBufLen);
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
const byte_t pn53x_ack_frame[] = { 0x00,0x00,0xff,0x00,0xff,0x00 };
|
||||
@@ -282,10 +279,9 @@ bool arygon_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, const s
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
// When the answer should be ignored, just return a successful result
|
||||
if(pbtRx == NULL || pszRxLen == NULL) return true;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "../drivers.h"
|
||||
#include "../bitutils.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -215,8 +214,7 @@ bool pn532_uart_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, con
|
||||
abtTxBuf[szTxLen+6] = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" TX: ");
|
||||
print_hex(abtTxBuf,szTxLen+7);
|
||||
PRINT_HEX("TX", abtTxBuf,szTxLen+7);
|
||||
#endif
|
||||
if (!uart_send((serial_port)nds,abtTxBuf,szTxLen+7)) {
|
||||
ERR("%s", "Unable to transmit data. (TX)");
|
||||
@@ -229,8 +227,7 @@ bool pn532_uart_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, con
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRxBuf,szRxBufLen);
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -262,10 +259,9 @@ bool pn532_uart_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, con
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
// When the answer should be ignored, just return a successful result
|
||||
if(pbtRx == NULL || pszRxLen == NULL) return true;
|
||||
@@ -293,16 +289,14 @@ pn532_uart_wakeup(const nfc_device_spec_t nds)
|
||||
// const byte_t pncmd_pn532c106_wakeup[] = { 0x00,0x00,0xff,0x09,0xf7,0xd4,0x00,0x00,'l','i','b','n','f','c',0xbe,0x00 };
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" TX: ");
|
||||
print_hex(pncmd_pn532c106_wakeup,sizeof(pncmd_pn532c106_wakeup));
|
||||
PRINT_HEX("TX", pncmd_pn532c106_wakeup,sizeof(pncmd_pn532c106_wakeup));
|
||||
#endif
|
||||
uart_send((serial_port)nds, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup));
|
||||
|
||||
while (!uart_receive((serial_port)nds,abtRx,&szRxLen)) {
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRx,szRxLen);
|
||||
PRINT_HEX("RX", abtRx,szRxLen);
|
||||
#endif
|
||||
|
||||
const byte_t attempted_result[] = { 0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0xff,0x09,0xf7,0xD5,0x01,0x00,'l','i','b','n','f','c',0xbc,0x00};
|
||||
|
||||
@@ -38,7 +38,6 @@ Thanks to d18c7db and Okko for example code
|
||||
#include <string.h>
|
||||
|
||||
#include "../drivers.h"
|
||||
#include "../bitutils.h"
|
||||
|
||||
#include <nfc/nfc-messages.h>
|
||||
|
||||
@@ -267,10 +266,9 @@ bool pn53x_usb_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, cons
|
||||
abtTx[szTxLen+6] = 0;
|
||||
|
||||
DBG("%s","pn53x_usb_transceive");
|
||||
#ifdef DEBUG
|
||||
printf(" TX: ");
|
||||
print_hex(abtTx,szTxLen+7);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("TX", abtTx,szTxLen+7);
|
||||
#endif
|
||||
|
||||
ret = usb_bulk_write(pus->pudh, pus->uiEndPointOut, (char*)abtTx, szTxLen+7, USB_TIMEOUT);
|
||||
if( ret < 0 )
|
||||
@@ -286,10 +284,9 @@ bool pn53x_usb_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, cons
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRx,ret);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRx,ret);
|
||||
#endif
|
||||
|
||||
if( ret == 6 )
|
||||
{
|
||||
@@ -300,10 +297,9 @@ bool pn53x_usb_transceive(const nfc_device_spec_t nds, const byte_t* pbtTx, cons
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" RX: ");
|
||||
print_hex(abtRx,ret);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRx,ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
// When the answer should be ignored, just return a succesful result
|
||||
|
||||
Reference in New Issue
Block a user