Locating a USB device
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.