more debuggers and fix auto-connecting to libusb devices (still no way to list them though)
This commit is contained in:
parent
c449fe8561
commit
b8a9a7d743
3 changed files with 25 additions and 7 deletions
|
@ -49,6 +49,7 @@ int main(int argc, const char* argv[])
|
||||||
printf("%s use libnfc %s\n", argv[0], acLibnfcVersion);
|
printf("%s use libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
||||||
// Lazy way to open an NFC device
|
// Lazy way to open an NFC device
|
||||||
|
|
||||||
/*
|
/*
|
||||||
pnd = nfc_connect(NULL);
|
pnd = nfc_connect(NULL);
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -95,6 +95,7 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
|
||||||
usb_spec_t* pus;
|
usb_spec_t* pus;
|
||||||
usb_spec_t us;
|
usb_spec_t us;
|
||||||
uint32_t uiDevIndex;
|
uint32_t uiDevIndex;
|
||||||
|
int devs;
|
||||||
|
|
||||||
us.uiEndPointIn = 0;
|
us.uiEndPointIn = 0;
|
||||||
us.uiEndPointOut = 0;
|
us.uiEndPointOut = 0;
|
||||||
|
@ -102,8 +103,17 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
|
||||||
|
|
||||||
DBG("%s", "Looking for PN531 device");
|
DBG("%s", "Looking for PN531 device");
|
||||||
usb_init();
|
usb_init();
|
||||||
if (usb_find_busses() < 0) return NULL;
|
if (usb_find_busses() < 0)
|
||||||
if (usb_find_devices() < 0) return NULL;
|
{
|
||||||
|
DBG("%s","No USB bus found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if ((devs= usb_find_devices()) < 0)
|
||||||
|
{
|
||||||
|
DBG("%s","No USB devices found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
DBG("%i USB candidates found",devs);
|
||||||
|
|
||||||
// Initialize the device index we are seaching for
|
// Initialize the device index we are seaching for
|
||||||
if( pndd == NULL ) {
|
if( pndd == NULL ) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszD
|
||||||
{
|
{
|
||||||
if (drivers_callbacks_list[uiDriver].list_devices != NULL)
|
if (drivers_callbacks_list[uiDriver].list_devices != NULL)
|
||||||
{
|
{
|
||||||
DBG("Checking driver: %s",drivers_callbacks_list[uiDriver]);
|
DBG("Checking driver: %s",drivers_callbacks_list[uiDriver].acDriver);
|
||||||
size_t szN = 0;
|
size_t szN = 0;
|
||||||
if (drivers_callbacks_list[uiDriver].list_devices (pnddDevices + (*pszDeviceFound), szDevices - (*pszDeviceFound), &szN))
|
if (drivers_callbacks_list[uiDriver].list_devices (pnddDevices + (*pszDeviceFound), szDevices - (*pszDeviceFound), &szN))
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszD
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else
|
else
|
||||||
DBG("Not checking driver: %s",drivers_callbacks_list[uiDriver]);
|
DBG("Not checking driver: %s",drivers_callbacks_list[uiDriver].acDriver);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,16 @@ nfc_device_t* nfc_connect(nfc_device_desc_t* pndd)
|
||||||
{
|
{
|
||||||
if (pndd == NULL) {
|
if (pndd == NULL) {
|
||||||
// No device description specified: try to automatically claim a device
|
// No device description specified: try to automatically claim a device
|
||||||
DBG("%s","Autodetecting available devices...");
|
DBG("Autodetecting available devices: %s", drivers_callbacks_list[uiDriver].acDriver);
|
||||||
pndd = drivers_callbacks_list[uiDriver].pick_device ();
|
if(drivers_callbacks_list[uiDriver].pick_device != NULL)
|
||||||
|
pndd = drivers_callbacks_list[uiDriver].pick_device ();
|
||||||
|
DBG("Auto-connecting %s device",drivers_callbacks_list[uiDriver].acDriver);
|
||||||
pnd = drivers_callbacks_list[uiDriver].connect(pndd);
|
pnd = drivers_callbacks_list[uiDriver].connect(pndd);
|
||||||
|
if(pnd == NULL)
|
||||||
|
{
|
||||||
|
DBG("%s Not found",drivers_callbacks_list[uiDriver].acDriver);
|
||||||
|
pndd = NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Specific device is requested: using device description pndd
|
// Specific device is requested: using device description pndd
|
||||||
if( 0 != strcmp(drivers_callbacks_list[uiDriver].acDriver, pndd->pcDriver ) )
|
if( 0 != strcmp(drivers_callbacks_list[uiDriver].acDriver, pndd->pcDriver ) )
|
||||||
|
|
Loading…
Add table
Reference in a new issue