mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-13 02:53:46 +00:00
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:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user