def scan_interfaces():
 interfaces = []
 for service in GetIOServicesByType('IOSerialBSDClient'):
  device = get_string_property(service, 'IOCalloutDevice')
  if device:
   usb_device = GetParentDeviceByType(service, 'IOUSBInterface')
   if usb_device:
    name = (get_string_property(usb_device, 'USB Interface Name') or None)
    locationID = (get_int_property(usb_device, 'locationID', kCFNumberSInt32Type) or '')
    i = SuitableSerialInterface()
    i.id = locationID
    i.name = name
    interfaces.append(i)
 return interfaces

def scan_interfaces ( ) : interfaces = [ ] for service in GetIOServicesByType ( 'IOSerialBSDClient' ) : device = get_string_property ( service , 'IOCalloutDevice' ) if device : usb_device = GetParentDeviceByType ( service , 'IOUSBInterface' ) if usb_device : name = ( get_string_property ( usb_device , 'USB Interface Name' ) or None ) locationID = ( get_int_property ( usb_device , 'locationID' , kCFNumberSInt32Type ) or '' ) i = SuitableSerialInterface ( ) i . id = locationID i . name = name interfaces . append ( i ) return interfaces
helper function to scan usb interfaces returns a list of suitableserialinterface objects with name and id attributes .