Return an error when a command is aborted;

Fix aborting with UART devices.
This commit is contained in:
Romain Tartiere 2011-03-09 14:10:40 +00:00
parent 605a5f2db3
commit 2cca743e07
3 changed files with 28 additions and 31 deletions

View file

@ -263,15 +263,18 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
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)) {
return arygon_abort (pnd);
if (abort_fd && (DEABORT == pnd->iLastError)) {
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)");
pnd->iLastError = res;
return -1;
}
@ -312,10 +315,9 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
}
// TFI + PD0 (CC+1)
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}
@ -332,18 +334,16 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe
}
if (len) {
res = uart_receive (DRIVER_DATA (pnd)->port, pbtData, len, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, pbtData, len, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}
}
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 2, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}

View file

@ -243,15 +243,15 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
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)) {
return pn532_uart_ack (pnd);
if (abort_fd && (DEABORT == pnd->iLastError)) {
pn532_uart_ack (pnd);
return -1;
}
if (res != 0) {
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}
@ -292,10 +292,9 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
}
// TFI + PD0 (CC+1)
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}
@ -312,18 +311,16 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen
}
if (len) {
res = uart_receive (DRIVER_DATA(pnd)->port, pbtData, len, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, pbtData, len, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}
}
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
if (res != 0) {
pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 2, 0);
if (pnd->iLastError != 0) {
ERR ("%s", "Unable to receive data. (RX)");
pnd->iLastError = res;
return -1;
}