diff options
author | Frederic Leger | 2016-07-06 13:10:25 +0000 |
---|---|---|
committer | Frederic Leger | 2016-07-06 13:10:25 +0000 |
commit | 69846a1fda38662c05543d5b584086cf0fbc8406 (patch) | |
tree | f541e3c7af842d7a26436a37e643d0232ca6b413 | |
parent | 9aa0407d70df7561fd820377f268831bef524611 (diff) | |
download | org.eclipse.tcf-69846a1fda38662c05543d5b584086cf0fbc8406.tar.gz org.eclipse.tcf-69846a1fda38662c05543d5b584086cf0fbc8406.tar.xz org.eclipse.tcf-69846a1fda38662c05543d5b584086cf0fbc8406.zip |
Added dprintf service.
The dprintf service interface and proxy.
-rw-r--r-- | python/src/tcf/services/dprintf.py | 84 | ||||
-rw-r--r-- | python/src/tcf/services/remote/DPrintfProxy.py | 59 |
2 files changed, 143 insertions, 0 deletions
diff --git a/python/src/tcf/services/dprintf.py b/python/src/tcf/services/dprintf.py new file mode 100644 index 000000000..1e54cca70 --- /dev/null +++ b/python/src/tcf/services/dprintf.py @@ -0,0 +1,84 @@ +# ***************************************************************************** +# * Copyright (c) 2014 Wind River Systems, Inc. and others. +# * All rights reserved. This program and the accompanying materials +# * are made available under the terms of the Eclipse Public License v1.0 +# * which accompanies this distribution, and is available at +# * http://www.eclipse.org/legal/epl-v10.html +# * +# * Contributors: +# * Wind River Systems - initial API and implementation +# ***************************************************************************** + +"""TCF DPrintf service interface. + +Service Methods +--------------- +.. autodata:: NAME +.. autoclass:: DPrintfService + +getName +^^^^^^^ +.. automethod:: DisassemblyService.getName + +open +^^^^^^^^^^^ +.. automethod:: DPrintfService.open + +close +^^^^^^^^^^^ +.. automethod:: DPrintfService.close + +""" + +from .. import services + +NAME = "DPrintf" +"""DPrintf service name.""" + + +class DPrintfService(services.Service): + def getName(self): + """Get this service name. + + :returns: The value of string :const:`NAME` + """ + return NAME + + def open(self): + """Open a virtual stream to get DPrintf output. + + :returns: The ID of the stream :basestring: `stream_id` + """ + raise NotImplementedError("Abstract method") + + def close(self): + """Close DPrintf virtual stream opened by this client. + + :returns: Pending command handle, can be used to cancel the command. + """ + raise NotImplementedError("Abstract method") + + +class DoneOpen(object): + """Call back interface for 'open' command.""" + def doneOpen(self, token, error, stream_id): + """Called when DPrintf open is done. + + :param token: command handle. + :param error: error object or None. + :param stream_id: ID of the DPrintf stream. + """ + pass + + +class DoneClose(object): + """Call back interface for |close| command.""" + + def doneClose(self, token, error): + """Called when DPrintf close is done. + + :param token: Pending command handle. + :param error: Error description if operation failed, **None** if + succeeded. + """ + pass diff --git a/python/src/tcf/services/remote/DPrintfProxy.py b/python/src/tcf/services/remote/DPrintfProxy.py new file mode 100644 index 000000000..057e0f433 --- /dev/null +++ b/python/src/tcf/services/remote/DPrintfProxy.py @@ -0,0 +1,59 @@ +# ***************************************************************************** +# * Copyright (c) 2014 Wind River Systems, Inc. and others. +# * All rights reserved. This program and the accompanying materials +# * are made available under the terms of the Eclipse Public License v1.0 +# * which accompanies this distribution, and is available at +# * http://www.eclipse.org/legal/epl-v10.html +# * +# * Contributors: +# * Wind River Systems - initial API and implementation +# ***************************************************************************** + +from .. import dprintf +from ...channel.Command import Command + + +class DPrintfProxy(dprintf.DPrintfService): + def __init__(self, channel): + self.channel = channel + self.listeners = {} + + def getName(self): + return (dprintf.NAME) + + def open(self, done, arg=None): + done = self._makeCallback(done) + service = self + + class OpenCommand(Command): + def __init__(self): + super(OpenCommand, self).__init__(service.channel, service, + "open", (arg,)) + + def done(self, error, args): + if not error: + assert len(args) == 2 + error = self.toError(args[0]) + vs = args[1] + + done.doneOpen(self.token, error, vs) + + return OpenCommand().token + + def close(self, done): + done = self._makeCallback(done) + service = self + + class CloseCommand(Command): + def __init__(self): + super(CloseCommand, self).__init__(service.channel, service, + "close", None) + + def done(self, error, args): + if not error: + assert len(args) == 1 + error = self.toError(args[0]) + + done.doneClose(self.token, error) + + return CloseCommand().token |