DISCUSSION: Developing Linux Device Drivers using Libusb API
This thread is to discuss the article titled: Developing Linux Device Drivers using Libusb API
|
This is a good article, but #include <...> are left out, and the indentation on the code is horrible (because there isn't any). I'm not sure if this is problem with the linuxanswers themselves, but it would look much better if it was properly formatted.
|
Just experimenting a bit here. Here is some C code with the vB 'code' tags:
Code:
#include <stdio.h> #include <stdio.h> main() { Printf("hello world\n"); } So (according to the preview button) you lose your indentation but I have no idea what happened to the #include directives in this post. Perhaps the author could fix it up with some 'code' tags. The ref to the sourceforge site also needs changing so it comes out as a link. I've been searching for documentation on USB device drivers recently. There are a few good references but overall the situation is not very satisfactory. So almost anything is a positive contribution. If I understand correctly libusb lets you access USB devices even if they don't have kernel-level drivers. As the author suggests the (again rather brief) documentation at http://libusb.sourceforge.net/doc is worth a look for further code and examples. Apparently gphoto and rio500 are based on libusb. |
Missing include lines
Quote:
#include <stdio.h> #include <stdlib.h> #include <usb.h> I do not know if all of those are necessary. After compiling and testing I noticed that usb_get_string_simple does not return any string via string parameter when testing the program as a user. The return value of the function usb_get_string_simple is -1 all the time. But when I changed to root user and tested the program, everything worked fine. Anyway, I wonder if this phenomen has something to do with udev? With two different live-cd (gentoo and SuSE) boot process stopped just after udev: ... Starting udev.... ... udev running. Starting hardware detection... Activating usb devices... <-- boot stops here (the above example is with the SuSE 10.1 installation CD-ROM and repair system option). |
Linux Device Drivers
I am new to the Linux world. I have been programming for over 15 years and now I am writing a User Space USB device driver, or aleast trying to do so.
I found the article very interesting though it end with a hanging thought (i.e., These descriptors are defined using the) and that was the end. I am looking for any information that anyone can give me about writing a USB device driver that has to be run in User Space. Thanks, John V. |
complete
Hello,
Here is the end of the article : Important attributes of USB devices useful in device driver coding Configuration and Endpoints are one of the two important descriptors of any USB device. These desciptors are defined using the “struct usb_config_descriptor” and “struct_usb_endpoint_descriptor” respectively . dev->descriptor.idVendor : Reveals the Vendor-Id of the USB device connected to the system. dev->descriptor.idProduct : Reveals the Product-Id of the USB device connected to the system. dev->descriptor.iManufacturer : Reveals the name of the Manufacturer USB device connected to the system. EndpointAddress:Combination of endpoint address and enpoint direction on a USB device. InterfaceNumber : One of the several interfaces that is allocated to the connected USB device. AlternateSetting:This is part of the a single interface allocated to the USB device. Prerequites for Libusb programming Linux system with Kernel 2.4 above series. Proficiency in C language. Good understanding of USB device internals. Idea about USBFS. |
Can't read descriptor info
Thanks for the good guide. But for unknown reason, I can't read the descriptor of the USBs device. Here's the output of your example
Code:
bus/device idVendor/idProduct $ /sbin/lsusb Note: I'm using Fedora 8 64-bit as a VMWare guest. Please tell me what's wrong with it. Thanks in advance! |
Hi ppl, I used a similar test program to the one of the article.
Code:
/* Code:
usb_set_debug: Setting debugging level to 255 (on) thx |
rockballad, try running the program as root.
|
Quote:
Thanks |
missing includes
I put the following includes to get the program to work
#include <stdio.h> #include <usb.h> Under Ubuntu linux you must compile using sudo as well as run the program using sudo to get it to work.. this is a good starting article. |
Sri
Man! A worthy tutorial.
|
Hi.
I wrote a shell-prog that communicates a selfmade USB-device using the libusb. It works fine, but I only can use the prog if I am logged in as root. Every other user gets the message, that there is no device connected, but without changing anything root can control it. I tried to "chmod 777" all the libusb-files in /usr/lib/, but that did not work, too. Has anyone of you a clue, what the problem could be? Thanks. |
Is there some fort of GUI for this?
Quote:
|
Compile problem
I tried to compile teslibusb.c:
gcc -o usbdevice_details testlibusb.c -I/usr/local/include -L. -lnsl -lm -lc -L/usr/local/lib -lusb However i get: testlibusb.c:27: error: 'true' undeclared here (not in a function) testlibusb.c:146: error: conflicting types for 'read' /usr/include/unistd.h:312: error: previous declaration of 'read' was here testlibusb.c: In function 'read': testlibusb.c:170: error: 'for' loop initial declaration used outside C99 mode testlibusb.c: At top level: testlibusb.c:180: error: conflicting types for 'write' /usr/include/unistd.h:318: error: previous declaration of 'write' was here testlibusb.c: In function 'write': testlibusb.c:214: error: 'for' loop initial declaration used outside C99 mode testlibusb.c: In function 'readWriteLoop': testlibusb.c:313: error: 'for' loop initial declaration used outside C99 mode testlibusb.c:318: error: 'for' loop initial declaration used outside C99 mode testlibusb.c:335: error: 'for' loop initial declaration used outside C99 mode testlibusb.c: In function 'main': testlibusb.c:368: error: 'bool' undeclared (first use in this function) testlibusb.c:368: error: (Each undeclared identifier is reported only once testlibusb.c:368: error: for each function it appears in.) testlibusb.c:368: error: expected ';' before 'run' testlibusb.c:423: error: 'run' undeclared (first use in this function) testlibusb.c:434: error: 'false' undeclared (first use in this function) testlibusb.c:466:2: warning: no newline at end of file Is there a version that compiles out of the box? |
All times are GMT -5. The time now is 02:19 AM. |