Factorise code.

Avoid redundant code in PN53x usb and uart drivers.  Since it makes sense to
report errors at the nfc_device_t level, pass it directly to
pn53x_transceive().

Programs using the libnfc MAY use pn53x_transceive() to communicate with a NFC
device, and SHALL not use anymore pnd->pdc->transceive().  Code in the library
itself SHOULD avoid calling pnd->pdc->transceive(), so such construct have been
updated accordingly.
This commit is contained in:
Romain Tartiere
2010-07-31 14:20:15 +00:00
parent 301d692e8a
commit 79aeaa6287
15 changed files with 80 additions and 70 deletions

View File

@@ -78,19 +78,19 @@ int main(int argc, const char* argv[])
printf("NFC device [%s] connected.\n",pnd->acName);
result = pnd->pdc->transceive(pnd->nds,pncmd_diagnose_communication_line_test,sizeof(pncmd_diagnose_communication_line_test),abtRx,&szRxLen);
result = pn53x_transceive(pnd,pncmd_diagnose_communication_line_test,sizeof(pncmd_diagnose_communication_line_test),abtRx,&szRxLen);
if ( result ) {
result = (memcmp(pncmd_diagnose_communication_line_test+2, abtRx, sizeof(pncmd_diagnose_communication_line_test)-2 ) == 0);
}
printf(" Communication line test: %s\n", result ? "OK" : "Failed");
result = pnd->pdc->transceive(pnd->nds,pncmd_diagnose_rom_test,sizeof(pncmd_diagnose_rom_test),abtRx,&szRxLen);
result = pn53x_transceive(pnd,pncmd_diagnose_rom_test,sizeof(pncmd_diagnose_rom_test),abtRx,&szRxLen);
if ( result ) {
result = ((szRxLen == 1) && (abtRx[0] == 0x00));
}
printf(" ROM test: %s\n", result ? "OK" : "Failed");
result = pnd->pdc->transceive(pnd->nds,pncmd_diagnose_ram_test,sizeof(pncmd_diagnose_ram_test),abtRx,&szRxLen);
result = pn53x_transceive(pnd,pncmd_diagnose_ram_test,sizeof(pncmd_diagnose_ram_test),abtRx,&szRxLen);
if ( result ) {
result = ((szRxLen == 1) && (abtRx[0] == 0x00));
}