63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sys/ioctl.h>
|
|
#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 * p1 = fname;
|
|
char * p2 = 0;
|
|
|
|
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\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;
|
|
} |