Find the answer to your Linux question:
Results 1 to 5 of 5
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    13

    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:

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,159
    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.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    13

    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.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,159
    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.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Mar 2009
    Posts
    4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •