parameters: (serial, serial_map=None,
                                   serial_map_file=None)
docstring: Gets the TTY path (e.g. '/dev/ttyUSB0')  to communicate with the BattOr.
  
    (1) If serial_map is given, it is treated as a dictionary mapping
    phone serial numbers to BattOr serial numbers. This function will get the
    TTY path for the given BattOr serial number.
  
    (2) If serial_map_file is given, it is treated as the name of a
    phone-to-BattOr mapping file (generated with GenerateSerialMapFile)
    and this will be loaded and used as the dict to map port numbers to
    BattOr serial numbers.
  
    You can only give one of serial_map and serial_map_file.
  
    Args:
      serial: Serial number of phone connected on the same physical port that
      the BattOr is connected to.
      serial_map: Map of phone serial numbers to BattOr serial numbers, given
      as a dictionary.
      serial_map_file: Map of phone serial numbers to BattOr serial numbers,
      given as a file.
      hub_types: List of hub types to check for. Used only if serial_map_file
      is None.
  
    Returns:
      Device string used to communicate with device.
  
    Raises:
      ValueError: If serial number is not given.
      BattorError: If BattOr not found or unexpected USB topology.
docstring_summary: Gets the TTY path (e.g. '/dev/ttyUSB0')  to communicate with the BattOr.
docstring_tokens: Gets the TTY path ( e . g . / dev / ttyUSB0 ) to communicate with the BattOr .
function: def GetBattorPathFromPhoneSerial(serial, serial_map=None,
                                   serial_map_file=None):
    """Gets the TTY path (e.g. '/dev/ttyUSB0')  to communicate with the BattOr.
  
    (1) If serial_map is given, it is treated as a dictionary mapping
    phone serial numbers to BattOr serial numbers. This function will get the
    TTY path for the given BattOr serial number.
  
    (2) If serial_map_file is given, it is treated as the name of a
    phone-to-BattOr mapping file (generated with GenerateSerialMapFile)
    and this will be loaded and used as the dict to map port numbers to
    BattOr serial numbers.
  
    You can only give one of serial_map and serial_map_file.
  
    Args:
      serial: Serial number of phone connected on the same physical port that
      the BattOr is connected to.
      serial_map: Map of phone serial numbers to BattOr serial numbers, given
      as a dictionary.
      serial_map_file: Map of phone serial numbers to BattOr serial numbers,
      given as a file.
      hub_types: List of hub types to check for. Used only if serial_map_file
      is None.
  
    Returns:
      Device string used to communicate with device.
  
    Raises:
      ValueError: If serial number is not given.
      BattorError: If BattOr not found or unexpected USB topology.
    """
    # If there's only one BattOr connected to the system, just use that one.
    # This allows for use on, e.g., a developer's workstation with no hubs.
    devtree = find_usb_devices.GetBusNumberToDeviceTreeMap()
    all_battors = GetBattorList(devtree)
    if len(all_battors) == 1:
      return '/dev/' + all_battors[0]
  
    if not serial:
      raise battor_error.BattorError(
          'Two or more BattOrs connected, no serial provided')
  
    if serial_map and serial_map_file:
      raise ValueError('Cannot specify both serial_map and serial_map_file')
  
    if serial_map_file:
      serial_map = ReadSerialMapFile(serial_map_file)
  
    tty_string = _PhoneToPathMap(serial, serial_map, devtree)
  
    if not tty_string:
      raise battor_error.BattorError(
          'No device with given serial number detected.')
  
    if IsBattor(tty_string, devtree):
      return '/dev/' + tty_string
    else:
      raise battor_error.BattorError(
          'Device with given serial number is not a BattOr.')
function_tokens: def GetBattorPathFromPhoneSerial ( serial , serial_map = None , serial_map_file = None ) : # If there's only one BattOr connected to the system, just use that one. # This allows for use on, e.g., a developer's workstation with no hubs. devtree = find_usb_devices . GetBusNumberToDeviceTreeMap ( ) all_battors = GetBattorList ( devtree ) if len ( all_battors ) == 1 : return '/dev/' + all_battors [ 0 ] if not serial : raise battor_error . BattorError ( 'Two or more BattOrs connected, no serial provided' ) if serial_map and serial_map_file : raise ValueError ( 'Cannot specify both serial_map and serial_map_file' ) if serial_map_file : serial_map = ReadSerialMapFile ( serial_map_file ) tty_string = _PhoneToPathMap ( serial , serial_map , devtree ) if not tty_string : raise battor_error . BattorError ( 'No device with given serial number detected.' ) if IsBattor ( tty_string , devtree ) : return '/dev/' + tty_string else : raise battor_error . BattorError ( 'Device with given serial number is not a BattOr.' )