drivers/arygon,pn532_uart,pn53x_usb: all PN53x commands are now cancelable

This commit is contained in:
Romuald Conty 2011-09-29 14:53:52 +00:00
parent 49ab6a7f31
commit 8f7834c625
7 changed files with 54 additions and 73 deletions

View file

@ -831,7 +831,11 @@ pn53x_check_communication (nfc_device_t *pnd)
byte_t abtRx[sizeof(abtExpectedRx)];
size_t szRx = sizeof (abtRx);
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, NULL))
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
if (!pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, &timeout))
return false;
return ((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx))));
@ -1935,7 +1939,7 @@ pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value)
}
bool
pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode)
pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode, struct timeval *timeout)
{
byte_t abtCmd[] = { SAMConfiguration, ui8Mode, 0x00, 0x00 };
size_t szCmd = sizeof(abtCmd);
@ -1960,7 +1964,7 @@ pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode ui8Mode)
pnd->iLastError = EINVALARG;
return false;
}
return (pn53x_transceive (pnd, abtCmd, szCmd, NULL, NULL, NULL));
return (pn53x_transceive (pnd, abtCmd, szCmd, NULL, NULL, timeout));
}
bool

View file

@ -313,7 +313,7 @@ const char *pn53x_strerror (const nfc_device_t * pnd);
// C wrappers for PN53x commands
bool pn53x_SetParameters (nfc_device_t * pnd, const uint8_t ui8Value);
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode mode);
bool pn53x_SAMConfiguration (nfc_device_t * pnd, const pn532_sam_mode mode, struct timeval *timeout);
bool pn53x_PowerDown (nfc_device_t * pnd);
bool pn53x_InListPassiveTarget (nfc_device_t * pnd, const pn53x_modulation_t pmInitModulation,
const byte_t szMaxTargets, const byte_t * pbtInitiatorData,