• 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
Locating a USB device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Locating a USB device


  • Subject: Locating a USB device
  • From: Chuck Rice <email@hidden>
  • Date: Sun, 19 Jan 2003 14:01:18 -0800

I have some code using Andraes Meyer's serial port code (thanks!). I need to locate a cell phone attached to a USB port. I came up with the following code:

a1 = [sPortList getPortList];
for (i=0;i<[a1 count];i++) {
if ([[[a1 objectAtIndex:i] bsdPath] hasPrefix:@"/dev/cu.usbmodem"]) {
[thePort setString:[[a1 objectAtIndex:i] bsdPath]];
NSLog(@"Found %@",[[a1 objectAtIndex:i] bsdPath]);
}
}

Which seems to work fine. The bsdPath is different depending on the USB port you connect to, but they always seem to be prefixed with cu.usbmodem and are then suffixed with a number such as cu.usbmodem001 (on my PBG4) or cu.usbmodem0013 (plugged into the keyboard on an iMac).

My question is, is this a hack, or a technique? :) In other words, can I get away with it? I know that there is one problem with it in that it will only find the last usbModem connected, but I think I can live with that for now. Any opinions/alternate methods on locating the correct device to connect to? -Chuck-
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Locating a USB device
      • From: Tomas Zahradnicky <email@hidden>
  • Prev by Date: Examples of applications developed with Cocoa?
  • Next by Date: Re: Examples of applications developed with Cocoa?
  • Previous by thread: Re: Examples of applications developed with Cocoa?
  • Next by thread: Re: Locating a USB device
  • Index(es):
    • Date
    • Thread