Merge r520-546 from trunk.
This commit is contained in:
@@ -205,8 +205,6 @@ nfc_device_t* acr122_connect(const nfc_device_desc_t* pndd)
|
||||
SCARDCONTEXT *pscc;
|
||||
|
||||
DBG("Attempt to connect to %s",pndd->acDevice);
|
||||
// We no longer support connecting with a NULL
|
||||
if(pndd == NULL) return NULL;
|
||||
// Test if context succeeded
|
||||
if (!(pscc = acr122_get_scardcontext ())) return NULL;
|
||||
// Test if we were able to connect to the "emulator" card
|
||||
|
||||
+16
-29
@@ -109,21 +109,13 @@ arygon_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *p
|
||||
*pszDeviceFound = 0;
|
||||
|
||||
serial_port sp;
|
||||
char acPort[BUFFER_LENGTH];
|
||||
int iDevice;
|
||||
const char* pcPorts[] = DEFAULT_SERIAL_PORTS;
|
||||
const char* pcPort;
|
||||
int iDevice = 0;
|
||||
|
||||
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround
|
||||
for (iDevice=0; iDevice<DRIVERS_MAX_DEVICES; iDevice++)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
strncpy(acPort, SERIAL_STRING, BUFFER_LENGTH - 1);
|
||||
acPort[BUFFER_LENGTH - 1] = '\0';
|
||||
#else /* __APPLE__ */
|
||||
snprintf(acPort, BUFFER_LENGTH - 1, "%s%d", SERIAL_STRING, iDevice);
|
||||
acPort[BUFFER_LENGTH - 1] = '\0';
|
||||
#endif /* __APPLE__ */
|
||||
sp = uart_open(acPort);
|
||||
DBG("Trying to find ARYGON device on serial port: %s at %d bauds.",acPort, SERIAL_DEFAULT_PORT_SPEED);
|
||||
while( pcPort = pcPorts[iDevice++] ) {
|
||||
sp = uart_open(pcPort);
|
||||
DBG("Trying to find ARYGON device on serial port: %s at %d bauds.", pcPort, SERIAL_DEFAULT_PORT_SPEED);
|
||||
|
||||
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT))
|
||||
{
|
||||
@@ -132,10 +124,10 @@ arygon_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *p
|
||||
uart_close(sp);
|
||||
|
||||
// ARYGON reader is found
|
||||
snprintf(pnddDevices[*pszDeviceFound].acDevice, DEVICE_NAME_LENGTH - 1, "%s (%s)", "ARYGON", acPort);
|
||||
snprintf(pnddDevices[*pszDeviceFound].acDevice, DEVICE_NAME_LENGTH - 1, "%s (%s)", "ARYGON", pcPort);
|
||||
pnddDevices[*pszDeviceFound].acDevice[DEVICE_NAME_LENGTH - 1] = '\0';
|
||||
pnddDevices[*pszDeviceFound].pcDriver = ARYGON_DRIVER_NAME;
|
||||
pnddDevices[*pszDeviceFound].pcPort = strdup(acPort);
|
||||
pnddDevices[*pszDeviceFound].pcPort = strdup(pcPort);
|
||||
pnddDevices[*pszDeviceFound].uiSpeed = SERIAL_DEFAULT_PORT_SPEED;
|
||||
DBG("Device found: %s.", pnddDevices[*pszDeviceFound].acDevice);
|
||||
(*pszDeviceFound)++;
|
||||
@@ -144,8 +136,8 @@ arygon_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *p
|
||||
if((*pszDeviceFound) >= szDevices) break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (sp == INVALID_SERIAL_PORT) DBG("Invalid serial port: %s",acPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acPort);
|
||||
if (sp == INVALID_SERIAL_PORT) DBG("Invalid serial port: %s", pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s", pcPort);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
#endif /* SERIAL_AUTOPROBE_ENABLED */
|
||||
@@ -157,19 +149,14 @@ nfc_device_t* arygon_connect(const nfc_device_desc_t* pndd)
|
||||
serial_port sp;
|
||||
nfc_device_t* pnd = NULL;
|
||||
|
||||
if( pndd == NULL ) {
|
||||
DBG("%s", "arygon_connect() need an nfc_device_desc_t struct.");
|
||||
return NULL;
|
||||
} else {
|
||||
DBG("Attempt to connect to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
sp = uart_open(pndd->pcPort);
|
||||
DBG("Attempt to connect to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
sp = uart_open(pndd->pcPort);
|
||||
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",pndd->pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",pndd->pcPort);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",pndd->pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",pndd->pcPort);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
}
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
|
||||
DBG("Successfully connected to: %s",pndd->pcPort);
|
||||
|
||||
|
||||
+19
-32
@@ -84,21 +84,13 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_
|
||||
*pszDeviceFound = 0;
|
||||
|
||||
serial_port sp;
|
||||
char acPort[BUFFER_LENGTH];
|
||||
int iDevice;
|
||||
|
||||
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround
|
||||
for (iDevice=0; iDevice<DRIVERS_MAX_DEVICES; iDevice++)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
strncpy(acPort,SERIAL_STRING, BUFFER_LENGTH - 1);
|
||||
acPort[BUFFER_LENGTH - 1] = '\0';
|
||||
#else /* __APPLE__ */
|
||||
snprintf(acPort,BUFFER_LENGTH - 1,"%s%d",SERIAL_STRING,iDevice);
|
||||
acPort[BUFFER_LENGTH - 1] = '\0';
|
||||
#endif /* __APPLE__ */
|
||||
sp = uart_open(acPort);
|
||||
DBG("Trying to find PN532 device on serial port: %s at %d bauds.",acPort, SERIAL_DEFAULT_PORT_SPEED);
|
||||
const char* pcPorts[] = DEFAULT_SERIAL_PORTS;
|
||||
const char* pcPort;
|
||||
int iDevice = 0;
|
||||
|
||||
while( pcPort = pcPorts[iDevice++] ) {
|
||||
sp = uart_open(pcPort);
|
||||
DBG("Trying to find PN532 device on serial port: %s at %d bauds.", pcPort, SERIAL_DEFAULT_PORT_SPEED);
|
||||
|
||||
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT))
|
||||
{
|
||||
@@ -114,11 +106,10 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_
|
||||
continue;
|
||||
uart_close(sp);
|
||||
|
||||
snprintf(pnddDevices[*pszDeviceFound].acDevice, DEVICE_NAME_LENGTH - 1, "%s (%s)", "PN532", acPort);
|
||||
snprintf(pnddDevices[*pszDeviceFound].acDevice, DEVICE_NAME_LENGTH - 1, "%s (%s)", "PN532", pcPort);
|
||||
pnddDevices[*pszDeviceFound].acDevice[DEVICE_NAME_LENGTH - 1] = '\0';
|
||||
pnddDevices[*pszDeviceFound].pcDriver = PN532_UART_DRIVER_NAME;
|
||||
pnddDevices[*pszDeviceFound].pcPort = strdup(acPort);
|
||||
pnddDevices[*pszDeviceFound].pcPort[BUFFER_LENGTH] = '\0';
|
||||
pnddDevices[*pszDeviceFound].pcPort = strdup(pcPort);
|
||||
pnddDevices[*pszDeviceFound].uiSpeed = SERIAL_DEFAULT_PORT_SPEED;
|
||||
DBG("Device found: %s.", pnddDevices[*pszDeviceFound].acDevice);
|
||||
(*pszDeviceFound)++;
|
||||
@@ -127,8 +118,8 @@ pn532_uart_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_
|
||||
if((*pszDeviceFound) >= szDevices) break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (sp == INVALID_SERIAL_PORT) DBG("Invalid serial port: %s",acPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s",acPort);
|
||||
if (sp == INVALID_SERIAL_PORT) DBG("Invalid serial port: %s", pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) DBG("Serial port already claimed: %s", pcPort);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
#endif /* SERIAL_AUTOPROBE_ENABLED */
|
||||
@@ -141,19 +132,15 @@ nfc_device_t* pn532_uart_connect(const nfc_device_desc_t* pndd)
|
||||
nfc_device_t* pnd = NULL;
|
||||
bool bComOk;
|
||||
|
||||
if( pndd == NULL ) {
|
||||
DBG("%s", "pn532_uart_connect() need an nfc_device_desc_t struct.");
|
||||
return NULL;
|
||||
} else {
|
||||
DBG("Attempt to connect to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
sp = uart_open(pndd->pcPort);
|
||||
DBG("Attempt to connect to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
sp = uart_open(pndd->pcPort);
|
||||
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",pndd->pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",pndd->pcPort);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",pndd->pcPort);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",pndd->pcPort);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
}
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
|
||||
// PN532 could be powered down, we need to wake it up before line testing.
|
||||
pn532_uart_wakeup((nfc_device_spec_t)sp);
|
||||
// Check communication using "Diagnose" command, with "Comunication test" (0x00)
|
||||
@@ -240,7 +227,7 @@ bool pn532_uart_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
PRINT_HEX("RX", abtRxBuf,szRxBufLen);
|
||||
#endif
|
||||
|
||||
// When the answer should be ignored, just return a successful result
|
||||
|
||||
@@ -162,9 +162,6 @@ nfc_device_t* pn53x_usb_connect(const nfc_device_desc_t* pndd,const char * targe
|
||||
us.uiEndPointOut = 0;
|
||||
us.pudh = NULL;
|
||||
|
||||
// must specify device to connect to
|
||||
if(pndd == NULL) return NULL;
|
||||
|
||||
DBG("Attempt to connect to %s device", target_name);
|
||||
usb_init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user