From 3d69c8b694fb012ceda949f0bde5ab7d1112a0aa Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Tue, 24 Aug 2010 10:11:48 +0000 Subject: [PATCH] New internal API function: pn53x_target_receive_dep_bytes(). --- libnfc/chips/pn53x.c | 21 +++++++++++++++++++++ libnfc/chips/pn53x.h | 2 ++ libnfc/nfc.c | 20 ++------------------ 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index db88e89..a303860 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -870,3 +870,24 @@ bool pn53x_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t // Everything went successful return true; } + +bool pn53x_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen) +{ + byte_t abtRx[MAX_FRAME_LEN]; + size_t szRxLen; + + pnd->iLastError = 0; + + + // Try to gather a received frame from the reader + if (!pn53x_transceive(pnd,pncmd_target_get_data,2,abtRx,&szRxLen)) return false; + + // Save the received byte count + *pszRxLen = szRxLen-1; + + // Copy the received bytes + memcpy(pbtRx,abtRx+1,*pszRxLen); + + // Everyting seems ok, return true + return true; +} diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index bf12af1..22beeac 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -101,6 +101,8 @@ bool pn53x_transceive_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const si bool pn53x_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar); bool pn53x_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool pn53x_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen); + const char *pn53x_strerror (const nfc_device_t *pnd); static const struct chip_callbacks pn53x_callbacks_list = { diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 5d28daa..8d6a1af 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -68,7 +68,7 @@ nfc_device_desc_t * nfc_pick_device (void); // extern const byte_t pncmd_initiator_auto_poll [ 5]; // // // Target -extern const byte_t pncmd_target_get_data [ 2]; +// extern const byte_t pncmd_target_get_data [ 2]; extern const byte_t pncmd_target_set_data [264]; extern const byte_t pncmd_target_init [ 39]; // extern const byte_t pncmd_target_virtual_card [ 4]; @@ -629,23 +629,7 @@ bool nfc_target_receive_bits(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits */ bool nfc_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen) { - byte_t abtRx[MAX_FRAME_LEN]; - size_t szRxLen; - - pnd->iLastError = 0; - - - // Try to gather a received frame from the reader - if (!pn53x_transceive(pnd,pncmd_target_get_data,2,abtRx,&szRxLen)) return false; - - // Save the received byte count - *pszRxLen = szRxLen-1; - - // Copy the received bytes - memcpy(pbtRx,abtRx+1,*pszRxLen); - - // Everyting seems ok, return true - return true; + return pn53x_target_receive_dep_bytes (pnd, pbtRx, pszRxLen); } /**