the following functions now return libnfc error code:

_pn53x_write_register()
_pn53x_WriteRegister()
_pn53x_transceive()
_pn53x_SAMConfiguration()
_pn53x_PowerDown()
 _pn53x_InListPassiveTarget()
_pn53x_InDeselect()
_pn53x_InRelease()
_pn53x_RFConfiguration__*
This commit is contained in:
Audrey Diacre 2011-12-20 11:25:33 +00:00
parent 103485518c
commit 9c5ec3c4e1
8 changed files with 121 additions and 133 deletions

View file

@ -57,6 +57,7 @@ main (int argc, const char *argv[])
nfc_device *pnd;
const char *acLibnfcVersion;
bool result;
int res = 0;
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
@ -88,8 +89,8 @@ main (int argc, const char *argv[])
printf ("NFC device [%s] connected.\n", nfc_device_get_name (pnd));
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, 0);
if (result) {
res = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, 0);
if (res == 0) {
// Result of Diagnose ping for RC-S360 doesn't contain status byte so we've to handle both cases
result = (memcmp (pncmd_diagnose_communication_line_test + 1, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 1) == 0) ||
(memcmp (pncmd_diagnose_communication_line_test + 2, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 2) == 0);
@ -98,16 +99,16 @@ main (int argc, const char *argv[])
}
printf (" Communication line test: %s\n", result ? "OK" : "Failed");
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx, 0);
if (result) {
res = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx, 0);
if (res == 0) {
result = ((szRx == 1) && (abtRx[0] == 0x00));
} else {
nfc_perror (pnd, "pn53x_transceive");
}
printf (" ROM test: %s\n", result ? "OK" : "Failed");
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, 0);
if (result) {
res = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, 0);
if (res == 0) {
result = ((szRx == 1) && (abtRx[0] == 0x00));
} else {
nfc_perror (pnd, "pn53x_transceive");

View file

@ -110,7 +110,7 @@ main (int argc, const char *argv[])
// Connect with the SAM
// FIXME: Its a private pn53x function
if (!pn53x_SAMConfiguration (pnd, mode, 0)) {
if (pn53x_SAMConfiguration (pnd, mode, 0) < 0) {
nfc_perror (pnd, "pn53x_SAMConfiguration");
exit (EXIT_FAILURE);
}

View file

@ -178,7 +178,7 @@ int main(int argc, const char* argv[])
print_hex((uint8_t*)abtTx,szTx);
szRx = sizeof(abtRx);
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, 0)) {
if (pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, 0) < 0) {
free(cmd);
nfc_perror (pnd, "Rx");
continue;