pn53x_build_frame() function returns now 0 on success and libnfc error code on failure.

This commit is contained in:
Audrey Diacre 2012-01-04 16:44:40 +00:00
parent e87241184a
commit 52c72383f1
4 changed files with 6 additions and 6 deletions

View file

@ -2465,7 +2465,7 @@ pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, cons
* @param pbtData payload (bytes array) of the frame, will become PD0, ..., PDn in PN53x frame
* @note The first byte of pbtData is the Command Code (CC)
*/
bool
int
pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData)
{
if (szData <= PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
@ -2517,9 +2517,9 @@ pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData,
(*pszFrame) = szData + PN53x_EXTENDED_FRAME__OVERHEAD;
} else {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "We can't send more than %d bytes in a raw (requested: %zd)", PN53x_EXTENDED_FRAME__DATA_MAX_LEN, szData);
return false;
return NFC_ECHIP;
}
return true;
return NFC_SUCCESS;
}
pn53x_modulation
pn53x_nm_to_pm(const nfc_modulation nm)

View file

@ -353,7 +353,7 @@ int pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t
// Misc
int pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
int pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
bool pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData);
int pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData);
void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io);
void pn53x_data_free (struct nfc_device *pnd);

View file

@ -319,7 +319,7 @@ arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData,
return false;
}
if (!pn53x_build_frame (abtFrame + 1, &szFrame, pbtData, szData)) {
if (pn53x_build_frame (abtFrame + 1, &szFrame, pbtData, szData) < 0) {
pnd->last_error = NFC_EINVARG;
return false;
}

View file

@ -320,7 +320,7 @@ pn532_uart_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, i
uint8_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
size_t szFrame = 0;
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {
if (pn53x_build_frame (abtFrame, &szFrame, pbtData, szData) < 0) {
pnd->last_error = NFC_EINVARG;
return false;
}