chips/pn53x.c: allow null reception buffers for transceive commands

This commit is contained in:
Philippe Teuwen 2011-05-05 23:13:49 +00:00
parent c0a38e6eb0
commit 77e522aade

View file

@ -752,18 +752,19 @@ 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;
// Ignore the status byte from the PN53X here, it was checked earlier in pn53x_transceive() if (pbtRx != NULL) {
// Check if we should recover the parity bits ourself // Ignore the status byte from the PN53X here, it was checked earlier in pn53x_transceive()
if (!pnd->bPar) { // Check if we should recover the parity bits ourself
// Unwrap the response frame if (!pnd->bPar) {
pn53x_unwrap_frame (abtRx + 1, szFrameBits, pbtRx, pszRxBits, pbtRxPar); // Unwrap the response frame
} else { pn53x_unwrap_frame (abtRx + 1, szFrameBits, pbtRx, pszRxBits, pbtRxPar);
// Save the received bits } else {
*pszRxBits = szFrameBits; // Save the received bits
// Copy the received bytes *pszRxBits = szFrameBits;
memcpy (pbtRx, abtRx + 1, szRx - 1); // Copy the received bytes
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;
// Save the received byte count if (pbtRx != NULL) {
*pszRx = szRx - 1; // Save the received byte count
*pszRx = szRx - 1;
// Copy the received bytes
memcpy (pbtRx, abtRx + 1, *pszRx);
// Copy the received bytes
memcpy (pbtRx, abtRx + 1, *pszRx);
}
// Everything went successful // Everything went successful
return true; return true;
} }