trying to get the driver test
This commit is contained in:
parent
a7b664e397
commit
52d8339f4b
@ -1,36 +1,63 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#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);
|
||||
printf("5 \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user