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,7 +49,8 @@ int main(int argc, const char* argv[])
|
|||
printf("%s use libnfc %s\n", argv[0], acLibnfcVersion);
|
||||
|
||||
// Lazy way to open an NFC device
|
||||
/*
|
||||
|
||||
/*
|
||||
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 us;
|
||||
uint32_t uiDevIndex;
|
||||
int devs;
|
||||
|
||||
us.uiEndPointIn = 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");
|
||||
usb_init();
|
||||
if (usb_find_busses() < 0) return NULL;
|
||||
if (usb_find_devices() < 0) return NULL;
|
||||
if (usb_find_busses() < 0)
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
DBG("Checking driver: %s",drivers_callbacks_list[uiDriver]);
|
||||
DBG("Checking driver: %s",drivers_callbacks_list[uiDriver].acDriver);
|
||||
size_t szN = 0;
|
||||
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
|
||||
else
|
||||
DBG("Not checking driver: %s",drivers_callbacks_list[uiDriver]);
|
||||
DBG("Not checking driver: %s",drivers_callbacks_list[uiDriver].acDriver);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +120,16 @@ nfc_device_t* nfc_connect(nfc_device_desc_t* pndd)
|
|||
{
|
||||
if (pndd == NULL) {
|
||||
// No device description specified: try to automatically claim a device
|
||||
DBG("%s","Autodetecting available devices...");
|
||||
pndd = drivers_callbacks_list[uiDriver].pick_device ();
|
||||
DBG("Autodetecting available devices: %s", drivers_callbacks_list[uiDriver].acDriver);
|
||||
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);
|
||||
if(pnd == NULL)
|
||||
{
|
||||
DBG("%s Not found",drivers_callbacks_list[uiDriver].acDriver);
|
||||
pndd = NULL;
|
||||
}
|
||||
} else {
|
||||
// Specific device is requested: using device description pndd
|
||||
if( 0 != strcmp(drivers_callbacks_list[uiDriver].acDriver, pndd->pcDriver ) )
|
||||
|
|
Loading…
Add table
Reference in a new issue