

@classmethod
def Open(cls, usb, destination, timeout_ms=None):
    "Opens a new connection to the device via an OPEN message.\n\n    Not the same as the posix 'open' or any other google3 Open methods.\n\n    Args:\n      usb: USB device handle with BulkRead and BulkWrite methods.\n      destination: The service:command string.\n      timeout_ms: Timeout in milliseconds for USB packets.\n\n    Raises:\n      InvalidResponseError: Wrong local_id sent to us.\n      InvalidCommandError: Didn't get a ready response.\n\n    Returns:\n      The local connection id.\n    "
    local_id = 1
    msg = cls(command='OPEN', arg0=local_id, arg1=0, data=(destination + '\x00'))
    msg.Send(usb, timeout_ms)
    (cmd, remote_id, their_local_id, _) = cls.Read(usb, ['CLSE', 'OKAY'], timeout_ms=cmd)
    if (local_id != their_local_id):
        raise InvalidResponseError(('Expected the local_id to be %s, got %s' % (local_id, their_local_id)))
    if (cmd == 'CLSE'):
        return None
    if (cmd != 'OKAY'):
        raise InvalidCommandError(('Expected a ready response, got %s' % cmd), cmd, (remote_id, their_local_id))
    return _AdbConnection(usb, local_id, remote_id, timeout_ms)

dataset/ETHPy150Open google/python-adb/adb/adb_protocol.py AdbMessage.Open/VarMisuse@85/299 `timeout_ms`->`cmd`