chips/pn53x.c: allow null reception buffers for transceive commands
This commit is contained in:
parent
c0a38e6eb0
commit
77e522aade
1 changed files with 18 additions and 16 deletions
|
@ -752,6 +752,7 @@ pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const
|
||||||
// Recover the real frame length in bits
|
// Recover the real frame length in bits
|
||||||
szFrameBits = ((szRx - 1 - ((ui8Bits == 0) ? 0 : 1)) * 8) + ui8Bits;
|
szFrameBits = ((szRx - 1 - ((ui8Bits == 0) ? 0 : 1)) * 8) + ui8Bits;
|
||||||
|
|
||||||
|
if (pbtRx != NULL) {
|
||||||
// Ignore the status byte from the PN53X here, it was checked earlier in pn53x_transceive()
|
// Ignore the status byte from the PN53X here, it was checked earlier in pn53x_transceive()
|
||||||
// Check if we should recover the parity bits ourself
|
// Check if we should recover the parity bits ourself
|
||||||
if (!pnd->bPar) {
|
if (!pnd->bPar) {
|
||||||
|
@ -763,7 +764,7 @@ pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const
|
||||||
// Copy the received bytes
|
// Copy the received bytes
|
||||||
memcpy (pbtRx, abtRx + 1, szRx - 1);
|
memcpy (pbtRx, abtRx + 1, szRx - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Everything went successful
|
// Everything went successful
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -804,12 +805,13 @@ pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, cons
|
||||||
if (!pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, &szRx))
|
if (!pn53x_transceive (pnd, abtCmd, szTx + szExtraTxLen, abtRx, &szRx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (pbtRx != NULL) {
|
||||||
// Save the received byte count
|
// Save the received byte count
|
||||||
*pszRx = szRx - 1;
|
*pszRx = szRx - 1;
|
||||||
|
|
||||||
// Copy the received bytes
|
// Copy the received bytes
|
||||||
memcpy (pbtRx, abtRx + 1, *pszRx);
|
memcpy (pbtRx, abtRx + 1, *pszRx);
|
||||||
|
}
|
||||||
// Everything went successful
|
// Everything went successful
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue