code: def _open_usb_handle(serial_number=None, **kwargs):
    
    init_dependent_flags()
    remote_usb = conf.remote_usb
    if remote_usb:
      if remote_usb.strip() == 'ethersync':
        device = conf.ethersync
        try:
          mac_addr = device['mac_addr']
          port = device['plug_port']
        except (KeyError, TypeError):
          raise ValueError('Ethersync needs mac_addr and plug_port to be set')
        else:
          ethersync = cambrionix.EtherSync(mac_addr)
          serial_number = ethersync.get_usb_serial(port)
  
    return local_usb.LibUsbHandle.open(serial_number=serial_number, **kwargs)
docs: Open a UsbHandle subclass, based on configuration.
  
    If configuration 'remote_usb' is set, use it to connect to remote usb,
    otherwise attempt to connect locally.'remote_usb' is set to usb type,
    EtherSync or other.
  
    Example of Cambrionix unit in config:
    remote_usb: ethersync
    ethersync:
         mac_addr: 78:a5:04:ca:91:66
         plug_port: 5
  
    Args:
      serial_number: Optional serial number to connect to.
      **kwargs: Arguments to pass to respective handle's Open() method.
  
    Returns:
      Instance of UsbHandle.