Skip to content

Commit

Permalink
Rename client to master.
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Mar 18, 2018
1 parent 319f9ef commit da72ca2
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 72 deletions.
38 changes: 36 additions & 2 deletions pyxcp/client.py → pyxcp/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __str__(self):
__repr__ = __str__


class Client(object):
class Master(object):

def __init__(self, transport):
self.ctr = 0
Expand All @@ -157,7 +157,9 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
if exc_tb:
if exc_type is None:
return
else:
self.succeeded = False
#print("=" * 79)
#print("Exception while in Context-Manager:\n")
Expand All @@ -177,6 +179,25 @@ def sendCRO(self, canID, cmd, ctr, b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 =
## Mandatory Commands.
##
def connect(self):
"""Build up connection to an XCP slave.
Before the actual XCP traffic starts a connection is required.
Parameters
----------
None
Returns
-------
`types.ConnectResponse`
Describes fundamental client properties.
Note
----
Every XCP slave supports at most one connection,
more attempts to connect are silently ignored.
"""
response = self.transport.request(types.Command.CONNECT, 0x00)
result = types.ConnectResponse.parse(response)
self.maxCto = result.maxCto
Expand All @@ -189,6 +210,19 @@ def connect(self):
return result

def disconnect(self):
"""Releases the connection to the XCP slave.
Thereafter, no further communication with the slave is possible (besides `connect`).
Parameters
----------
None
Returns
-------
None
"""
response = self.transport.request(types.Command.DISCONNECT)

def getStatus(self):
Expand Down

0 comments on commit da72ca2

Please sign in to comment.