-
problem in usb program
hi,
i write a program to access information about usb device.
#include <linux/usb.h>
#include <linux/input.h>
#include <stdlib.h>
int main() {
struct usb_device newdev, *rptr;
rptr=usb_get_dev(&newdev);
return 0;
}
after compiling this is giving error:
expected specifier-list in mod_devicetable.h : kernel_ulock_t
like this.
please solve this:
-
This is a compiler error. AFAIK, you cannot use the stdlib in kernel code. Take out the line: #include <stdlib.h>
Also, I think that you actually are trying to write a user-space program? If so, then you cannot use internal kernel calls. To get the information you need in a user-space program, you should look at /proc/bus/usb/devices.
-
usb program problem
hi,
thanks for reply.
i am doing project on usb file structure system. first i am writing codes to communicate directly from host, hub and usb devices. i want to read all raw data from my own written function.
My first question is that can i write a code by use of header file function in linux directry.
as example.
code:
#include <linux/usb.h>
int main() {
struct usb_device *newdev;
usb_get_dev(newdev);
return 0;
}
this is running in user space. is that ok.
if not how can i run this program in kernel mode.
in this code i got a linking error.
i wrote command like this gcc -lusb filename.c
this is giving linking error for usb_get_dev function. so can be possible usb library file does not have this function definition.
is this possible to see that library file have which function definitions.
i am using ubuntu operating system.
please give me one example of ioctl() for usb device.
i have usb files in /dev directory. which file i will open for ioctl() call fd for usb.
any document or book refer me to write code for usb above the usb driver, i.e. code those use driver functions and write code for applications.
-
These are kernel-level calls and I am not sure if they can be used in user space. I believe that you would need to create a kernel module to use these functions. Anyway, the reason why it is failing to link is likely because you are not telling it to link in the appropriate kernel libraries where the missing function is defined.
-
hi
you cannot use usb_get_dev(newdev) function in user mode. if u want to use usb_get_dev(newdev) function u want to write ur programe as kernel module after that you can dynamically laod ur module into kernel ,then i hope it will work fine