• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Discovering USB devices
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Discovering USB devices


  • Subject: Re: Discovering USB devices
  • From: Kevin Elliott <email@hidden>
  • Date: Tue, 10 Jul 2007 11:32:12 -0700

In the next few days I think I'm going to try and put together a more detailed "IOKit from Cocoa" doc that goes in to much more detail, but in the meantime, and basic overview would be the following:

1) use IORegistryExplorer to figure out the name of the class you want. Your looking for USB, so IOUSBDevice seems a likely choice.

2) Create a match dict using IOServiceMatch- i.e. IOServiceMatching ("IOUSBDevice");

3) Get the list of matching devices by calling IOServiceGetMatchingServices

4) walk the iterator it returns using IOIteratorNext()

5) for each object, figure out what you need and got get it. In you case, you want the "BSD Name", which is stored in a couple different places above the IOUSBDevice. You can see these keys using IORegistryExplorer. Use IORegistryEntrySearchCFProperty to find the property your interested in.

Notifications work basically the same except you call a different function in step 3, and your callback gets called whenever devices appear. All of the functions described are in <IOKit/IOKitLib.h>, which is pretty well header doc'd.

Please note: I'm glossing over a lot of detail, and make ZERO guarantee that the chain above will work flawlessly for a particular random object. IOKit is very, very cool, but can also be really messy. As I said, I'm going to try and write a more detailed exposition in the next few days/weekend that should clear things up in greater detail.

On Jul 10, 2007, at 9:44 AM, Pierre Bernard wrote:

Hi Kevin!
(greetings to your iPhone)

Thanks for your reply to my message.

Scanning would be good, notifications would be way better.

How would I use IOKit to do this?

Pierre


On Jul 10, 2007, at 4:28 PM, Kevin Elliott wrote:

Short answer is IOKit.

Long answer depends on what exactly you need to do. Do you need notification of devices appearing, or are you just trying to scan the state of the bus at a particular instant?


Sent from my iPhone

On Jul 10, 2007, at 12:03 AM, Pierre Bernard <email@hidden> wrote:

Hi!

Is there an easy way to discover connected USB devices and get their UNIX name (e.g. /dev/cu.USA19QI181P1.1) ?

I tried reading the docs, but was overwhelmed. This is overkill. All I need is the name of the device so I can hand it to a command line tool.

Best,
Pierre

---
Pierre Bernard
http://www.bernard-web.com/pierre
http://www.houdah.com



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

- - - Houdah Software s. à r. l. http://www.houdah.com

HoudahGeo: One-stop photo geocoding
HoudahSpot: Powerful Spotlight frontend



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • shmget from a Cocoa application
      • From: Jay Reynolds Freeman <email@hidden>
References: 
 >Discovering USB devices (From: Pierre Bernard <email@hidden>)
 >Re: Discovering USB devices (From: Kevin Elliott <email@hidden>)
 >Re: Discovering USB devices (From: Pierre Bernard <email@hidden>)

  • Prev by Date: Re: Is there a fast NSShadow alternative?
  • Next by Date: Re: Core Data and Document Packages
  • Previous by thread: Re: Discovering USB devices
  • Next by thread: shmget from a Cocoa application
  • Index(es):
    • Date
    • Thread