diff --git a/examples/nfc-dep-initiator.c b/examples/nfc-dep-initiator.c index fd3d212..2373f59 100644 --- a/examples/nfc-dep-initiator.c +++ b/examples/nfc-dep-initiator.c @@ -86,7 +86,7 @@ main (int argc, const char *argv[]) return EXIT_FAILURE; } - if(!nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000)) { + if(nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) { nfc_perror(pnd, "nfc_initiator_select_dep_target"); goto error; } diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index 9ef9bd0..a0d75db 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -75,7 +75,7 @@ extern "C" { NFC_EXPORT int nfc_initiator_select_passive_target (nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt); NFC_EXPORT int nfc_initiator_list_passive_targets (nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets); NFC_EXPORT int nfc_initiator_poll_target (nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt); - NFC_EXPORT bool nfc_initiator_select_dep_target (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout); + NFC_EXPORT int nfc_initiator_select_dep_target (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout); NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device *pnd); NFC_EXPORT int nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout); NFC_EXPORT bool nfc_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar); diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 82b8943..e623b09 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1082,7 +1082,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd, return NFC_ECHIP; } -bool +int pn53x_initiator_select_dep_target(struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, @@ -2243,7 +2243,7 @@ pn53x_InAutoPoll (struct nfc_device *pnd, * @param szGBi count of General Bytes * @param[out] pnt \a nfc_target which will be filled by this function */ -bool +int pn53x_InJumpForDEP (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, @@ -2271,7 +2271,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd, case NBR_847: case NBR_UNDEFINED: pnd->last_error = NFC_EINVARG; - return false; + return pnd->last_error; break; } @@ -2291,7 +2291,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd, case NBR_847: case NBR_UNDEFINED: pnd->last_error = NFC_EINVARG; - return false; + return pnd->last_error; break; } } @@ -2310,13 +2310,14 @@ pn53x_InJumpForDEP (struct nfc_device *pnd, uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; size_t szRx = sizeof (abtRx); + int res = 0; // Try to find a target, call the transceive callback function of the current device - if (pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, timeout) < 0) - return false; + if ((res = pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, timeout)) < 0) + return res; // Make sure one target has been found, the PN53X returns 0x00 if none was available if (abtRx[1] != 1) - return false; + return NFC_ECHIP; // Is a target struct available if (pnt) { @@ -2336,7 +2337,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd, pnt->nti.ndi.szGB = 0; } } - return true; + return NFC_SUCCESS; } int diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 4010a77..33ee19b 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -294,7 +294,7 @@ int pn53x_initiator_poll_target (struct nfc_device *pnd, const nfc_modulation *pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt); -bool pn53x_initiator_select_dep_target (struct nfc_device *pnd, +int pn53x_initiator_select_dep_target (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, @@ -335,7 +335,7 @@ int pn53x_InAutoPoll (struct nfc_device *pnd, const pn53x_target_type *ppttTa const uint8_t btPollNr, const uint8_t btPeriod, nfc_target *pntTargets, size_t *pszTargetFound, const int timeout); -bool pn53x_InJumpForDEP (struct nfc_device *pnd, +int pn53x_InJumpForDEP (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const uint8_t *pbtPassiveInitiatorData, const uint8_t *pbtNFCID3i, diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 3f2919f..6ebe21c 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -135,7 +135,7 @@ struct nfc_driver_t { int (*initiator_init) (struct nfc_device *pnd); int (*initiator_select_passive_target) (struct nfc_device *pnd, const nfc_modulation nm, const uint8_t * pbtInitData, const size_t szInitData, nfc_target * pnt); int (*initiator_poll_target) (struct nfc_device *pnd, const nfc_modulation * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target * pnt); - bool (*initiator_select_dep_target) (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout); + int (*initiator_select_dep_target) (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout); bool (*initiator_deselect_target) (struct nfc_device *pnd); int (*initiator_transceive_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout); bool (*initiator_transceive_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index e2eb1cd..46ad4ed 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -433,7 +433,7 @@ nfc_initiator_poll_target (nfc_device *pnd, /** * @brief Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol) - * @return Returns \c true if action was successfully performed; otherwise returns \c false. + * @return Returns 0 on success, otherwise returns libnfc's error code (negative value). * * @param pnd \a nfc_device struct pointer that represent currently used device * @param ndm desired D.E.P. mode (\a NDM_ACTIVE or \a NDM_PASSIVE for active, respectively passive mode) @@ -446,7 +446,7 @@ nfc_initiator_poll_target (nfc_device *pnd, * * @note \a nfc_dep_info will be returned when the target was acquired successfully. */ -bool +int nfc_initiator_select_dep_target (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout) diff --git a/test/test_dep_active.c b/test/test_dep_active.c index a80eefa..852939e 100644 --- a/test/test_dep_active.c +++ b/test/test_dep_active.c @@ -124,27 +124,27 @@ initiator_thread (void *arg) // Active mode printf ("=========== INITIATOR %s (Active mode / %s Kbps) =========\n", nfc_device_get_name (device), str_nfc_baud_rate(nbr)); - 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))); + int res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000); + cut_assert_equal_int (0, 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")); cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3")); cut_assert_equal_int (NDM_ACTIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode")); cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } const uint8_t abtTx[] = "Hello DEP target!"; uint8_t abtRx[1024]; size_t szRx = sizeof (abtRx); res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 5000); - cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); + cut_assert_operator_int (res, >=, 0, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); - if (!res) { thread_res = -1; return (void*) thread_res; } - res = nfc_initiator_deselect_target (device); - cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } + bool bres = nfc_initiator_deselect_target (device); + cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (!bres) { thread_res = -1; return (void*) thread_res; } return (void *) thread_res; } diff --git a/test/test_dep_passive.c b/test/test_dep_passive.c index cc80ece..3bf13e5 100644 --- a/test/test_dep_passive.c +++ b/test/test_dep_passive.c @@ -157,94 +157,94 @@ initiator_thread (void *arg) // Passive mode / 106Kbps printf ("=========== INITIATOR %s (Passive mode / 106Kbps) =========\n", nfc_device_get_name (device)); - 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))); + int res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000); + cut_assert_equal_int (0, 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")); cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3")); cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode")); cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } const uint8_t abtTx[] = "Hello DEP target!"; uint8_t abtRx[1024]; size_t szRx = sizeof (abtRx); res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 500); - cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); + cut_assert_operator_int (res, >=, 0, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } - res = nfc_initiator_deselect_target (device); - cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + bool bres = nfc_initiator_deselect_target (device); + cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (!bres) { thread_res = -1; return (void*) thread_res; } // Passive mode / 212Kbps (second pass) printf ("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_get_name (device)); res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt, 1000); - cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); + cut_assert_equal_int (0, 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_212, nt.nm.nbr, cut_message ("Invalid target baud rate")); cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3")); cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode")); cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } szRx = sizeof (abtRx); res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 1000); - cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); + cut_assert_operator_int (res, >=, 0, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } - res = nfc_initiator_deselect_target (device); - cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + bres = nfc_initiator_deselect_target (device); + cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (!bres) { thread_res = -1; return (void*) thread_res; } // Passive mode / 212Kbps printf ("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_get_name (device)); res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt, 1000); - cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); + cut_assert_equal_int (0, 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_212, nt.nm.nbr, cut_message ("Invalid target baud rate")); cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3")); cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode")); cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } szRx = sizeof (abtRx); res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 5000); - cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); + cut_assert_operator_int (res, >=, 0, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } - res = nfc_initiator_deselect_target (device); - cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + bres = nfc_initiator_deselect_target (device); + cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (!bres) { thread_res = -1; return (void*) thread_res; } // Passive mode / 424Kbps printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name (device)); res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_424, NULL, &nt, 1000); - cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); + cut_assert_equal_int (0, 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_424, nt.nm.nbr, cut_message ("Invalid target baud rate")); cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3")); cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode")); cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } szRx = sizeof (abtRx); res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 5000); - cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); + cut_assert_operator_int (res, >=, 0, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device))); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); - if (!res) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void*) thread_res; } - res = nfc_initiator_deselect_target (device); - cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + bres = nfc_initiator_deselect_target (device); + cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (!bres) { thread_res = -1; return (void*) thread_res; } return (void *) thread_res; } diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 320c73d..c2ae78c 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -116,7 +116,7 @@ transmit_bytes (const uint8_t *pbtTx, const size_t szTx) printf ("Sent bits: "); print_hex (pbtTx, szTx); // Transmit the command bytes - if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0)) + if (nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0) < 0) return false; // Show received answer diff --git a/utils/nfc-mfsetuid.c b/utils/nfc-mfsetuid.c index 9d18dc0..ea0af5c 100644 --- a/utils/nfc-mfsetuid.c +++ b/utils/nfc-mfsetuid.c @@ -118,7 +118,7 @@ transmit_bytes (const uint8_t *pbtTx, const size_t szTx) print_hex (pbtTx, szTx); } // Transmit the command bytes - if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0)) + if (nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0) < 0) return false; // Show received answer diff --git a/utils/nfc-read-forum-tag3.c b/utils/nfc-read-forum-tag3.c index e051bb8..5b3db96 100644 --- a/utils/nfc-read-forum-tag3.c +++ b/utils/nfc-read-forum-tag3.c @@ -116,7 +116,7 @@ nfc_forum_tag_type3_check (nfc_device *pnd, const nfc_target nt, const uint16_t uint8_t res[1024]; size_t res_len; - if (!nfc_initiator_transceive_bytes (pnd, frame, frame_len, res, &res_len, 0)) { + if (nfc_initiator_transceive_bytes (pnd, frame, frame_len, res, &res_len, 0) < 0) { return -1; } const size_t res_overhead = 1 + 1 + 8 + 2; // 1+1+8+2: LEN + CMD + NFCID2 + STATUS diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index b3cdff3..ec10084 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -400,8 +400,8 @@ main (int argc, char *argv[]) if (!target_only_mode) { // Forward the frame to the original tag - ret = nfc_initiator_transceive_bytes - (pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen, 0); + ret = (nfc_initiator_transceive_bytes + (pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen, 0) < 0) ? 0 : 1; } else { if (scan_hex_fd3(abtRapdu, &szRapduLen, "R-APDU") != EXIT_SUCCESS) { fprintf (stderr, "Error while scanning R-APDU from FD3\n");