Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-27-2005, 09:17 AM   #1
LQ Newbie
Registered: Sep 2005
Location: Bangalore,india
Distribution: Redhat9
Posts: 4

Rep: Reputation: 0
help me --- interrupt_read() in libusb

hi all,
i need to develop some applications using libusb library.. just now i started with this library... first i want to read the USB mouse interrupts... i have written program... but it doesnt receive the interrupts... .here i include my program...i dono wher i made mistake... so kindly help me to interface the USB mouse(for receiving interrupts)...

my program is working fine upto claiming the interfaces,,, after that the interrupt_read() function returns only negative value...

here i include my program :

#include <stdio.h>
#include <usb.h>
#include <stdlib.h>
#include <unistd.h>

int vid = 0x04fc;
int prod = 0x0013;

struct usb_bus *bus;
struct usb_device *dev;
int stat, scancnt;
unsigned char buf[1024];
usb_dev_handle *udev;
int j,c,i,a,verbose = 0;

int main(int argc, char *argv[])
char *cbuf;
int i;
int show_listing = 0;
int found_device = 0;
struct usb_device *fnd_dev;


for (bus = usb_busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
int ret;
char string[256];

if ((dev->descriptor.idVendor == vid) &&
(dev->descriptor.idProduct == prod)) {
found_device = 1;
fnd_dev = dev;
if (found_device)


if (found_device) {
udev = usb_open(dev);
printf("udev=%x\n", udev);

if (udev) {
stat = usb_set_configuration (udev,
printf ("stat:%d from usb_set_config to %x\n",stat,dev->config[0].bConfigurationValue);

stat = usb_claim_interface(udev, 0);
printf ("stat:%d from claim\n",stat);

memset(buf, 0, sizeof(buf));

stat = usb_interrupt_read(udev, 0x81, buf, 8,1000);

if (stat<0)
goto scan;

printf ("\nstat:%5d, ", stat);

for (i=0; i<8; i++)
printf ("interrupt %02x ", buf[i]);

printf ("closing port\n");
usb_close (udev);
udev = 0;

exit (0);

thanks in advance...



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
libusb Digikam question alexm1 Linux - Hardware 0 06-06-2005 05:52 PM
compiling/install libusb O(V)eGA_l2el) Fedora 2 05-13-2005 12:19 PM
Lexmark X73 and libusb cent20 Linux - Hardware 3 03-18-2005 12:13 PM
libusb:001:002 ? d1l2w3 Linux - Laptop and Netbook 1 01-24-2005 03:22 AM
libUSB install Dutch3 Linux - Newbie 1 04-30-2002 08:15 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration