[Pkg-running-devel] [openambit] 99/131: Log most likely reason why device cannot be opened. Re #26
Christian Perrier
bubulle at moszumanska.debian.org
Thu Jul 17 20:19:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
bubulle pushed a commit to branch master
in repository openambit.
commit 4799eabeb7d4a643fab59fde31b860ddbc8241d1
Author: Olaf Meeuwissen <olaf at member.fsf.org>
Date: Tue Mar 25 22:50:59 2014 +0900
Log most likely reason why device cannot be opened. Re #26
Device communication requires read/write access permissions no matter
how you look at it. Looking at the innards of `hid_open()` shows that
that function calls `open()` with the same flags as well.
---
src/libambit/libambit.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/libambit/libambit.c b/src/libambit/libambit.c
index b65508e..25c43bf 100644
--- a/src/libambit/libambit.c
+++ b/src/libambit/libambit.c
@@ -22,9 +22,14 @@
#include "libambit.h"
#include "libambit_int.h"
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
/*
* Local definitions
*/
@@ -74,6 +79,7 @@ ambit_object_t *libambit_detect(void)
ambit_object_t *ret_object = NULL;
int i;
ambit_supported_device_t *device = NULL;
+ char *path = NULL;
LOG_INFO("Searching devices");
@@ -86,6 +92,7 @@ ambit_object_t *libambit_detect(void)
LOG_INFO("match!");
// Found at least one supported row, lets remember that!
device = &supported_devices[i];
+ path = strdup (cur_dev->path);
break;
}
}
@@ -144,10 +151,18 @@ ambit_object_t *libambit_detect(void)
}
}
else {
+#ifdef DEBUG_PRINT_ERROR
+ int error = 0;
+ int fd = 0;
+ if (path) fd = open (path, O_RDWR);
+ if (-1 == fd) error = errno;
+#endif
LOG_ERROR("Failed to open device \"%s (%s)\"", device->name, device->model);
+ LOG_ERROR("Reason: %s", (error ? strerror(error) : "Unknown"));
}
}
+ if (path) free (path);
return ret_object;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-running/openambit.git
More information about the Pkg-running-devel
mailing list