Hi All
If I connect 1 USB PEN DRIVE in PC ,in /dev folder I recognize that particular device by /dev/sdb1. Then if I connect USB MOUSE ,it gets recognize by /dev/hidraw0.
How can I make one linux application which should be generic for all USB devices .I meant whichever USB device I connect I can
fetch that device name(for example /dev/sdb1 In case of USB pendrive) on my applciation .Is there any API available
I have written one small application but it is hardcoded for USB ,It should be genric for all USB devices.
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
main()
{
int fd,fd1,led_no;
fd = open ("/dev/hidraw0",O_RDWR);
if (fd <= 0) {
printf ("USB Port not opened %d\n",fd);
// exit(0);
}
else
printf("USB_OPEN %d \n",fd);
fd1 = open ("/dev/sdb1",O_RDWR);
if (fd1 <= 0) {
printf ("USB port not opened %d\n",fd1);
//exit(0);
}
else
printf("USB_OPEN %x\n ",fd1);
}