Rework and fix error frames detection.

While here, rename the pn53x_transceive_callback() function to
pn53x_transceive_check_ack_frame_callback() to make it more obvious what it is
supposed to do.
This commit is contained in:
Romain Tartiere
2010-08-20 10:06:19 +00:00
parent b0737bd1a0
commit f4aa4edc94
3 changed files with 21 additions and 6 deletions

View File

@@ -285,7 +285,7 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
PRINT_HEX("RX", abtRx,ret);
#endif
if (!pn53x_transceive_callback (pnd, abtRx, ret))
if (!pn53x_transceive_check_ack_frame_callback (pnd, abtRx, ret))
return false;
ret = usb_bulk_read(pus->pudh, pus->uiEndPointIn, (char*)abtRx, BUFFER_LENGTH, USB_TIMEOUT);
@@ -305,6 +305,9 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
#endif
usb_bulk_write(pus->pudh, pus->uiEndPointOut, (char *)ack_frame, 6, USB_TIMEOUT);
if (!pn53x_transceive_check_error_frame_callback (pnd, abtRx, ret))
return false;
// When the answer should be ignored, just return a succesful result
if(pbtRx == NULL || pszRxLen == NULL) return true;
@@ -329,8 +332,5 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
memcpy( pbtRx, abtRx + 7, *pszRxLen);
if (abtRx[5] != pbtTx[0] + 1) {
pnd->iLastError = DEISERRFRAME;
}
return true;
}