From 52d8339f4b17b471b9389accc966539390e8759f Mon Sep 17 00:00:00 2001 From: carl Date: Wed, 7 Jun 2023 09:25:31 -0300 Subject: [PATCH] trying to get the driver test --- .../fjpalmvein/C/fjpalmvein-main/drivertest.c | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/modules/fjpalmvein/C/fjpalmvein-main/drivertest.c b/modules/fjpalmvein/C/fjpalmvein-main/drivertest.c index 38bcf5884..abca062b1 100644 --- a/modules/fjpalmvein/C/fjpalmvein-main/drivertest.c +++ b/modules/fjpalmvein/C/fjpalmvein-main/drivertest.c @@ -1,36 +1,63 @@ #include +#include #include #include #include #include "fjveincam.h" -#define DEVICE_PATH "/dev/usb/fjveincam0" + - -int main() { +int main(int argc, char ** argv) { struct fjveincam_info info; int status = 0; + int fd = 0; + char fname[] = "/dev/usb/fjveincam\0\0"; + char * p1 = fname; + char * p2 = 0; + memset(&info,1,sizeof(struct fjveincam_info)); + p2 = argv[1]; + *(p1+strlen(p1))=*p2; + printf("#1 %s\n", fname); - int fd = open(DEVICE_PATH, O_RDWR); + fd = open(fname, O_RDWR); if (fd < 0) { - printf("Failed to open USB device %s", DEVICE_PATH); + perror("open"); + printf("Failed to open USB device %s (%d)",fname, fd); return -1; } - printf("Open USB device OK with magic number %d\n", USB_FJVEINCAM_IOCTL_CHECK); - + printf("#2 Open returned fd: %d\n", fd); + + close(fd); + return (0); + + + + printf("Trying ioctl magic number %lu\n", (unsigned long)USB_FJVEINCAMV30_IOCTL_CHECK); + + int arg = 0; + // Call the function in the kernel module - status = ioctl(fd, 33, &info); + status = ioctl(fd, USB_FJVEINCAMV30_IOCTL_CHECK, &info); + printf("3 %d \n",status); + if (status < 0) { perror("ioctl"); - printf("Failed to call function in kernel module with IOCTL %d code %d\n",USB_FJVEINCAM_IOCTL_CHECK,status); + printf("Failed to call function in kernel module with IOCTL code %lu\n",(unsigned long)USB_FJVEINCAMV30_IOCTL_CHECK,status); close(fd); return -1; } + printf("4 \n"); + + printf("%d %d %d %d %d %d %d '%s'\n", info.magic, info.minor, info.o_timeout, + info.r_error, info.r_lasterr, info.w_error, info.w_lasterr, info.version); + close(fd); - return 0; + printf("5 \n"); + + return 0; } \ No newline at end of file