TestCenter Reference
TestCenterAdvanced.IPC.Communicator Class Reference

The Communicator is the superclass for the communicating entities. More...

Inheritance diagram for TestCenterAdvanced.IPC.Communicator:
TestCenterAdvanced.IPC.ComMaster TestCenterAdvanced.IPC.ComSlave

Public Member Functions

 __init__ (self)
 
 getPort (self)
 Get the port used for connections.
 
 isConnected (self)
 Get the connection status of the IPC client.
 
 send (self, data, timeout)
 Send the data via the socket using the given timeout.
 
 recv (self, timeout)
 Receive data via the socket using the given timeout.
 
 getLastError (self)
 Get a tuple describing the last error.
 
 getLastErrorWithMessage (self)
 Get a tuple describing the last error.
 

Protected Member Functions

 _send (self, data, length, timeout)
 Send's little helper.
 
 _recv (self, length, timeout)
 Receive's little helper.
 
 _handleError (self, errorCode, errorMsg, silent=False)
 Set the error code and message and disconnect from network.
 

Protected Attributes

 _mHost
 IP to connect to.
 
 _mPort
 Port to use for the connection.
 
 _mConnected
 Status of the connection.
 
 _msocket
 Main socket of the server.
 
 _csocket
 Connection socket.
 
 _mErrorCode
 Internal error code used to track the last error.
 
 _mErrorMsg
 Internal error messages.
 

Static Protected Attributes

int _mMsgLength = 8192
 Length of the messages sent between the two entities.
 

Detailed Description

The Communicator is the superclass for the communicating entities.

This class contains the fundamental routines for sending messages between the two entities master and slave. The communication protocol consists of two parts. First the length of the message is sent via a string with exactly 16 bytes. This fixed length is essential as with asynchronous communication many non obvious things can happen (like only parts of messages being transmitted or concatenation of successivly sent messages). The second part of the communication protocol sends the actual data in junks of a given size.

Definition at line 51 of file IPC.py.

Constructor & Destructor Documentation

◆ __init__()

TestCenterAdvanced.IPC.Communicator.__init__ ( self)

Reimplemented in TestCenterAdvanced.IPC.ComSlave, and TestCenterAdvanced.IPC.ComMaster.

Definition at line 56 of file IPC.py.

Member Function Documentation

◆ _handleError()

TestCenterAdvanced.IPC.Communicator._handleError ( self,
errorCode,
errorMsg,
silent = False )
protected

◆ _recv()

TestCenterAdvanced.IPC.Communicator._recv ( self,
length,
timeout )
protected

Receive's little helper.

This method first waits for the socket to get ready for receiving. This is done using the timeout to assure this operation doesn't block everything. Afterwards data is received in junks of a size specified in _mMsgLength via the socket. The length of the data expected must be given.

Definition at line 174 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._csocket, TestCenterAdvanced.IPC.ComMaster._csocket, TestCenterAdvanced.IPC.ComSlave._csocket, TestCenterAdvanced.IPC.Communicator._handleError(), and TestCenterAdvanced.IPC.Communicator.recv().

Referenced by TestCenterAdvanced.IPC.Communicator.recv().

◆ _send()

TestCenterAdvanced.IPC.Communicator._send ( self,
data,
length,
timeout )
protected

Send's little helper.

This method first waits for the socket to get ready for sending. This is done using the timeout to assure this operation doesn't block everything. Afterwards all data is send in junks of a size specified in _mMsgLength via the socket.

Definition at line 114 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._csocket, TestCenterAdvanced.IPC.ComMaster._csocket, TestCenterAdvanced.IPC.ComSlave._csocket, TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mMsgLength, and TestCenterAdvanced.IPC.Communicator.send().

Referenced by TestCenterAdvanced.IPC.Communicator.send().

◆ getLastError()

TestCenterAdvanced.IPC.Communicator.getLastError ( self)

Get a tuple describing the last error.

Each failure event sets an internal error code which can be read using this method.

Definition at line 203 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._mErrorCode, and TestCenterAdvanced.IPC.ComMaster._mErrorCode.

◆ getLastErrorWithMessage()

TestCenterAdvanced.IPC.Communicator.getLastErrorWithMessage ( self)

Get a tuple describing the last error.

Each failure event sets an internal error code which can be read using this method.

Definition at line 210 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._mErrorCode, TestCenterAdvanced.IPC.ComMaster._mErrorCode, TestCenterAdvanced.IPC.Communicator._mErrorMsg, and TestCenterAdvanced.IPC.ComMaster._mErrorMsg.

◆ getPort()

TestCenterAdvanced.IPC.Communicator.getPort ( self)

Get the port used for connections.

Definition at line 78 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._mPort, TestCenterAdvanced.IPC.ComMaster._mPort, and TestCenterAdvanced.IPC.ComSlave._mPort.

◆ isConnected()

TestCenterAdvanced.IPC.Communicator.isConnected ( self)

◆ recv()

TestCenterAdvanced.IPC.Communicator.recv ( self,
timeout )

Receive data via the socket using the given timeout.

This method implements the receiving part of the protocol specified in the description of send. This method returns True if it succeeded sending the data, False otherwise.

Definition at line 147 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mConnected, TestCenterAdvanced.IPC.ComMaster._mConnected, TestCenterAdvanced.IPC.ComSlave._mConnected, and TestCenterAdvanced.IPC.Communicator._recv().

Referenced by TestCenterAdvanced.IPC.Communicator._recv().

◆ send()

TestCenterAdvanced.IPC.Communicator.send ( self,
data,
timeout )

Send the data via the socket using the given timeout.

This method returns True if it succeeded sending the data, False otherwise.

Definition at line 91 of file IPC.py.

References TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mConnected, TestCenterAdvanced.IPC.ComMaster._mConnected, TestCenterAdvanced.IPC.ComSlave._mConnected, and TestCenterAdvanced.IPC.Communicator._send().

Referenced by TestCenterAdvanced.IPC.Communicator._send().

Member Data Documentation

◆ _csocket

◆ _mConnected

◆ _mErrorCode

TestCenterAdvanced.IPC.Communicator._mErrorCode
protected

◆ _mErrorMsg

TestCenterAdvanced.IPC.Communicator._mErrorMsg
protected

◆ _mHost

TestCenterAdvanced.IPC.Communicator._mHost
protected

IP to connect to.

Definition at line 59 of file IPC.py.

◆ _mMsgLength

int TestCenterAdvanced.IPC.Communicator._mMsgLength = 8192
staticprotected

Length of the messages sent between the two entities.

Definition at line 54 of file IPC.py.

Referenced by TestCenterAdvanced.IPC.Communicator._send().

◆ _mPort

TestCenterAdvanced.IPC.Communicator._mPort
protected

Port to use for the connection.

Definition at line 61 of file IPC.py.

Referenced by TestCenterAdvanced.IPC.Communicator.getPort().

◆ _msocket

TestCenterAdvanced.IPC.Communicator._msocket
protected

Main socket of the server.

Definition at line 66 of file IPC.py.

Referenced by TestCenterAdvanced.IPC.ComMaster.__del__().


The documentation for this class was generated from the following file: