Discussion:
[libhid-discuss] Need API for identifying the port no to which the usb device is connected
shivaprasad javali
2008-06-23 10:49:33 UTC
Permalink
Hi,

The usb device that I am working with doesnot have a unique serial no
for each usb device. So I have to use the port no of the port it is
connected to identify the device uniquely. Is there an API in libhid that I
can use to get port no?

If you know of an API which can serve my purpose or If you have any
pointers as to how I can acheive my goal please let me know?

Thanks
Shivaprasad
Charles Lepple
2008-06-23 12:13:29 UTC
Permalink
Post by shivaprasad javali
The usb device that I am working with doesnot have a unique serial no
for each usb device. So I have to use the port no of the port it is
connected to identify the device uniquely. Is there an API in
libhid that I
can use to get port no?
Look in src/hid_presentation.c for hid_write_identification() - it
prints a "location" which should probably work for your needs.
--
Charles Lepple
shivaprasad javali
2008-06-24 04:52:53 UTC
Permalink
Hi,

The location being printed there is the busnumber/devicefilename. While
this might be useful for me I am looking for a way for me to get the port no
of the usb device. When I look at the file /proc/bus/usb/devices I get a
port no field for each usb device there . Thats the port no I want to know
about my USB device. Is ther any way to get that port no.

Thanks
Shivaprasad
Post by Charles Lepple
Post by shivaprasad javali
The usb device that I am working with doesnot have a unique serial no
for each usb device. So I have to use the port no of the port it is
connected to identify the device uniquely. Is there an API in libhid that I
can use to get port no?
Look in src/hid_presentation.c for hid_write_identification() - it
prints a "location" which should probably work for your needs.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
Peter Stuge
2008-06-24 05:29:24 UTC
Permalink
Post by shivaprasad javali
The location being printed there is the busnumber/devicefilename.
While this might be useful for me I am looking for a way for me to
get the port no of the usb device. When I look at the file
/proc/bus/usb/devices I get a port no field for each usb device
there. Thats the port no I want to know about my USB device. Is
there any way to get that port no.
See thread on libusb list.

You could of course parse /proc/bus/usb/devices, but it is preferred
to look your device up in the /sys/bus/usb/devices/ directory. The
link for your device has encoded in it the port number it is
connected to.


//Peter
shivaprasad javali
2008-06-24 05:37:27 UTC
Permalink
I want to get the port no programatically from within my c driver code. I
could parse the device files to get the port no I want but is there any
better way like an API or something that I can use to get this no easily.

Thanks
Shivaprasad
Post by Peter Stuge
Post by shivaprasad javali
The location being printed there is the busnumber/devicefilename.
While this might be useful for me I am looking for a way for me to
get the port no of the usb device. When I look at the file
/proc/bus/usb/devices I get a port no field for each usb device
there. Thats the port no I want to know about my USB device. Is
there any way to get that port no.
See thread on libusb list.
You could of course parse /proc/bus/usb/devices, but it is preferred
to look your device up in the /sys/bus/usb/devices/ directory. The
link for your device has encoded in it the port number it is
connected to.
//Peter
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
Peter Stuge
2008-06-24 06:06:19 UTC
Permalink
Post by shivaprasad javali
I want to get the port no programatically from within my c driver code.
Right.
Post by shivaprasad javali
I could parse the device files to get the port no I want but is
there any better way like an API or something that I can use to get
this no easily.
Sorry, noone bothered wrapping it in libusb 0.1.

Look into the libusb 1.0 API however, it may be there - I forget. :\


//Peter
Charles Lepple
2008-06-24 11:40:02 UTC
Permalink
Post by shivaprasad javali
Hi,
The location being printed there is the busnumber/
devicefilename. While this might be useful for me I am looking for
a way for me to get the port no of the usb device. When I look at
the file /proc/bus/usb/devices I get a port no field for each usb
device there . Thats the port no I want to know about my USB
device. Is ther any way to get that port no.
/proc/bus/usb/devices is not available on all systems (especially
systems where the usbdevfs is mounted at /dev/bus/usb instead).

Since there is no libusb API for this, I don't plan on adding one to
libhid.
Post by shivaprasad javali
Post by shivaprasad javali
The usb device that I am working with doesnot have a unique serial no
for each usb device. So I have to use the port no of the port it is
connected to identify the device uniquely. Is there an API in libhid that I
can use to get port no?
Look in src/hid_presentation.c for hid_write_identification() - it
prints a "location" which should probably work for your needs.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
--
Charles Lepple
clepple at ghz.cc
shivaprasad javali
2008-06-24 11:44:15 UTC
Permalink
So the only way for me to get the port no the USB is attached to is to parse
the /proc/bus/usb/devices file(If it exists)??

And if that file is not present on a system what other options do I have?Are
there any helpful API's in libusb possibly?

Thanks
Shivaprasad
Post by Charles Lepple
Post by shivaprasad javali
Hi,
The location being printed there is the busnumber/
devicefilename. While this might be useful for me I am looking for
a way for me to get the port no of the usb device. When I look at
the file /proc/bus/usb/devices I get a port no field for each usb
device there . Thats the port no I want to know about my USB
device. Is ther any way to get that port no.
/proc/bus/usb/devices is not available on all systems (especially
systems where the usbdevfs is mounted at /dev/bus/usb instead).
Since there is no libusb API for this, I don't plan on adding one to
libhid.
Post by shivaprasad javali
Post by shivaprasad javali
The usb device that I am working with doesnot have a unique serial no
for each usb device. So I have to use the port no of the port it is
connected to identify the device uniquely. Is there an API in libhid that I
can use to get port no?
Look in src/hid_presentation.c for hid_write_identification() - it
prints a "location" which should probably work for your needs.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
--
Charles Lepple
clepple at ghz.cc
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
Charles Lepple
2008-06-24 11:48:44 UTC
Permalink
Post by shivaprasad javali
So the only way for me to get the port no the USB is attached to is
to parse the /proc/bus/usb/devices file(If it exists)??
Read the reply from Peter Stuge about /sys/bus/usb/devices.

Nothing is stopping you from using functions outside the libhid API.
--
Charles Lepple
clepple at ghz.cc
shivaprasad javali
2008-06-25 11:49:26 UTC
Permalink
Thanks for all the info. Now i have figured out how to do it.. I got the bus
no from the hid itself and the port no by parsing the /proc/bus/usb/devces
file and combined the two to get a unique identifier for the usb port to
which my USB device is connected.

I have another question for you.

If I connect two USB devices to my machine, I need to loop to get all the
handles for the USB devices(right??). So I will have to call
hid_force_open() and the other calls in a loop. How can I instruct the
hid_force_open() call to pick up the next US B device , If it has already
got one of the handles.

Thanks
Shivaprasad
Post by Charles Lepple
Post by shivaprasad javali
So the only way for me to get the port no the USB is attached to is
to parse the /proc/bus/usb/devices file(If it exists)??
Read the reply from Peter Stuge about /sys/bus/usb/devices.
Nothing is stopping you from using functions outside the libhid API.
--
Charles Lepple
clepple at ghz.cc
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
Loading...