nfc_target_receive_bits() function does not now use pszRxBits as parameter because this function returns it.

This commit is contained in:
Audrey Diacre 2012-01-05 15:50:07 +00:00
parent 239fd750c4
commit 7e7ee3299e
7 changed files with 12 additions and 11 deletions

View file

@ -172,7 +172,7 @@ main (int argc, char *argv[])
while (true) {
// Test if we received a frame
if (nfc_target_receive_bits (pnd, abtRecv, &szRecvBits, NULL) > 0) {
if ((szRecvBits = nfc_target_receive_bits (pnd, abtRecv, NULL)) > 0) {
// Prepare the command to send back for the anti-collision request
switch (szRecvBits) {
case 7: // Request or Wakeup

View file

@ -179,7 +179,7 @@ main (int argc, char *argv[])
while (!quitting) {
// Test if we received a frame from the reader
if (nfc_target_receive_bits (pndTag, abtReaderRx, &szReaderRxBits, abtReaderRxPar) > 0) {
if ((szReaderRxBits = nfc_target_receive_bits (pndTag, abtReaderRx, abtReaderRxPar)) > 0) {
// Drop down the field before sending a REQA command and start a new session
if (szReaderRxBits == 7 && abtReaderRx[0] == 0x26) {
// Drop down field for a very short time (original tag will reboot)

View file

@ -87,7 +87,7 @@ extern "C" {
NFC_EXPORT int nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
NFC_EXPORT int nfc_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
NFC_EXPORT int nfc_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
NFC_EXPORT int nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
NFC_EXPORT int nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar);
/* Error reporting */
NFC_EXPORT const char *nfc_strerror (const nfc_device *pnd);

View file

@ -1811,8 +1811,9 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
}
int
pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar)
pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar)
{
size_t szRxBits = 0;
uint8_t abtCmd[] = { TgGetInitiatorCommand };
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
@ -1838,15 +1839,15 @@ pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx
// Unwrap the response frame
if ((res = pn53x_unwrap_frame (abtRx + 1, szFrameBits, pbtRx, pbtRxPar)) < 0)
return res;
*pszRxBits = res;
szRxBits = res;
} else {
// Save the received bits
*pszRxBits = szFrameBits;
szRxBits = szFrameBits;
// Copy the received bytes
memcpy (pbtRx, abtRx + 1, szRx - 1);
}
// Everyting seems ok, return received bits count
return *pszRxBits;
return szRxBits;
}
int

View file

@ -309,7 +309,7 @@ int pn53x_initiator_deselect_target (struct nfc_device *pnd);
// NFC device as Target functions
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout);
int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar);
int pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
int pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
int pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);

View file

@ -146,7 +146,7 @@ struct nfc_driver_t {
int (*target_send_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout);
int (*target_receive_bytes) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRx, int timeout);
int (*target_send_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
int (*target_receive_bits) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
int (*target_receive_bits) (struct nfc_device *pnd, uint8_t * pbtRx, uint8_t * pbtRxPar);
int (*device_set_property_bool) (struct nfc_device *pnd, const nfc_property property, const bool bEnable);
int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value);

View file

@ -758,9 +758,9 @@ nfc_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBi
* frames.
*/
int
nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar)
nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar)
{
HAL (target_receive_bits, pnd, pbtRx, pszRxBits, pbtRxPar);
HAL (target_receive_bits, pnd, pbtRx, pbtRxPar);
}
/**