def GetIOServicesByType(service_type):
 serial_port_iterator = ctypes.c_void_p()
 iokit.IOServiceGetMatchingServices(kIOMasterPortDefault, iokit.IOServiceMatching(service_type.encode('mac_roman')), ctypes.byref(serial_port_iterator))
 services = []
 while iokit.IOIteratorIsValid(serial_port_iterator):
  service = iokit.IOIteratorNext(serial_port_iterator)
  if (not service):
   break
  services.append(service)
 iokit.IOObjectRelease(serial_port_iterator)
 return services

def GetIOServicesByType ( service_type ) : serial_port_iterator = ctypes . c_void_p ( ) iokit . IOServiceGetMatchingServices ( kIOMasterPortDefault , iokit . IOServiceMatching ( service_type . encode ( 'mac_roman' ) ) , ctypes . byref ( serial_port_iterator ) ) services = [ ] while iokit . IOIteratorIsValid ( serial_port_iterator ) : service = iokit . IOIteratorNext ( serial_port_iterator ) if ( not service ) : break services . append ( service ) iokit . IOObjectRelease ( serial_port_iterator ) return services
returns iterator over specified service_type .