Timeout is now integer.
This commit is contained in:
parent
dad3603936
commit
5c7454a2f7
29 changed files with 133 additions and 145 deletions
|
@ -105,7 +105,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, NULL))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
@ -93,7 +93,7 @@ main (int argc, const char *argv[])
|
|||
print_nfc_target (nt, false);
|
||||
|
||||
printf ("Sending: %s\n", abtTx);
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx, NULL)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx, 0)) {
|
||||
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
printf("Initiator request received. Waiting for data...\n");
|
||||
if (!nfc_target_receive_bytes (pnd, abtRx, &szRx, NULL)) {
|
||||
if (!nfc_target_receive_bytes (pnd, abtRx, &szRx, 0)) {
|
||||
nfc_perror(pnd, "nfc_target_receive_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ main (int argc, const char *argv[])
|
|||
printf ("Received: %s\n", abtRx);
|
||||
|
||||
printf ("Sending: %s\n", abtTx);
|
||||
if (!nfc_target_send_bytes (pnd, abtTx, sizeof(abtTx), NULL)) {
|
||||
if (!nfc_target_send_bytes (pnd, abtTx, sizeof(abtTx), 0)) {
|
||||
nfc_perror(pnd, "nfc_target_send_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ nfc_target_emulate_tag(nfc_device* pnd, nfc_target * pnt)
|
|||
while ( loop ) {
|
||||
loop = target_io( pnt, abtRx, szRx, abtTx, &szTx );
|
||||
if (szTx) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, szTx, NULL)) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, szTx, 0)) {
|
||||
nfc_perror (pnd, "nfc_target_send_bytes");
|
||||
return false;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ nfc_target_emulate_tag(nfc_device* pnd, nfc_target * pnt)
|
|||
nfc_configure (pnd, NDO_HANDLE_CRC, false);
|
||||
init_mfc_auth = false;
|
||||
}
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, NULL)) {
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, 0)) {
|
||||
nfc_perror (pnd, "nfc_target_receive_bytes");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ main (int argc, const char *argv[])
|
|||
|
||||
printf ("NFC device [%s] connected.\n", pnd->acName);
|
||||
|
||||
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, NULL);
|
||||
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, 0);
|
||||
if (result) {
|
||||
// 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) ||
|
||||
|
@ -98,7 +98,7 @@ 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, NULL);
|
||||
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx, 0);
|
||||
if (result) {
|
||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||
} else {
|
||||
|
@ -106,7 +106,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
printf (" ROM test: %s\n", result ? "OK" : "Failed");
|
||||
|
||||
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, NULL);
|
||||
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, 0);
|
||||
if (result) {
|
||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||
} else {
|
||||
|
|
|
@ -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, NULL)) {
|
||||
if (!pn53x_SAMConfiguration (pnd, mode, 0)) {
|
||||
nfc_perror (pnd, "pn53x_SAMConfiguration");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
// Disconnect from the SAM
|
||||
pn53x_SAMConfiguration (pnd, PSM_NORMAL, NULL);
|
||||
pn53x_SAMConfiguration (pnd, PSM_NORMAL, 0);
|
||||
|
||||
// Disconnect from NFC device
|
||||
nfc_disconnect (pnd);
|
||||
|
|
|
@ -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, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, 0)) {
|
||||
free(cmd);
|
||||
nfc_perror (pnd, "Rx");
|
||||
continue;
|
||||
|
|
|
@ -78,15 +78,15 @@ extern "C" {
|
|||
NFC_EXPORT bool 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);
|
||||
NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device *pnd);
|
||||
NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
NFC_EXPORT bool 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);
|
||||
NFC_EXPORT bool nfc_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles);
|
||||
NFC_EXPORT bool nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar, uint32_t *cycles);
|
||||
|
||||
/* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
|
||||
NFC_EXPORT bool nfc_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx);
|
||||
NFC_EXPORT bool nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
NFC_EXPORT bool nfc_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
NFC_EXPORT bool nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
||||
NFC_EXPORT bool nfc_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
NFC_EXPORT bool nfc_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
NFC_EXPORT bool nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ void uart_flush_input (const serial_port sp);
|
|||
void uart_set_speed (serial_port sp, const uint32_t uiPortSpeed);
|
||||
uint32_t uart_get_speed (const serial_port sp);
|
||||
|
||||
int uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout);
|
||||
int uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
int uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout);
|
||||
int uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
|
||||
char **uart_list_ports (void);
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ uart_close (const serial_port sp)
|
|||
* @return 0 on success, otherwise driver error code
|
||||
*/
|
||||
int
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout)
|
||||
{
|
||||
int iAbortFd = abort_p ? *((int*)abort_p) : 0;
|
||||
int received_bytes_count = 0;
|
||||
|
@ -272,12 +272,13 @@ select:
|
|||
* Make a copy so that it will be updated on these systems,
|
||||
*/
|
||||
struct timeval fixed_timeout;
|
||||
if (timeout) {
|
||||
fixed_timeout = *timeout;
|
||||
timeout = &fixed_timeout;
|
||||
if (timeout > 0) {
|
||||
fixed_timeout.tv_sec = (timeout / 1000);
|
||||
fixed_timeout.tv_usec = ((timeout % 1000) * 1000);
|
||||
timeout = ((fixed_timeout.tv_sec * 1000) + (fixed_timeout.tv_usec / 1000));
|
||||
}
|
||||
|
||||
res = select (MAX(UART_DATA(sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, timeout);
|
||||
res = select (MAX(UART_DATA(sp)->fd, iAbortFd) + 1, &rfds, NULL, NULL, &fixed_timeout);
|
||||
|
||||
if ((res < 0) && (EINTR == errno)) {
|
||||
// The system call was interupted by a signal and a signal handler was
|
||||
|
@ -327,7 +328,7 @@ select:
|
|||
* @return 0 on success, otherwise a driver error is returned
|
||||
*/
|
||||
int
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
(void) timeout;
|
||||
LOG_HEX ("TX", pbtTx, szTx);
|
||||
|
|
|
@ -139,7 +139,7 @@ uart_get_speed (const serial_port sp)
|
|||
}
|
||||
|
||||
int
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, struct timeval *timeout)
|
||||
uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout)
|
||||
{
|
||||
DWORD dwBytesToGet = (DWORD)szRx;
|
||||
DWORD dwBytesReceived = 0;
|
||||
|
@ -147,7 +147,7 @@ uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p
|
|||
BOOL res;
|
||||
|
||||
// XXX Put this part into uart_win32_timeouts () ?
|
||||
DWORD timeout_ms = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
DWORD timeout_ms = timeout;
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 0;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 0;
|
||||
|
@ -194,16 +194,16 @@ uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p
|
|||
}
|
||||
|
||||
int
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
uart_send (serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
DWORD dwTxLen = 0;
|
||||
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 0;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.ReadTotalTimeoutConstant = timeout;
|
||||
timeouts.WriteTotalTimeoutMultiplier = 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout ? ((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)) : 0;
|
||||
timeouts.WriteTotalTimeoutConstant = timeout;
|
||||
|
||||
if (!SetCommTimeouts (((struct serial_port_windows *) sp)->hPort, &timeouts)) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to apply new timeout settings.");
|
||||
|
|
|
@ -100,7 +100,7 @@ pn53x_reset_settings(nfc_device * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, struct timeval *timeout)
|
||||
pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, int timeout)
|
||||
{
|
||||
if (CHIP_DATA (pnd)->wb_trigged) {
|
||||
if (!pn53x_writeback_register (pnd)) {
|
||||
|
@ -109,8 +109,8 @@ pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, ui
|
|||
}
|
||||
|
||||
PNCMD_TRACE (pbtTx[0]);
|
||||
if (timeout)
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout values: %li s, %li us", timeout->tv_sec, timeout->tv_usec);
|
||||
if (timeout > 0)
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout values: %d", timeout);
|
||||
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
|
@ -469,7 +469,7 @@ pn53x_ReadRegister (nfc_device * pnd, uint16_t ui16RegisterAddress, uint8_t * ui
|
|||
size_t szRegValue = sizeof (abtRegValue);
|
||||
|
||||
PNREG_TRACE (ui16RegisterAddress);
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRegValue, &szRegValue, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRegValue, &szRegValue, 0)) {
|
||||
return false;
|
||||
}
|
||||
if (CHIP_DATA(pnd)->type == PN533) {
|
||||
|
@ -491,7 +491,7 @@ pn53x_WriteRegister (nfc_device * pnd, const uint16_t ui16RegisterAddress, const
|
|||
{
|
||||
uint8_t abtCmd[] = { WriteRegister, ui16RegisterAddress >> 8, ui16RegisterAddress & 0xff, ui8Value };
|
||||
PNREG_TRACE (ui16RegisterAddress);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -543,7 +543,7 @@ pn53x_writeback_register (nfc_device * pnd)
|
|||
uint8_t abtRes[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRes = sizeof(abtRes);
|
||||
// It transceives the previously constructed ReadRegister command
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, 0)) {
|
||||
return false;
|
||||
}
|
||||
size_t i = 0;
|
||||
|
@ -581,7 +581,7 @@ pn53x_writeback_register (nfc_device * pnd)
|
|||
|
||||
if (BUFFER_SIZE (abtWriteRegisterCmd) > 1) {
|
||||
// We need to write some registers
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ pn53x_get_firmware_version (nfc_device * pnd, char abtFirmwareText[22])
|
|||
const uint8_t abtCmd[] = { GetFirmwareVersion };
|
||||
uint8_t abtFw[4];
|
||||
size_t szFwLen = sizeof (abtFw);
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtFw, &szFwLen, 0)) {
|
||||
return false;
|
||||
}
|
||||
// Determine which version of chip it is: PN531 will return only 2 bytes, while others return 4 bytes and have the first to tell the version IC
|
||||
|
@ -832,11 +832,7 @@ pn53x_check_communication (nfc_device *pnd)
|
|||
uint8_t abtRx[sizeof(abtExpectedRx)];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, &timeout))
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, 1000))
|
||||
return false;
|
||||
|
||||
return ((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx))));
|
||||
|
@ -860,7 +856,7 @@ pn53x_initiator_select_passive_target_ext (nfc_device * pnd,
|
|||
const nfc_modulation nm,
|
||||
const uint8_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target * pnt,
|
||||
struct timeval* timeout)
|
||||
int timeout)
|
||||
{
|
||||
uint8_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szTargetsData = sizeof(abtTargetsData);
|
||||
|
@ -971,7 +967,7 @@ pn53x_initiator_select_passive_target (nfc_device * pnd,
|
|||
const uint8_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target * pnt)
|
||||
{
|
||||
return pn53x_initiator_select_passive_target_ext (pnd, nm, pbtInitData, szInitData, pnt, NULL);
|
||||
return pn53x_initiator_select_passive_target_ext (pnd, nm, pbtInitData, szInitData, pnt, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1024,11 +1020,8 @@ pn53x_initiator_poll_target (nfc_device * pnd,
|
|||
size_t szInitiatorData;
|
||||
prepare_initiator_data (pnmModulations[n], &pbtInitiatorData, &szInitiatorData);
|
||||
const int timeout_ms = uiPeriod * 150;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = timeout_ms / 1000;
|
||||
timeout.tv_usec = (timeout_ms - (timeout.tv_sec * 1000)) * 1000;
|
||||
|
||||
if (!pn53x_initiator_select_passive_target_ext (pnd, pnmModulations[n], pbtInitiatorData, szInitiatorData, pnt, &timeout)) {
|
||||
if (!pn53x_initiator_select_passive_target_ext (pnd, pnmModulations[n], pbtInitiatorData, szInitiatorData, pnt, timeout_ms)) {
|
||||
if (pnd->iLastError != ECOMTIMEOUT)
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1105,7 +1098,7 @@ pn53x_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx, const
|
|||
// We have to give the amount of bytes + (the command byte 0x42)
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, abtRx, &szRx, NULL))
|
||||
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Get the last bit-count that is stored in the received byte
|
||||
|
@ -1135,7 +1128,7 @@ pn53x_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx, const
|
|||
|
||||
bool
|
||||
pn53x_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
|
||||
size_t * pszRx, struct timeval *timeout)
|
||||
size_t * pszRx, int timeout)
|
||||
{
|
||||
size_t szExtraTxLen;
|
||||
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
|
@ -1222,7 +1215,7 @@ uint32_t __pn53x_get_timer(nfc_device * pnd, const uint8_t last_cmd_byte)
|
|||
uint8_t abtRes[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRes = sizeof(abtRes);
|
||||
// Let's send the previously constructed ReadRegister command
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, 0)) {
|
||||
return false;
|
||||
}
|
||||
counter_hi = abtRes[off];
|
||||
|
@ -1312,7 +1305,7 @@ pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx,
|
|||
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_BitFraming & 0xff);
|
||||
BUFFER_APPEND (abtWriteRegisterCmd, SYMBOL_START_SEND | ((szTxBits % 8) & SYMBOL_TX_LAST_BITS));
|
||||
// Let's send the previously constructed WriteRegister command
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1337,7 @@ pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx,
|
|||
uint8_t abtRes[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRes = sizeof(abtRes);
|
||||
// Let's send the previously constructed ReadRegister command
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, 0)) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < sz; i++) {
|
||||
|
@ -1407,7 +1400,7 @@ pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const uint8_t * pbtTx,
|
|||
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_BitFraming & 0xff);
|
||||
BUFFER_APPEND (abtWriteRegisterCmd, SYMBOL_START_SEND);
|
||||
// Let's send the previously constructed WriteRegister command
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtWriteRegisterCmd, BUFFER_SIZE (abtWriteRegisterCmd), NULL, NULL, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1439,7 +1432,7 @@ pn53x_initiator_transceive_bytes_timed (nfc_device * pnd, const uint8_t * pbtTx,
|
|||
uint8_t abtRes[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRes = sizeof(abtRes);
|
||||
// Let's send the previously constructed ReadRegister command
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtReadRegisterCmd, BUFFER_SIZE (abtReadRegisterCmd), abtRes, &szRes, 0)) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < sz; i++) {
|
||||
|
@ -1703,7 +1696,7 @@ pn53x_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits
|
|||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
// Try to gather a received frame from the reader
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, NULL))
|
||||
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Get the last bit-count that is stored in the received byte
|
||||
|
@ -1731,7 +1724,7 @@ pn53x_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, int timeout)
|
||||
{
|
||||
uint8_t abtCmd[1];
|
||||
|
||||
|
@ -1810,7 +1803,7 @@ pn53x_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t sz
|
|||
return false;
|
||||
|
||||
// Try to send the bits to the reader
|
||||
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, NULL, NULL, NULL))
|
||||
if (!pn53x_transceive (pnd, abtCmd, szFrameBytes + 1, NULL, NULL, 0))
|
||||
return false;
|
||||
|
||||
// Everyting seems ok, return true
|
||||
|
@ -1818,7 +1811,7 @@ pn53x_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t sz
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
uint8_t abtCmd[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
|
||||
|
@ -1936,7 +1929,7 @@ bool
|
|||
pn53x_RFConfiguration__RF_field (nfc_device * pnd, bool bEnable)
|
||||
{
|
||||
uint8_t abtCmd[] = { RFConfiguration, RFCI_FIELD, (bEnable) ? 0x01 : 0x00 };
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1949,7 +1942,7 @@ pn53x_RFConfiguration__Various_timings (nfc_device * pnd, const uint8_t fATR_RES
|
|||
fATR_RES_Timeout, // ATR_RES timeout (default: 0x0B 102.4 ms)
|
||||
fRetryTimeout // TimeOut during non-DEP communications (default: 0x0A 51.2 ms)
|
||||
};
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1960,7 +1953,7 @@ pn53x_RFConfiguration__MaxRtyCOM (nfc_device * pnd, const uint8_t MaxRtyCOM)
|
|||
RFCI_RETRY_DATA,
|
||||
MaxRtyCOM // MaxRtyCOM, default: 0x00 (no retry, only one try), inifite: 0xff
|
||||
};
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1974,7 +1967,7 @@ pn53x_RFConfiguration__MaxRetries (nfc_device * pnd, const uint8_t MxRtyATR, con
|
|||
MxRtyPSL, // MxRtyPSL, default: 0x01
|
||||
MxRtyPassiveActivation // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531)
|
||||
};
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1982,7 +1975,7 @@ pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value)
|
|||
{
|
||||
uint8_t abtCmd[] = { SetParameters, ui8Value };
|
||||
|
||||
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL)) {
|
||||
if(!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0)) {
|
||||
return false;
|
||||
}
|
||||
// We save last parameters in register cache
|
||||
|
@ -1991,7 +1984,7 @@ pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value)
|
|||
}
|
||||
|
||||
bool
|
||||
pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode ui8Mode, struct timeval *timeout)
|
||||
pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode ui8Mode, int timeout)
|
||||
{
|
||||
uint8_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
|
||||
size_t szCmd = sizeof(abtCmd);
|
||||
|
@ -2023,7 +2016,7 @@ bool
|
|||
pn53x_PowerDown (nfc_device * pnd)
|
||||
{
|
||||
uint8_t abtCmd[] = { PowerDown, 0xf0 };
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2045,7 +2038,7 @@ pn53x_InListPassiveTarget (nfc_device * pnd,
|
|||
const pn53x_modulation pmInitModulation, const uint8_t szMaxTargets,
|
||||
const uint8_t * pbtInitiatorData, const size_t szInitiatorData,
|
||||
uint8_t * pbtTargetsData, size_t * pszTargetsData,
|
||||
struct timeval* timeout)
|
||||
int timeout)
|
||||
{
|
||||
uint8_t abtCmd[15] = { InListPassiveTarget };
|
||||
|
||||
|
@ -2101,7 +2094,7 @@ pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target)
|
|||
uint8_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szStatus = sizeof(abtStatus);
|
||||
uint8_t abtCmdGetStatus[] = { GetGeneralStatus };
|
||||
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, 0)) {
|
||||
return false;
|
||||
}
|
||||
if ((szStatus < 3) || (abtStatus[2] == 0)) {
|
||||
|
@ -2109,10 +2102,10 @@ pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target)
|
|||
}
|
||||
// No much choice what to deselect actually...
|
||||
uint8_t abtCmdRcs360[] = { InDeselect, 0x01, 0x01 };
|
||||
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, NULL));
|
||||
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, 0));
|
||||
}
|
||||
uint8_t abtCmd[] = { InDeselect, ui8Target };
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2123,7 +2116,7 @@ pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target)
|
|||
uint8_t abtStatus[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szStatus = sizeof(abtStatus);
|
||||
uint8_t abtCmdGetStatus[] = { GetGeneralStatus };
|
||||
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, NULL)) {
|
||||
if (!pn53x_transceive (pnd, abtCmdGetStatus, sizeof (abtCmdGetStatus), abtStatus, &szStatus, 0)) {
|
||||
return false;
|
||||
}
|
||||
if ((szStatus < 3) || (abtStatus[2] == 0)) {
|
||||
|
@ -2131,10 +2124,10 @@ pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target)
|
|||
}
|
||||
// No much choice what to release actually...
|
||||
uint8_t abtCmdRcs360[] = { InRelease, 0x01, 0x01 };
|
||||
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, NULL));
|
||||
return (pn53x_transceive (pnd, abtCmdRcs360, sizeof (abtCmdRcs360), NULL, NULL, 0));
|
||||
}
|
||||
uint8_t abtCmd[] = { InRelease, ui8Target };
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL));
|
||||
return (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2157,7 +2150,7 @@ pn53x_InAutoPoll (nfc_device * pnd,
|
|||
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
bool res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, &szRx, NULL);
|
||||
bool res = pn53x_transceive (pnd, abtCmd, szTxInAutoPoll, abtRx, &szRx, 0);
|
||||
|
||||
if (res == false) {
|
||||
return false;
|
||||
|
@ -2266,7 +2259,7 @@ pn53x_InJumpForDEP (nfc_device * pnd,
|
|||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
// Try to find a target, call the transceive callback function of the current device
|
||||
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, NULL))
|
||||
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Make sure one target has been found, the PN53X returns 0x00 if none was available
|
||||
|
@ -2347,7 +2340,7 @@ pn53x_TgInitAsTarget (nfc_device * pnd, pn53x_target_mode ptm,
|
|||
// Request the initialization as a target
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, NULL))
|
||||
if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Note: the first byte is skip:
|
||||
|
|
|
@ -127,8 +127,8 @@ typedef enum {
|
|||
} pn53x_operating_mode;
|
||||
|
||||
struct pn53x_io {
|
||||
bool (*send)(nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int (*receive)(nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout);
|
||||
bool (*send)(nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout);
|
||||
int (*receive)(nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, int timeout);
|
||||
};
|
||||
|
||||
/* defines */
|
||||
|
@ -256,7 +256,7 @@ extern const uint8_t pn53x_ack_frame[6];
|
|||
extern const uint8_t pn53x_nack_frame[6];
|
||||
|
||||
bool pn53x_init(nfc_device * pnd);
|
||||
bool pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, struct timeval *timeout);
|
||||
bool pn53x_transceive (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t *pszRx, int timeout);
|
||||
|
||||
bool pn53x_set_parameters (nfc_device * pnd, const uint8_t ui8Value, const bool bEnable);
|
||||
bool pn53x_set_tx_bits (nfc_device * pnd, const uint8_t ui8Bits);
|
||||
|
@ -292,7 +292,7 @@ bool pn53x_initiator_transceive_bits (nfc_device * pnd, const uint8_t * pbtTx
|
|||
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits,
|
||||
uint8_t * pbtRxPar);
|
||||
bool pn53x_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx,
|
||||
uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool pn53x_initiator_transceive_bits_timed (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits,
|
||||
const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits,
|
||||
uint8_t * pbtRxPar, uint32_t * cycles);
|
||||
|
@ -303,21 +303,21 @@ bool pn53x_initiator_deselect_target (nfc_device * pnd);
|
|||
// NFC device as Target functions
|
||||
bool pn53x_target_init (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx);
|
||||
bool pn53x_target_receive_bits (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool pn53x_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool pn53x_target_send_bits (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
|
||||
bool pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool pn53x_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
|
||||
// Error handling functions
|
||||
const char *pn53x_strerror (const nfc_device * pnd);
|
||||
|
||||
// C wrappers for PN53x commands
|
||||
bool pn53x_SetParameters (nfc_device * pnd, const uint8_t ui8Value);
|
||||
bool pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode mode, struct timeval *timeout);
|
||||
bool pn53x_SAMConfiguration (nfc_device * pnd, const pn532_sam_mode mode, int timeout);
|
||||
bool pn53x_PowerDown (nfc_device * pnd);
|
||||
bool pn53x_InListPassiveTarget (nfc_device * pnd, const pn53x_modulation pmInitModulation,
|
||||
const uint8_t szMaxTargets, const uint8_t * pbtInitiatorData,
|
||||
const size_t szInitiatorDataLen, uint8_t * pbtTargetsData, size_t * pszTargetsData,
|
||||
struct timeval *timeout);
|
||||
int timeout);
|
||||
bool pn53x_InDeselect (nfc_device * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InRelease (nfc_device * pnd, const uint8_t ui8Target);
|
||||
bool pn53x_InAutoPoll (nfc_device * pnd, const pn53x_target_type * ppttTargetTypes, const size_t szTargetTypes,
|
||||
|
|
|
@ -310,7 +310,7 @@ acr122_disconnect (nfc_device * pnd)
|
|||
}
|
||||
|
||||
bool
|
||||
acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
@ -381,7 +381,7 @@ acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, str
|
|||
}
|
||||
|
||||
int
|
||||
acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, int timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
|
|
@ -30,8 +30,8 @@ bool acr122_probe (nfc_connstring connstrings[], size_t connstrings_len, size
|
|||
|
||||
// Functions used by developer to handle connection to this device
|
||||
nfc_device *acr122_connect (const nfc_connstring connstring);
|
||||
bool acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
bool acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout);
|
||||
int acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, int timeout);
|
||||
void acr122_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t acr122_driver;
|
||||
|
|
|
@ -304,7 +304,7 @@ arygon_disconnect (nfc_device * pnd)
|
|||
#define ARYGON_TX_BUFFER_LEN (PN53x_NORMAL_FRAME__DATA_MAX_LEN + PN53x_NORMAL_FRAME__OVERHEAD + 1)
|
||||
#define ARYGON_RX_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
bool
|
||||
arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
|
@ -359,14 +359,14 @@ arygon_abort (nfc_device *pnd)
|
|||
// Send a valid TAMA packet to wakup the PN53x (we will not have an answer, according to Arygon manual)
|
||||
uint8_t dummy[] = { 0x32, 0x00, 0x00, 0xff, 0x09, 0xf7, 0xd4, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0xbe, 0x00 };
|
||||
|
||||
uart_send (DRIVER_DATA (pnd)->port, dummy, sizeof (dummy), NULL);
|
||||
uart_send (DRIVER_DATA (pnd)->port, dummy, sizeof (dummy), 0);
|
||||
|
||||
// Using Arygon device we can't send ACK frame to abort the running command
|
||||
return (pn53x_check_communication (pnd)) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, int timeout)
|
||||
{
|
||||
uint8_t abtRxBuf[5];
|
||||
size_t len;
|
||||
|
@ -491,12 +491,12 @@ arygon_firmware (nfc_device * pnd, char * str)
|
|||
size_t szRx = sizeof(abtRx);
|
||||
|
||||
|
||||
int res = uart_send (DRIVER_DATA (pnd)->port, arygon_firmware_version_cmd, sizeof (arygon_firmware_version_cmd), NULL);
|
||||
int res = uart_send (DRIVER_DATA (pnd)->port, arygon_firmware_version_cmd, sizeof (arygon_firmware_version_cmd), 0);
|
||||
if (res != 0) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to send ARYGON firmware command.");
|
||||
return;
|
||||
}
|
||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, NULL);
|
||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 0);
|
||||
if (res != 0) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to retrieve ARYGON firmware version.");
|
||||
return;
|
||||
|
@ -519,15 +519,11 @@ arygon_reset_tama (nfc_device * pnd)
|
|||
size_t szRx = sizeof(abtRx);
|
||||
int res;
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
uart_send (DRIVER_DATA (pnd)->port, arygon_reset_tama_cmd, sizeof (arygon_reset_tama_cmd), &tv);
|
||||
uart_send (DRIVER_DATA (pnd)->port, arygon_reset_tama_cmd, sizeof (arygon_reset_tama_cmd), 1000);
|
||||
|
||||
// Two reply are possible from ARYGON device: arygon_error_none (ie. in case the byte is well-sent)
|
||||
// or arygon_error_unknown_mode (ie. in case of the first byte was bad-transmitted)
|
||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, &tv);
|
||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 1000);
|
||||
if (res != 0) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "No reply to 'reset TAMA' command.");
|
||||
return false;
|
||||
|
|
|
@ -35,8 +35,8 @@ bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size
|
|||
nfc_device *arygon_connect (const nfc_connstring connstring);
|
||||
void arygon_disconnect (nfc_device * pnd);
|
||||
|
||||
bool arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDat, struct timeval *timeouta);
|
||||
bool arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout);
|
||||
int arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDat, int timeouta);
|
||||
|
||||
extern const struct nfc_driver_t arygon_driver;
|
||||
|
||||
|
|
|
@ -282,14 +282,14 @@ pn532_uart_wakeup (nfc_device * pnd)
|
|||
{
|
||||
/* High Speed Unit (HSU) wake up consist to send 0x55 and wait a "long" delay for PN532 being wakeup. */
|
||||
const uint8_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00 };
|
||||
int res = uart_send (DRIVER_DATA(pnd)->port, pn532_wakeup_preamble, sizeof (pn532_wakeup_preamble), NULL);
|
||||
int res = uart_send (DRIVER_DATA(pnd)->port, pn532_wakeup_preamble, sizeof (pn532_wakeup_preamble), 0);
|
||||
CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 should now be awake
|
||||
return res;
|
||||
}
|
||||
|
||||
#define PN532_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
bool
|
||||
pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
|
@ -301,10 +301,7 @@ pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData,
|
|||
return false;
|
||||
}
|
||||
// According to PN532 application note, C106 appendix: to go out Low Vbat mode and enter in normal mode we need to send a SAMConfiguration command
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
if (!pn53x_SAMConfiguration (pnd, 0x01, &tv)) {
|
||||
if (!pn53x_SAMConfiguration (pnd, 0x01, 1000)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +349,7 @@ pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData,
|
|||
}
|
||||
|
||||
int
|
||||
pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, int timeout)
|
||||
{
|
||||
uint8_t abtRxBuf[5];
|
||||
size_t len;
|
||||
|
@ -483,7 +480,7 @@ pn532_uart_ack (nfc_device * pnd)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
return (0 == uart_send (DRIVER_DATA(pnd)->port, pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL)) ? 0 : -1;
|
||||
return (0 == uart_send (DRIVER_DATA(pnd)->port, pn53x_ack_frame, sizeof (pn53x_ack_frame), 0)) ? 0 : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -33,8 +33,8 @@ bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len,
|
|||
|
||||
nfc_device *pn532_uart_connect (const nfc_connstring connstring);
|
||||
void pn532_uart_disconnect (nfc_device * pnd);
|
||||
bool pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
bool pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout);
|
||||
int pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, int timeout);
|
||||
|
||||
extern const struct nfc_driver_t pn532_uart_driver;
|
||||
|
||||
|
|
|
@ -121,11 +121,11 @@ bool pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev
|
|||
bool pn53x_usb_init (nfc_device *pnd);
|
||||
|
||||
int
|
||||
pn53x_usb_bulk_read (struct pn53x_usb_data *data, uint8_t abtRx[], const size_t szRx, struct timeval *timeout)
|
||||
pn53x_usb_bulk_read (struct pn53x_usb_data *data, uint8_t abtRx[], const size_t szRx, int timeout)
|
||||
{
|
||||
int timeout_ms = USB_INFINITE_TIMEOUT;
|
||||
if (timeout) {
|
||||
timeout_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
||||
if (timeout > 0) {
|
||||
timeout_ms = timeout;
|
||||
if (timeout_ms == USB_INFINITE_TIMEOUT) {
|
||||
// timeout < 1 ms
|
||||
timeout_ms++;
|
||||
|
@ -143,12 +143,12 @@ pn53x_usb_bulk_read (struct pn53x_usb_data *data, uint8_t abtRx[], const size_t
|
|||
}
|
||||
|
||||
int
|
||||
pn53x_usb_bulk_write (struct pn53x_usb_data *data, uint8_t abtTx[], const size_t szTx, struct timeval *timeout)
|
||||
pn53x_usb_bulk_write (struct pn53x_usb_data *data, uint8_t abtTx[], const size_t szTx, int timeout)
|
||||
{
|
||||
LOG_HEX ("TX", abtTx, szTx);
|
||||
int timeout_ms = USB_INFINITE_TIMEOUT;
|
||||
if (timeout)
|
||||
timeout_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
||||
if (timeout > 0)
|
||||
timeout_ms = timeout;
|
||||
|
||||
int res = usb_bulk_write (data->pudh, data->uiEndPointOut, (char *) abtTx, szTx, timeout_ms);
|
||||
if (res > 0) {
|
||||
|
@ -519,7 +519,7 @@ pn53x_usb_disconnect (nfc_device * pnd)
|
|||
#define PN53X_USB_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
|
||||
bool
|
||||
pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout)
|
||||
{
|
||||
uint8_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
size_t szFrame = 0;
|
||||
|
@ -565,7 +565,7 @@ pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData,
|
|||
}
|
||||
|
||||
int
|
||||
pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, int timeout)
|
||||
{
|
||||
size_t len;
|
||||
off_t offset = 0;
|
||||
|
@ -583,11 +583,12 @@ pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen,
|
|||
};
|
||||
|
||||
struct timeval remaining_time, usb_timeout;
|
||||
if (timeout) {
|
||||
remaining_time = *timeout;
|
||||
if (timeout > 0) {
|
||||
remaining_time.tv_sec = (timeout / 1000);
|
||||
remaining_time.tv_usec = ((timeout % 1000) * 1000);
|
||||
}
|
||||
read:
|
||||
if (timeout) {
|
||||
if (timeout > 0) {
|
||||
// A user-provided timeout is set, we have to cut it in multiple chunk to be able to keep an nfc_abort_command() mecanism
|
||||
struct timeval tmp;
|
||||
if (1 == timeval_subtract (&tmp, &remaining_time, &fixed_timeout)) {
|
||||
|
@ -607,7 +608,7 @@ read:
|
|||
pnd->iLastError = ECOMTIMEOUT;
|
||||
return -1;
|
||||
}
|
||||
res = pn53x_usb_bulk_read (DRIVER_DATA (pnd), abtRxBuf, sizeof (abtRxBuf), &usb_timeout);
|
||||
res = pn53x_usb_bulk_read (DRIVER_DATA (pnd), abtRxBuf, sizeof (abtRxBuf), ((usb_timeout.tv_sec * 1000) + (usb_timeout.tv_usec / 1000)));
|
||||
|
||||
if (res == -USB_TIMEDOUT) {
|
||||
if (DRIVER_DATA (pnd)->abort_flag) {
|
||||
|
@ -717,7 +718,7 @@ read:
|
|||
int
|
||||
pn53x_usb_ack (nfc_device * pnd)
|
||||
{
|
||||
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (uint8_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), NULL);
|
||||
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (uint8_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame), 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -726,13 +727,13 @@ pn53x_usb_init (nfc_device *pnd)
|
|||
// Sometimes PN53x USB doesn't reply ACK one the first frame, so we need to send a dummy one...
|
||||
//pn53x_check_communication (pnd); // Sony RC-S360 doesn't support this command for now so let's use a get_firmware_version instead:
|
||||
const uint8_t abtCmd[] = { GetFirmwareVersion };
|
||||
pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, 0);
|
||||
// ...and we don't care about error
|
||||
pnd->iLastError = 0;
|
||||
if (SONY_RCS360 == DRIVER_DATA (pnd)->model) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "SONY RC-S360 initialization.");
|
||||
const uint8_t abtCmd2[] = { 0x18, 0x01 };
|
||||
pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, NULL, NULL);
|
||||
pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, NULL, 0);
|
||||
pn53x_usb_ack (pnd);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
|
||||
nfc_device *pn53x_usb_connect (const nfc_connstring connstring);
|
||||
bool pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
bool pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, int timeout);
|
||||
int pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, int timeout);
|
||||
void pn53x_usb_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t pn53x_usb_driver;
|
||||
|
|
|
@ -42,12 +42,12 @@ nfc_emulate_target (nfc_device* pnd, struct nfc_emulator *emulator)
|
|||
while (res >= 0) {
|
||||
res = emulator->state_machine->io (emulator, abtRx, szRx, abtTx, sizeof (abtTx));
|
||||
if (res > 0) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, res, NULL)) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, res, 0)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (res >= 0) {
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, NULL)) {
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, 0)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,14 +136,14 @@ struct nfc_driver_t {
|
|||
bool (*initiator_poll_target) (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) (nfc_device * pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt);
|
||||
bool (*initiator_deselect_target) (nfc_device * pnd);
|
||||
bool (*initiator_transceive_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*initiator_transceive_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool (*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);
|
||||
bool (*initiator_transceive_bytes_timed) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, uint32_t * cycles);
|
||||
bool (*initiator_transceive_bits_timed) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar, uint32_t * cycles);
|
||||
|
||||
bool (*target_init) (nfc_device * pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx);
|
||||
bool (*target_send_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout);
|
||||
bool (*target_receive_bytes) (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout);
|
||||
bool (*target_send_bytes) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
bool (*target_receive_bytes) (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool (*target_send_bits) (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
|
||||
bool (*target_receive_bits) (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
|
||||
|
||||
|
|
12
libnfc/nfc.c
12
libnfc/nfc.c
|
@ -461,7 +461,7 @@ nfc_initiator_deselect_target (nfc_device * pnd)
|
|||
*
|
||||
* @param pbtTx contains a byte array of the frame that needs to be transmitted.
|
||||
* @param szTx contains the length in bytes.
|
||||
* @param timeout timeval struct pointer (NULL means infinite)
|
||||
* @param timeout in milliseconds
|
||||
*
|
||||
* The NFC device (configured as initiator) will transmit the supplied bytes (\a pbtTx) to the target.
|
||||
* It waits for the response and stores the received bytes in the \a pbtRx byte array.
|
||||
|
@ -480,7 +480,7 @@ nfc_initiator_deselect_target (nfc_device * pnd)
|
|||
*/
|
||||
bool
|
||||
nfc_initiator_transceive_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx,
|
||||
size_t * pszRx, struct timeval *timeout)
|
||||
size_t * pszRx, int timeout)
|
||||
{
|
||||
HAL (initiator_transceive_bytes, pnd, pbtTx, szTx, pbtRx, pszRx, timeout)
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ nfc_abort_command (nfc_device * pnd)
|
|||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param pbtTx pointer to Tx buffer
|
||||
* @param szTx size of Tx buffer
|
||||
* @param timeout timeval struct pointer (NULL means infinite)
|
||||
* @param timeout in milliseconds
|
||||
*
|
||||
* This function make the NFC device (configured as \e target) send byte frames
|
||||
* (e.g. APDU responses) to the \e initiator.
|
||||
|
@ -691,7 +691,7 @@ nfc_abort_command (nfc_device * pnd)
|
|||
* If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
|
||||
*/
|
||||
bool
|
||||
nfc_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, struct timeval *timeout)
|
||||
nfc_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szTx, int timeout)
|
||||
{
|
||||
HAL (target_send_bytes, pnd, pbtTx, szTx, timeout);
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ nfc_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szT
|
|||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param[out] pbtRx pointer to Rx buffer
|
||||
* @param[out] pszRx received byte count
|
||||
* @param timeout timeval struct pointer (NULL means infinite)
|
||||
* @param timeout in milliseconds
|
||||
*
|
||||
* This function retrieves bytes frames (e.g. ADPU) sent by the \e initiator to the NFC device (configured as \e target).
|
||||
*
|
||||
|
@ -711,7 +711,7 @@ nfc_target_send_bytes (nfc_device * pnd, const uint8_t * pbtTx, const size_t szT
|
|||
* If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
|
||||
*/
|
||||
bool
|
||||
nfc_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, struct timeval *timeout)
|
||||
nfc_target_receive_bytes (nfc_device * pnd, uint8_t * pbtRx, size_t * pszRx, int timeout)
|
||||
{
|
||||
HAL (target_receive_bytes, pnd, pbtRx, pszRx, timeout);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ nfc_initiator_mifare_cmd (nfc_device * pnd, const mifare_cmd mc, const uint8_t u
|
|||
return false;
|
||||
}
|
||||
// Fire the mifare command
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx, NULL)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx, 0)) {
|
||||
if (pnd->iLastError == EINVRXFRAM) {
|
||||
// "Invalid received frame" AKA EINVRXFRAM, usual means we are
|
||||
// authenticated on a sector but the requested MIFARE cmd (read, write)
|
||||
|
|
|
@ -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, NULL))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
@ -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, NULL))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
@ -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, NULL)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, frame, frame_len, res, &res_len, 0)) {
|
||||
return -1;
|
||||
}
|
||||
const size_t res_overhead = 1 + 1 + 8 + 2; // 1+1+8+2: LEN + CMD + NFCID2 + STATUS
|
||||
|
|
|
@ -370,7 +370,7 @@ main (int argc, char *argv[])
|
|||
bool ret;
|
||||
if (!initiator_only_mode) {
|
||||
// Receive external reader command through target
|
||||
if (!nfc_target_receive_bytes(pndTarget,abtCapdu,&szCapduLen, NULL)) {
|
||||
if (!nfc_target_receive_bytes(pndTarget,abtCapdu,&szCapduLen, 0)) {
|
||||
nfc_perror (pndTarget, "nfc_target_receive_bytes");
|
||||
if (!target_only_mode) {
|
||||
nfc_disconnect (pndInitiator);
|
||||
|
@ -401,7 +401,7 @@ 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, NULL);
|
||||
(pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen, 0);
|
||||
} else {
|
||||
if (scan_hex_fd3(abtRapdu, &szRapduLen, "R-APDU") != EXIT_SUCCESS) {
|
||||
fprintf (stderr, "Error while scanning R-APDU from FD3\n");
|
||||
|
@ -425,7 +425,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
if (!initiator_only_mode) {
|
||||
// Transmit the response bytes
|
||||
if (!nfc_target_send_bytes(pndTarget, abtRapdu, szRapduLen, NULL)) {
|
||||
if (!nfc_target_send_bytes(pndTarget, abtRapdu, szRapduLen, 0)) {
|
||||
nfc_perror (pndTarget, "nfc_target_send_bytes");
|
||||
if (!target_only_mode) {
|
||||
nfc_disconnect (pndInitiator);
|
||||
|
|
Loading…
Add table
Reference in a new issue