#include #include #include #include #include #include "fjveincam.h" int main(int argc, char ** argv) { struct fjveincam_info info; int status = 0; int fd = 0; char fname[] = "/dev/usb/fjveincam\0\0"; //char fname[] = "/dev/bus/usb//004/01\0\0"; char * p1 = fname; char * p2 = 0; if (argc<2){ printf("Error. Syntax is %s device# (eg 0,1,2)\n", argv[0]); return 1; } memset(&info,1,sizeof(struct fjveincam_info)); p2 = argv[1]; *(p1+strlen(p1))=*p2; printf("#1 %s\n", fname); fd = open(fname, O_RDWR); if (fd < 0) { perror("open"); printf("Failed to open USB device %s (%d)",fname, fd); return -1; } 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, 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 code %lu status %d\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); printf("5 \n"); return 0; }