aboutsummaryrefslogtreecommitdiffstats
path: root/linux/cusblinux-1.0.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/cusblinux-1.0.c')
-rw-r--r--linux/cusblinux-1.0.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/linux/cusblinux-1.0.c b/linux/cusblinux-1.0.c
index 4b43b1d..204ef53 100644
--- a/linux/cusblinux-1.0.c
+++ b/linux/cusblinux-1.0.c
@@ -261,8 +261,8 @@ static int getLabelString(CPhidgetHandle phid, struct libusb_device_handle *hand
{
case LIBUSB_ERROR_TIMEOUT: //important case?
default:
- LOG(PHIDGET_LOG_INFO, "libusb_get_string_descriptor failed in CUSBGetDeviceCapabilities with error code: %d while reading label\
- - this probably just means the device doesn't support labels, so this is fine.", len);
+ LOG(PHIDGET_LOG_INFO, "libusb_get_string_descriptor failed in CUSBGetDeviceCapabilities with error code: %d while reading label"\
+ " - this probably just means the device doesn't support labels, so this is fine.", len);
}
phid->label[0]='\0';
return EPHIDGET_OK;
@@ -407,7 +407,7 @@ int CUSBBuildList(CPhidgetList **curList) {
}
}
- ssize_t cnt = libusb_get_device_list(NULL, &list);
+ ssize_t cnt = libusb_get_device_list(libusbContext, &list);
if(cnt < 0)
{
LOG(PHIDGET_LOG_ERROR, "libusb_get_device_list failed with error code: %d", cnt);
@@ -456,7 +456,7 @@ int CUSBBuildList(CPhidgetList **curList) {
//LOG(PHIDGET_LOG_DEBUG,"New Device: %s",(char *)Phid_DeviceName[Phid_Device_Def[i].pdd_did]);
libusb_device_handle *handle = NULL;
- if (libusb_open(device, &handle) == 0)
+ if ((ret = libusb_open(device, &handle)) == 0)
{
if (desc.bcdDevice < 0x100)
phid->deviceVersion = desc.bcdDevice * 100;
@@ -478,7 +478,6 @@ int CUSBBuildList(CPhidgetList **curList) {
if((ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string))) < 0)
{
LOG(PHIDGET_LOG_ERROR, "libusb_get_string_descriptor_ascii failed with error code: %d", ret);
- LOG(PHIDGET_LOG_INFO, "This usually means you need to run as root");
libusb_close(handle);
free(phid);
goto next;
@@ -505,6 +504,8 @@ int CUSBBuildList(CPhidgetList **curList) {
} //if(udev)
else
{
+ LOG(PHIDGET_LOG_WARNING, "libusb_open failed with error code: %d", ret);
+ LOG(PHIDGET_LOG_INFO, "This usually means you need to run as root, or install the udev rules.");
free(phid);
libusb_close(handle);
}
@@ -537,7 +538,7 @@ int CUSBOpenHandle(CPhidgetHandle phid)
int i, j,ret = EPHIDGET_OK;
libusb_device **list = NULL;
- ssize_t cnt = libusb_get_device_list(NULL, &list);
+ ssize_t cnt = libusb_get_device_list(libusbContext, &list);
if(cnt < 0)
{
@@ -565,7 +566,7 @@ int CUSBOpenHandle(CPhidgetHandle phid)
/* the vend/prod matches! */
libusb_device_handle *handle = NULL;
- if (libusb_open(device, &handle) == 0)
+ if ((ret = libusb_open(device, &handle)) == 0)
{
serial = -1;
if (desc.iSerialNumber) {
@@ -573,7 +574,6 @@ int CUSBOpenHandle(CPhidgetHandle phid)
if((ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string))) < 0)
{
LOG(PHIDGET_LOG_WARNING, "libusb_get_string_descriptor_ascii failed with error code: %d", ret);
- LOG(PHIDGET_LOG_INFO, "This usually means you need to run as root");
libusb_close(handle);
goto next;
}
@@ -643,8 +643,9 @@ int CUSBOpenHandle(CPhidgetHandle phid)
} /* udev open */
else
{
+ LOG(PHIDGET_LOG_WARNING, "libusb_open failed with error code: %d", ret);
+ LOG(PHIDGET_LOG_INFO, "This usually means you need to run as root, or install the udev rules.");
libusb_close(handle);
- LOG(PHIDGET_LOG_WARNING, "usb_open failed - bad permission or what?");
}
} /* vendor/product match */
} /* deviceID matches in table */