Skip to content

Commit

Permalink
more debuggers and fix auto-connecting to libusb devices (still no wa…
Browse files Browse the repository at this point in the history
…y to list them though)
  • Loading branch information
AdamLaurie committed Dec 2, 2009
1 parent c449fe8 commit b8a9a7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/examples/nfc-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
*/

Expand Down
14 changes: 12 additions & 2 deletions src/lib/drivers/pn531_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,25 @@ 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;
us.pudh = NULL;

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 ) {
Expand Down
15 changes: 11 additions & 4 deletions src/lib/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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
}
}
Expand All @@ -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 ) )
Expand Down

0 comments on commit b8a9a7d

Please sign in to comment.