add some forgotten NFC_SUCCESS returns in pn53x_set_property_bool function and fix some return types in test/

This commit is contained in:
Audrey Diacre 2011-12-19 14:05:02 +00:00
parent 6eb2499aa8
commit 31f67be83e
3 changed files with 21 additions and 12 deletions

View file

@ -699,6 +699,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
if (!pn53x_write_register (pnd, PN53X_REG_CIU_RxMode, SYMBOL_RX_CRC_ENABLE, btValue))
return NFC_ECHIP;
pnd->bCrc = bEnable;
return NFC_SUCCESS;
break;
case NP_HANDLE_PARITY:
@ -710,15 +711,18 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
if (!pn53x_write_register (pnd, PN53X_REG_CIU_ManualRCV, SYMBOL_PARITY_DISABLE, btValue))
return NFC_ECHIP;
pnd->bPar = bEnable;
return NFC_SUCCESS;
break;
case NP_EASY_FRAMING:
pnd->bEasyFraming = bEnable;
return NFC_SUCCESS;
break;
case NP_ACTIVATE_FIELD:
{
return pn53x_RFConfiguration__RF_field (pnd, bEnable);
if (pn53x_RFConfiguration__RF_field (pnd, bEnable))
return NFC_SUCCESS;
}
break;
@ -726,6 +730,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
btValue = (bEnable) ? SYMBOL_MF_CRYPTO1_ON : 0x00;
if (!pn53x_write_register (pnd, PN53X_REG_CIU_Status2, SYMBOL_MF_CRYPTO1_ON, btValue))
return NFC_ECHIP;
return NFC_SUCCESS;
break;
case NP_INFINITE_SELECT:
@ -733,11 +738,12 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
// TODO Made some research around this point:
// timings could be tweak better than this, and maybe we can tweak timings
// to "gain" a sort-of hardware polling (ie. like PN532 does)
return pn53x_RFConfiguration__MaxRetries (pnd,
if (pn53x_RFConfiguration__MaxRetries (pnd,
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
(bEnable) ? 0xff : 0x00, // MxRtyPSL, default: 0x01
(bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531)
);
))
return NFC_SUCCESS;
}
break;
@ -745,6 +751,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
btValue = (bEnable) ? SYMBOL_RX_NO_ERROR : 0x00;
if (!pn53x_write_register (pnd, PN53X_REG_CIU_RxMode, SYMBOL_RX_NO_ERROR, btValue))
return NFC_ECHIP;
return NFC_SUCCESS;
break;
case NP_ACCEPT_MULTIPLE_FRAMES:
@ -759,7 +766,8 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
// Nothing to do
return NFC_SUCCESS;
pnd->bAutoIso14443_4 = bEnable;
return pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable);
if (pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable))
return NFC_SUCCESS;
break;
case NP_FORCE_ISO14443_A:

View file

@ -116,15 +116,15 @@ initiator_thread (void *arg)
*/
sleep (1);
printf ("=========== INITIATOR %s =========\n", nfc_device_get_name (device));
bool res = nfc_initiator_init (device);
cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device)));
if (!res) { thread_res = -1; return (void*) thread_res; }
int ires = nfc_initiator_init (device);
cut_assert_equal_int (0, ires, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device)));
if (ires < 0) { thread_res = -1; return (void*) thread_res; }
nfc_target nt;
// Active mode
printf ("=========== INITIATOR %s (Active mode / %s Kbps) =========\n", nfc_device_get_name (device), str_nfc_baud_rate(nbr));
res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000);
bool res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000);
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation"));
cut_assert_equal_int (nbr, nt.nm.nbr, cut_message ("Invalid target baud rate"));

View file

@ -149,15 +149,16 @@ initiator_thread (void *arg)
sleep (1);
printf ("=========== INITIATOR %s =========\n", nfc_device_get_name (device));
bool res = nfc_initiator_init (device);
cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device)));
if (!res) { thread_res = -1; return (void*) thread_res; }
int ires = nfc_initiator_init (device);
printf ("IRES: %d\n", ires);
cut_assert_equal_int (0, ires, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device)));
if (ires < 0) { thread_res = -1; return (void*) thread_res; }
nfc_target nt;
// Passive mode / 106Kbps
printf ("=========== INITIATOR %s (Passive mode / 106Kbps) =========\n", nfc_device_get_name (device));
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000);
bool res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000);
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation"));
cut_assert_equal_int (NBR_106, nt.nm.nbr, cut_message ("Invalid target baud rate"));