pn53x_check_ack_frame() and pn53x_check_error_frame() functions return now 0 on success and libnfc error code on failure.

This commit is contained in:
Audrey Diacre 2012-01-04 16:32:16 +00:00
parent 4b373263e4
commit e87241184a
5 changed files with 11 additions and 11 deletions

View file

@ -2432,31 +2432,31 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
return NFC_SUCCESS;
}
bool
int
pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen)
{
if (szRxFrameLen >= sizeof (pn53x_ack_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x ACKed");
return true;
return NFC_SUCCESS;
}
}
pnd->last_error = NFC_EIO;
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unexpected PN53x reply!");
return false;
return pnd->last_error;
}
bool
int
pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen)
{
if (szRxFrameLen >= sizeof (pn53x_error_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x sent an error frame");
pnd->last_error = NFC_EIO;
return false;
return pnd->last_error;
}
}
return true;
return NFC_SUCCESS;
}
/**

View file

@ -351,8 +351,8 @@ int pn53x_RFConfiguration__MaxRtyCOM (struct nfc_device *pnd, const uint8_t M
int pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation);
// Misc
bool pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
bool pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen);
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);
void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io);

View file

@ -339,7 +339,7 @@ arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData,
return false;
}
if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf))) {
if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) {
// The PN53x is running the sent command
} else if (0 == memcmp(arygon_error_unknown_mode, abtRxBuf, sizeof(abtRxBuf))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Bad frame format." );

View file

@ -340,7 +340,7 @@ pn532_uart_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, i
return false;
}
if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf))) {
if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) {
// The PN53x is running the sent command
} else {
return false;

View file

@ -529,7 +529,7 @@ pn53x_usb_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, co
return false;
}
if (pn53x_check_ack_frame (pnd, abtRxBuf, res)) {
if (pn53x_check_ack_frame (pnd, abtRxBuf, res) == 0) {
// The PN53x is running the sent command
} else {
// For some reasons (eg. send another command while a previous one is