Thread-topic: Need to identify a physical USB hub port
Title: Re: Need to identify a physical USB hub port
It's pretty easy, actually. Find the IOMedia
object for the mounted volume, then walk up that object's parents until you
hit an IOUSBDevice, which will have the locationID property. Or you can use
IORegistryEntrySearchCFProperty() to do it in one call.
There are several ways to find the IOMedia object for the
volume. Perhaps the easiest is to install a notification handler to watch for
new IOMedia objects.
Another way would be to use the statfs() call to get the
device path. It will be something like "/dev/disk0s4". Strip the "/dev/",
and search for an IOMedia with a "BSD Name" property with that
value.
There's other ways as well, but that should give you the
basic idea.
Cheers
-chris
From:
usb-bounces+creed=email@hidden
[mailto:usb-bounces+creed=email@hidden] On Behalf Of B.
Mitchell Loebel Sent: Thursday, May 26, 2005 2:22 AM To:
Fernando Urbina Cc: email@hidden Subject: Re: Need
to identify a physical USB hub port
Hello list and Fernando:
Perhaps I should clarify my question in the context of what I now
understand about locationID. I originally framed my question as follows:
"I have an N port hub connected to a Mac USB port. This hub is
permanently connected. Each of the N ports of my external hub has an SD
reader device permanently connected. When a removable SD flash is inserted
into one of the readers I get a volume mounted event so that I can get the
name of the mounted volume and then copy a file from my hard drive to the SD
flash ... no problem. I would like my code to tell me which physical reader
contains the mounted volume."
Now I see that each flash reader will acquire a 32 bit locationID when it
is connected to the USB bus system and I can pick up those numbers with a
callback which responds to a deviceAdded notification. Of course, I can't know
the ordering of the USB enumeration, so I can't know which locationID binds
with which physical port. Additionally, my code supports a mount event so that
I have a callback that responds to a flash media being put into one of the USB
reader devices. The fundamental question is how can I determine which physical
port contains the flash media that mounts? Inasmuch as I can't know which
locationID binds with which physical port, I don't see how knowing the
locationIDs for each of the readers helps me.
At 10:25 PM -0600 5/25/05, Fernando Urbina wrote:
>I think that the best that you can do is get the locationID of the
device in question. This number is persistent across restarts, as long
as the bus topology remains the same (which sounds like it will from your
description). What you do with this location ID is up to you
;-) > >HTH, > >-- >Fernando Urbina >USB
Technology Team >Apple Computer, Inc. > >On May 25, 2005, at
10:07 PM, B. Mitchell Loebel wrote: > >> As an example, Windows
explorer binds a drive letter to a reader whether or not the removable flash
is inserted in the reader. And that drive letter persists for the entire
session even after the removable flash has been removed. How can I do the same
under OSX ... Carbon, please? >> >>
--
-----
B. Mitchell
Loebel
408 425-9920 cell
Executive Director
The Tech Startup
Connection
(formerly The PARALLEL Processing
Connection)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden
This email sent to email@hidden