LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-27-2005, 08:17 AM   #1
shiva_teknic
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;

usb_init();
usb_find_busses();
usb_find_devices();

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;
break;
}
}
if (found_device)
break;
}


printf("value%d",found_device);


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

if (udev) {
stat = usb_set_configuration (udev,
dev->config[0].bConfigurationValue);
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));

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


if (stat<0)
goto scan;

else
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...

regards
siva
 
  


Reply


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 04:52 PM
compiling/install libusb O(V)eGA_l2el) Fedora 2 05-13-2005 11:19 AM
Lexmark X73 and libusb cent20 Linux - Hardware 3 03-18-2005 11:13 AM
libusb:001:002 ? d1l2w3 Linux - Laptop and Netbook 1 01-24-2005 02:22 AM
libUSB install Dutch3 Linux - Newbie 1 04-30-2002 07:15 AM


All times are GMT -5. The time now is 10:15 AM.

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