aboutsummaryrefslogtreecommitdiff
path: root/contrib/rpc_examples
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/rpc_examples')
-rwxr-xr-xcontrib/rpc_examples/ocd_rpc_example.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/rpc_examples/ocd_rpc_example.py b/contrib/rpc_examples/ocd_rpc_example.py
index 4b1516a..9d17e76 100755
--- a/contrib/rpc_examples/ocd_rpc_example.py
+++ b/contrib/rpc_examples/ocd_rpc_example.py
@@ -49,10 +49,16 @@ class OpenOcd:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def __enter__(self):
- self.sock.connect((self.tclRpcIp, self.tclRpcPort))
+ self.connect()
return self
def __exit__(self, type, value, traceback):
+ self.disconnect()
+
+ def connect(self):
+ self.sock.connect((self.tclRpcIp, self.tclRpcPort))
+
+ def disconnect(self):
try:
self.send("exit")
finally: