Is there a way, using IOKit
or something similar that does not involve downloading additional packages from the internet, that I can use to read a USB device's product name?
This is my current code...
func printSerialPaths(portIterator: io_iterator_t) {
var serialService: io_object_t
repeat {
serialService = IOIteratorNext(portIterator)
if (serialService != 0) {
var key: CFString! = "IOCalloutDevice"
var bsdPathAsCFtring: AnyObject? = IORegistryEntryCreateCFProperty(serialService, key, kCFAllocatorDefault, 0).takeUnretainedValue()
var bsdPath = bsdPathAsCFtring as! String?
if let path = bsdPath {
print(path)
}
var deviceNameCString: [CChar] = [CChar](count: 128, repeatedValue: 0)
let deviceNameResult = IORegistryEntryGetName(serialService, &deviceNameCString)
let deviceName = String.fromCString(&deviceNameCString)!
print("usb Device Name: \(deviceName)")
}
} while serialService != 0;
}
I have also tried using other CFStrings, such as "Product Name" in the IORegistryEntryCreateCFProperty()
command as I've seen suggested elsewhere with no luck. If replacing that is all I need, where can I find the documentation for the rest of these strings?
The product name that I'm talking about is highlighted below. I'm not sure what its technical name would be.