Return an error when a command is aborted;
Fix aborting with UART devices.
This commit is contained in:
parent
605a5f2db3
commit
2cca743e07
3 changed files with 28 additions and 31 deletions
|
@ -124,7 +124,7 @@ main (void)
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("Unable to connect to NFC device");
|
ERR("Unable to connect to NFC device");
|
||||||
return EXIT_FAILURE;
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
signal (SIGINT, stop_emulation);
|
signal (SIGINT, stop_emulation);
|
||||||
|
@ -152,11 +152,11 @@ main (void)
|
||||||
print_nfc_iso14443a_info (nt.nti.nai, true);
|
print_nfc_iso14443a_info (nt.nti.nai, true);
|
||||||
if (!nfc_target_init (pnd, &nt, abtRx, &szRx)) {
|
if (!nfc_target_init (pnd, &nt, abtRx, &szRx)) {
|
||||||
if (pnd->iLastError == DEABORT) {
|
if (pnd->iLastError == DEABORT) {
|
||||||
errx (EXIT_SUCCESS, "Operation canceld by keystroke.");
|
errx (EXIT_SUCCESS, "Operation canceled by keystroke.");
|
||||||
}
|
}
|
||||||
nfc_perror (pnd, "nfc_target_init");
|
nfc_perror (pnd, "nfc_target_init");
|
||||||
ERR("Could not come out of auto-emulation, no command was received");
|
ERR("Could not come out of auto-emulation, no command was received");
|
||||||
return EXIT_FAILURE;
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
|
|
|
@ -263,15 +263,18 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 5, abort_fd);
|
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 5, abort_fd);
|
||||||
|
|
||||||
if (abort_fd && (DEABORT == res)) {
|
if (abort_fd && (DEABORT == pnd->iLastError)) {
|
||||||
return arygon_abort (pnd);
|
arygon_abort (pnd);
|
||||||
|
|
||||||
|
/* iLastError got reset by arygon_abort() */
|
||||||
|
pnd->iLastError = DEABORT;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,10 +315,9 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
|
||||||
}
|
}
|
||||||
|
|
||||||
// TFI + PD0 (CC+1)
|
// TFI + PD0 (CC+1)
|
||||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,18 +334,16 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
res = uart_receive (DRIVER_DATA (pnd)->port, pbtData, len, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, pbtData, len, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,15 +243,15 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 5, abort_fd);
|
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 5, abort_fd);
|
||||||
|
|
||||||
if (abort_fd && (DEABORT == res)) {
|
if (abort_fd && (DEABORT == pnd->iLastError)) {
|
||||||
return pn532_uart_ack (pnd);
|
pn532_uart_ack (pnd);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,10 +292,9 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
|
||||||
}
|
}
|
||||||
|
|
||||||
// TFI + PD0 (CC+1)
|
// TFI + PD0 (CC+1)
|
||||||
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,18 +311,16 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
res = uart_receive (DRIVER_DATA(pnd)->port, pbtData, len, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, pbtData, len, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
|
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
|
||||||
if (res != 0) {
|
if (pnd->iLastError != 0) {
|
||||||
ERR ("%s", "Unable to receive data. (RX)");
|
ERR ("%s", "Unable to receive data. (RX)");
|
||||||
pnd->iLastError = res;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue