Change byte_t type to uint8_t (Fixes Issue 147)
This commit is contained in:
+10
-10
@@ -89,7 +89,7 @@ const char *supported_devices[] = {
|
||||
struct acr122_data {
|
||||
SCARDHANDLE hCard;
|
||||
SCARD_IO_REQUEST ioCard;
|
||||
byte_t abtRx[ACR122_RESPONSE_LEN];
|
||||
uint8_t abtRx[ACR122_RESPONSE_LEN];
|
||||
size_t szRx;
|
||||
};
|
||||
|
||||
@@ -310,7 +310,7 @@ acr122_disconnect (nfc_device * pnd)
|
||||
}
|
||||
|
||||
bool
|
||||
acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
@@ -323,7 +323,7 @@ acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, stru
|
||||
|
||||
// Prepare and transmit the send buffer
|
||||
const size_t szTxBuf = szData + 6;
|
||||
byte_t abtTxBuf[ACR122_WRAP_LEN + ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00, szData + 1, 0xD4 };
|
||||
uint8_t abtTxBuf[ACR122_WRAP_LEN + ACR122_COMMAND_LEN] = { 0xFF, 0x00, 0x00, 0x00, szData + 1, 0xD4 };
|
||||
memcpy (abtTxBuf + 6, pbtData, szData);
|
||||
LOG_HEX ("TX", abtTxBuf, szTxBuf);
|
||||
|
||||
@@ -381,13 +381,13 @@ acr122_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, stru
|
||||
}
|
||||
|
||||
int
|
||||
acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
acr122_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
||||
int len;
|
||||
byte_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
|
||||
uint8_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
|
||||
|
||||
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_T0) {
|
||||
/*
|
||||
@@ -424,16 +424,16 @@ acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct
|
||||
char *
|
||||
acr122_firmware (nfc_device *pnd)
|
||||
{
|
||||
byte_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
|
||||
uint8_t abtGetFw[5] = { 0xFF, 0x00, 0x48, 0x00, 0x00 };
|
||||
uint32_t uiResult;
|
||||
|
||||
static char abtFw[11];
|
||||
DWORD dwFwLen = sizeof (abtFw);
|
||||
memset (abtFw, 0x00, sizeof (abtFw));
|
||||
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {
|
||||
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (byte_t *) abtFw, dwFwLen-1, &dwFwLen);
|
||||
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (uint8_t *) abtFw, dwFwLen-1, &dwFwLen);
|
||||
} else {
|
||||
uiResult = SCardTransmit (DRIVER_DATA (pnd)->hCard, &(DRIVER_DATA (pnd)->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (byte_t *) abtFw, &dwFwLen);
|
||||
uiResult = SCardTransmit (DRIVER_DATA (pnd)->hCard, &(DRIVER_DATA (pnd)->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (uint8_t *) abtFw, &dwFwLen);
|
||||
}
|
||||
|
||||
if (uiResult != SCARD_S_SUCCESS) {
|
||||
@@ -447,8 +447,8 @@ acr122_firmware (nfc_device *pnd)
|
||||
bool
|
||||
acr122_led_red (nfc_device *pnd, bool bOn)
|
||||
{
|
||||
byte_t abtLed[9] = { 0xFF, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00 };
|
||||
byte_t abtBuf[2];
|
||||
uint8_t abtLed[9] = { 0xFF, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t abtBuf[2];
|
||||
DWORD dwBufLen = sizeof (abtBuf);
|
||||
(void) bOn;
|
||||
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {
|
||||
|
||||
@@ -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 byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int acr122_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
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);
|
||||
void acr122_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t acr122_driver;
|
||||
|
||||
+16
-16
@@ -84,9 +84,9 @@ struct arygon_data {
|
||||
#endif
|
||||
};
|
||||
|
||||
static const byte_t arygon_error_none[] = "FF000000\x0d\x0a";
|
||||
static const byte_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
|
||||
static const byte_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a";
|
||||
static const uint8_t arygon_error_none[] = "FF000000\x0d\x0a";
|
||||
static const uint8_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
|
||||
static const uint8_t arygon_error_unknown_mode[] = "FF060000\x0d\x0a";
|
||||
|
||||
bool arygon_reset_tama (nfc_device * pnd);
|
||||
void arygon_firmware (nfc_device * pnd, char * str);
|
||||
@@ -304,12 +304,12 @@ 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 byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
arygon_tama_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
|
||||
byte_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
|
||||
uint8_t abtFrame[ARYGON_TX_BUFFER_LEN] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "0x32 0x00 0x00 0xff"
|
||||
|
||||
size_t szFrame = 0;
|
||||
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
|
||||
@@ -331,7 +331,7 @@ arygon_tama_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
|
||||
return false;
|
||||
}
|
||||
|
||||
byte_t abtRxBuf[6];
|
||||
uint8_t abtRxBuf[6];
|
||||
res = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, sizeof (abtRxBuf), 0, timeout);
|
||||
if (res != 0) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Unable to read ACK");
|
||||
@@ -357,7 +357,7 @@ int
|
||||
arygon_abort (nfc_device *pnd)
|
||||
{
|
||||
// Send a valid TAMA packet to wakup the PN53x (we will not have an answer, according to Arygon manual)
|
||||
byte_t dummy[] = { 0x32, 0x00, 0x00, 0xff, 0x09, 0xf7, 0xd4, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0xbe, 0x00 };
|
||||
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);
|
||||
|
||||
@@ -366,9 +366,9 @@ arygon_abort (nfc_device *pnd)
|
||||
}
|
||||
|
||||
int
|
||||
arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
arygon_tama_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtRxBuf[5];
|
||||
uint8_t abtRxBuf[5];
|
||||
size_t len;
|
||||
void * abort_p = NULL;
|
||||
|
||||
@@ -393,7 +393,7 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
|
||||
pnd->iLastError = ECOMIO;
|
||||
@@ -462,7 +462,7 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte_t btDCS = (256 - 0xD5);
|
||||
uint8_t btDCS = (256 - 0xD5);
|
||||
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
|
||||
for (size_t szPos = 0; szPos < len; szPos++) {
|
||||
btDCS -= pbtData[szPos];
|
||||
@@ -486,8 +486,8 @@ arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
|
||||
void
|
||||
arygon_firmware (nfc_device * pnd, char * str)
|
||||
{
|
||||
const byte_t arygon_firmware_version_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'v' };
|
||||
byte_t abtRx[16];
|
||||
const uint8_t arygon_firmware_version_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'v' };
|
||||
uint8_t abtRx[16];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ arygon_firmware (nfc_device * pnd, char * str)
|
||||
}
|
||||
|
||||
if ( 0 == memcmp (abtRx, arygon_error_none, 6)) {
|
||||
byte_t * p = abtRx + 6;
|
||||
uint8_t * p = abtRx + 6;
|
||||
unsigned int szData;
|
||||
sscanf ((const char*)p, "%02x%s", &szData, p);
|
||||
memcpy (str, p, szData);
|
||||
@@ -514,8 +514,8 @@ arygon_firmware (nfc_device * pnd, char * str)
|
||||
bool
|
||||
arygon_reset_tama (nfc_device * pnd)
|
||||
{
|
||||
const byte_t arygon_reset_tama_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'r' };
|
||||
byte_t abtRx[10]; // Attempted response is 10 bytes long
|
||||
const uint8_t arygon_reset_tama_cmd[] = { DEV_ARYGON_PROTOCOL_ARYGON_ASCII, 'a', 'r' };
|
||||
uint8_t abtRx[10]; // Attempted response is 10 bytes long
|
||||
size_t szRx = sizeof(abtRx);
|
||||
int res;
|
||||
|
||||
|
||||
@@ -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 byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int arygon_tama_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDat, struct timeval *timeouta);
|
||||
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);
|
||||
|
||||
extern const struct nfc_driver_t arygon_driver;
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ int
|
||||
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 byte_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00 };
|
||||
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);
|
||||
CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 should now be awake
|
||||
return res;
|
||||
@@ -289,7 +289,7 @@ pn532_uart_wakeup (nfc_device * pnd)
|
||||
|
||||
#define PN532_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
bool
|
||||
pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn532_uart_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
// Before sending anything, we need to discard from any junk bytes
|
||||
uart_flush_input (DRIVER_DATA(pnd)->port);
|
||||
@@ -320,7 +320,7 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
|
||||
break;
|
||||
};
|
||||
|
||||
byte_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
uint8_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
size_t szFrame = 0;
|
||||
|
||||
if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) {
|
||||
@@ -335,7 +335,7 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
|
||||
return false;
|
||||
}
|
||||
|
||||
byte_t abtRxBuf[6];
|
||||
uint8_t abtRxBuf[6];
|
||||
res = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 6, 0, timeout);
|
||||
if (res != 0) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Unable to read ACK");
|
||||
@@ -352,9 +352,9 @@ pn532_uart_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData,
|
||||
}
|
||||
|
||||
int
|
||||
pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn532_uart_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtRxBuf[5];
|
||||
uint8_t abtRxBuf[5];
|
||||
size_t len;
|
||||
void * abort_p = NULL;
|
||||
|
||||
@@ -376,7 +376,7 @@ pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
|
||||
pnd->iLastError = ECOMIO;
|
||||
@@ -454,7 +454,7 @@ pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen,
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte_t btDCS = (256 - 0xD5);
|
||||
uint8_t btDCS = (256 - 0xD5);
|
||||
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
|
||||
for (size_t szPos = 0; szPos < len; szPos++) {
|
||||
btDCS -= pbtData[szPos];
|
||||
|
||||
@@ -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 byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn532_uart_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
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);
|
||||
|
||||
extern const struct nfc_driver_t pn532_uart_driver;
|
||||
|
||||
|
||||
+13
-13
@@ -121,7 +121,7 @@ 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, byte_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, struct timeval *timeout)
|
||||
{
|
||||
int timeout_ms = USB_INFINITE_TIMEOUT;
|
||||
if (timeout) {
|
||||
@@ -143,7 +143,7 @@ pn53x_usb_bulk_read (struct pn53x_usb_data *data, byte_t abtRx[], const size_t s
|
||||
}
|
||||
|
||||
int
|
||||
pn53x_usb_bulk_write (struct pn53x_usb_data *data, byte_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, struct timeval *timeout)
|
||||
{
|
||||
LOG_HEX ("TX", abtTx, szTx);
|
||||
int timeout_ms = USB_INFINITE_TIMEOUT;
|
||||
@@ -519,9 +519,9 @@ 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 byte_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
pn53x_usb_send (nfc_device * pnd, const uint8_t * pbtData, const size_t szData, struct timeval *timeout)
|
||||
{
|
||||
byte_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
uint8_t abtFrame[PN53X_USB_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
|
||||
size_t szFrame = 0;
|
||||
|
||||
pn53x_build_frame (abtFrame, &szFrame, pbtData, szData);
|
||||
@@ -533,7 +533,7 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
|
||||
return false;
|
||||
}
|
||||
|
||||
byte_t abtRxBuf[PN53X_USB_BUFFER_LEN];
|
||||
uint8_t abtRxBuf[PN53X_USB_BUFFER_LEN];
|
||||
res = pn53x_usb_bulk_read (DRIVER_DATA (pnd), abtRxBuf, sizeof (abtRxBuf), timeout);
|
||||
if (res < 0) {
|
||||
pnd->iLastError = ECOMIO;
|
||||
@@ -552,7 +552,7 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
|
||||
// pn53x_usb_receive()) will be able to retreive the correct response
|
||||
// packet.
|
||||
// FIXME Sony reader is also affected by this bug but NACK is not supported
|
||||
int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *)pn53x_nack_frame, sizeof(pn53x_nack_frame), timeout);
|
||||
int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (uint8_t *)pn53x_nack_frame, sizeof(pn53x_nack_frame), timeout);
|
||||
if (res < 0) {
|
||||
pnd->iLastError = ECOMIO;
|
||||
// try to interrupt current device state
|
||||
@@ -565,12 +565,12 @@ pn53x_usb_send (nfc_device * pnd, const byte_t * pbtData, const size_t szData, s
|
||||
}
|
||||
|
||||
int
|
||||
pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
pn53x_usb_receive (nfc_device * pnd, uint8_t * pbtData, const size_t szDataLen, struct timeval *timeout)
|
||||
{
|
||||
size_t len;
|
||||
off_t offset = 0;
|
||||
|
||||
byte_t abtRxBuf[PN53X_USB_BUFFER_LEN];
|
||||
uint8_t abtRxBuf[PN53X_USB_BUFFER_LEN];
|
||||
int res;
|
||||
|
||||
/*
|
||||
@@ -627,7 +627,7 @@ read:
|
||||
return -1;
|
||||
}
|
||||
|
||||
const byte_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
const uint8_t pn53x_preamble[3] = { 0x00, 0x00, 0xff };
|
||||
if (0 != (memcmp (abtRxBuf, pn53x_preamble, 3))) {
|
||||
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Frame preamble+start code mismatch");
|
||||
pnd->iLastError = ECOMIO;
|
||||
@@ -691,7 +691,7 @@ read:
|
||||
memcpy (pbtData, abtRxBuf + offset, len);
|
||||
offset += len;
|
||||
|
||||
byte_t btDCS = (256 - 0xD5);
|
||||
uint8_t btDCS = (256 - 0xD5);
|
||||
btDCS -= CHIP_DATA (pnd)->ui8LastCommand + 1;
|
||||
for (size_t szPos = 0; szPos < len; szPos++) {
|
||||
btDCS -= pbtData[szPos];
|
||||
@@ -717,7 +717,7 @@ read:
|
||||
int
|
||||
pn53x_usb_ack (nfc_device * pnd)
|
||||
{
|
||||
return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_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), NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -725,13 +725,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 byte_t abtCmd[] = { GetFirmwareVersion };
|
||||
const uint8_t abtCmd[] = { GetFirmwareVersion };
|
||||
pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, NULL);
|
||||
// ...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 byte_t abtCmd2[] = { 0x18, 0x01 };
|
||||
const uint8_t abtCmd2[] = { 0x18, 0x01 };
|
||||
pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, NULL, NULL);
|
||||
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 byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
int pn53x_usb_receive (nfc_device * pnd, byte_t * pbtData, const size_t szData, struct timeval *timeout);
|
||||
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);
|
||||
void pn53x_usb_disconnect (nfc_device * pnd);
|
||||
|
||||
extern const struct nfc_driver_t pn53x_usb_driver;
|
||||
|
||||
Reference in New Issue
Block a user