> On Jun 5, 2015, at 4:57 PM, Roland King <[email protected]> wrote:
> 
> 
>> On 6 Jun 2015, at 04:34, Carl Hoefs <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Using IOKit (OS X 10.10.3) how do I go about obtaining the mount point for
>> a USB device?
>> 
>> A USB device I'm using is mounted as /dev/tty.usbmodemXXXXXXXX, where the
>> XXX's vary every time.
>> 
>> I can successfully obtain the location ID for the device interface using
>> the VID & PID:
>> 
>>  kreturn = (*theDeviceInterface)->GetLocationID( theDeviceInterface,
>> &locationID );
>> 
>> But how do I obtain the mount point string? I need to return it so that I
>> can do an fopen on it.
>> 
>> -Carl
>> 
> 
> I had to go look at some old code of mine to find this. Here’s where I 
> initialise an object of mine with an IOObject which is a plugged-in USB 
> serial device, I usually use the callout device /dev/cu.usbmodemxxxxx, the 
> tty I think is the dial in device. Usually it’s the callout you want to open. 
> 
> -(id)initWithIOObject:(io_object_t)io_object
> {
>       self = [ super initWithIoObject:io_object ];
> 
>       if( self )
>       {
>               self.modemName          =  (__bridge_transfer NSString* 
> )IORegistryEntryCreateCFProperty( io_object, CFSTR( kIOTTYDeviceKey     ), 
> NULL, 0 );
>               self.callOutDevice      =  (__bridge_transfer NSString* 
> )IORegistryEntryCreateCFProperty( io_object, CFSTR( kIOCalloutDeviceKey ), 
> NULL, 0 );
>               self.dialInDevice       =  (__bridge_transfer NSString* 
> )IORegistryEntryCreateCFProperty( io_object, CFSTR( kIODialinDeviceKey  ), 
> NULL, 0 );
>               self.bsdType            =  (__bridge_transfer NSString* 
> )IORegistryEntryCreateCFProperty( io_object, CFSTR( kIOSerialBSDTypeKey ), 
> NULL, 0 );
>       }
> 
>       return self;
> }
> 
> Where I found that in the documentation I have entirely forgotten. 

Thanks, that looks like it should work nicely! My device is equally accessible 
as /dev/tty.usbmodem* and /dev/cu.usbmodem*. 

But first I need to get an io_object_t reference to the device. The only way I 
know of is to get the device in a matching dictionary. Currently I’m doing the 
following: 

  io_object_t device = 0;
  io_iterator_t serialPortIter = 0;
  CFMutableDictionaryRef matchDict = 
IOServiceMatching(kIOSerialBSDServiceValue);
  CFDictionarySetValue(matchDict, CFSTR(kIOSerialBSDTypeKey), 
CFSTR(kIOSerialBSDModemType));
  kern_return_t kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, 
matchDict, &serialPortIter);
  while ((device = IOIteratorNext(serialPortIter))) { ... }

For reasons that elude me, the result of the above code is an empty matchDict. 

-Carl

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/usb/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to