Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

LLRP::CConnection Class Reference
[Core LTK Library classes and functions]

LLRP connection class. More...

#include <ltkcpp_connection.h>

List of all members.

Public Member Functions

 CConnection (const CTypeRegistry *pTypeRegistry, unsigned int nBufferSize)
 Construct a new LLRP connection instance.
 ~CConnection (void)
 Destruct a LLRP connection instance.
int openConnectionToReader (const char *pReaderHostName)
 Open the connection to the reader.
const char * getConnectError (void)
 Get the string that explains openReaderConnection() error.
int closeConnectionToReader (void)
 Close connection to reader, allow reuse of instance.
CMessagetransact (CMessage *pSendMessage, int nMaxMS)
 Transact a LLRP request and response to a connection.
const CErrorDetailsgetTransactError (void)
 Get the details that explains transact() error.
EResultCode sendMessage (CMessage *pMessage)
 Send a LLRP message to a connection.
const CErrorDetailsgetSendError (void)
 Get the details that explains sendMessage() error.
CMessagerecvMessage (int nMaxMS)
 Receive a message from a connection.
CMessagerecvResponse (int nMaxMS, const CTypeDescriptor *pResponseType, llrp_u32_t ResponseMessageID)
 Receive a specific message from a connection.
const CErrorDetailsgetRecvError (void)
 Get the details that explains recvMessage() or recvResponse() error.


Detailed Description

LLRP connection class.

An LLRP connection consists of:

Definition at line 81 of file ltkcpp_connection.h.


Constructor & Destructor Documentation

LLRP::CConnection::CConnection const CTypeRegistry pTypeRegistry,
unsigned int  nBufferSize
 

Construct a new LLRP connection instance.

Parameters:
[in] pTypeRegistry The LLRP registry of known message/parameter types. Includes standard and custom. Used during decode.
[in] nBufferSize Size of each the receive and send buffers. Use size larger than the largest frame you expect. 0 selects a default value.
Returns:
!=NULL Pointer to connection instance ==NULL Error, always an allocation failure most likely nBufferSize is weird

Definition at line 138 of file ltkcpp_connection.cpp.


Member Function Documentation

int LLRP::CConnection::closeConnectionToReader void   ) 
 

Close connection to reader, allow reuse of instance.

Returns:
==0 Connected OK, ready for business !=0 Error, check getConnectError() for reason

Definition at line 405 of file ltkcpp_connection.cpp.

Referenced by ~CConnection().

const char * LLRP::CConnection::getConnectError void   ) 
 

Get the string that explains openReaderConnection() error.

Returns:
==NULL No error !=NULL Short string description of error

Definition at line 388 of file ltkcpp_connection.cpp.

const CErrorDetails * LLRP::CConnection::getRecvError void   ) 
 

Get the details that explains recvMessage() or recvResponse() error.

Returns:
Pointer to const error details

Definition at line 718 of file ltkcpp_connection.cpp.

Referenced by getTransactError().

const CErrorDetails * LLRP::CConnection::getSendError void   ) 
 

Get the details that explains sendMessage() error.

Returns:
Pointer to const error details

Definition at line 633 of file ltkcpp_connection.cpp.

Referenced by getTransactError().

const CErrorDetails * LLRP::CConnection::getTransactError void   ) 
 

Get the details that explains transact() error.

This is not 100% reliable. It looks at the send error and if that seems OK it uses the recv error. Uses of sendMessage(), recvMessage() or recvResponse() since transact() will distort the error.

Returns:
Pointer to const error details

Definition at line 514 of file ltkcpp_connection.cpp.

References getRecvError(), getSendError(), LLRP::CErrorDetails::m_eResultCode, and LLRP::RC_OK.

int LLRP::CConnection::openConnectionToReader const char *  pReaderHostName  ) 
 

Open the connection to the reader.

The steps:

  • Look up the host name
  • Create a socket
  • Connect to the host address
  • Condition the socket (set options)

Parameters:
[in] pReaderHostName String containing the reader host name
Returns:
==0 Connected OK, ready for business !=0 Error, check getConnectError() for reason

Definition at line 261 of file ltkcpp_connection.cpp.

CMessage * LLRP::CConnection::recvMessage int  nMaxMS  ) 
 

Receive a message from a connection.

The message could have already arrived and be pending on the input queue.

Parameters:
[in] nMaxMS -1 => block indefinitely 0 => just peek at input queue and socket queue, return immediately no matter what >0 => ms to await complete frame
Returns:
==NULL No message available per parameters. Check getRecvError() for why !=NULL Input message

Definition at line 660 of file ltkcpp_connection.cpp.

References LLRP::EResultCode, LLRP::RC_MiscError, and LLRP::CErrorDetails::resultCodeAndWhatStr().

CMessage * LLRP::CConnection::recvResponse int  nMaxMS,
const CTypeDescriptor pResponseType,
llrp_u32_t  ResponseMessageID
 

Receive a specific message from a connection.

The message is identified by type and message ID.

This is used to receive a response to a request, but could be used for other things, too. A message matches and is returned if the type matches AND if the message ID matches. Either or both can be wildcards.

The sought message could have already arrived and be pending on the input queue. While we are looking for the response notifications might arrive. They are held in the input queue while we continue to look for the sought message.

About timeLimit.... The timeLimit is the last time() we'll try to receive the sought message and prevents "spinning". It is conceivable that a steady stream of messages other than the one sought could arrive, and the time between those messages could be smaller the nMaxMS. When that happens, recvAdvance() would not time out during its poll/select. It could "spin". The time out must be detected by other means and that's the purpose of timeLimit.

Parameters:
[in] nMaxMS -1 => block indefinitely 0 => just peek at input queue and socket queue, return immediately no matter what >0 => ms to await complete frame
[in] pResponseType The type descriptor of the sought or NULL to match all messages. If not NULL, ERROR_MESSAGE will also match.
[in] ResponseMessageID The MessageID of sought message or 0 to match all messages.
Returns:
==NULL No message available per parameters. Check getRecvError() for why !=NULL Input message

Definition at line 771 of file ltkcpp_connection.cpp.

References LLRP::EResultCode, LLRP::CMessage::getMessageID(), LLRP::CTypeRegistry::lookupMessage(), LLRP::CElement::m_pType, LLRP::RC_MiscError, and LLRP::CErrorDetails::resultCodeAndWhatStr().

Referenced by transact().

EResultCode LLRP::CConnection::sendMessage CMessage pMessage  ) 
 

Send a LLRP message to a connection.

Parameters:
[in] pMessage Pointer to the LLRP message to send.
Returns:
RC_OK Frame sent RC_SendIOError I/O error in write(). Probably means fd is bad. RC_... Encoder error. Check getSendError() for why.

Definition at line 544 of file ltkcpp_connection.cpp.

References LLRP::CErrorDetails::clear(), LLRP::CErrorDetails::m_eResultCode, LLRP::RC_MiscError, LLRP::RC_OK, LLRP::RC_SendIOError, and LLRP::CErrorDetails::resultCodeAndWhatStr().

Referenced by transact().

CMessage * LLRP::CConnection::transact CMessage pSendMessage,
int  nMaxMS
 

Transact a LLRP request and response to a connection.

This is a combination of sendMessage() and recvResponse(). The MessageID is taken from the outgoing messages. It's best to not use MessageID 0.

Parameters:
[in] pSendMessage Pointer to the LLRP message to send.
[in] nMaxMS -1 => block indefinitely 0 => just peek at input queue and socket queue, return immediately no matter what >0 => ms to await complete frame
Returns:
==NULL Something failed. Use getTransactError() for best guess at what went wrong. !=NULL Response message

Definition at line 451 of file ltkcpp_connection.cpp.

References LLRP::CErrorDetails::clear(), LLRP::EResultCode, LLRP::CMessage::getMessageID(), LLRP::CTypeDescriptor::m_pResponseType, LLRP::CElement::m_pType, LLRP::RC_MissingResponseType, LLRP::RC_OK, recvResponse(), LLRP::CErrorDetails::resultCodeAndWhatStr(), and sendMessage().


The documentation for this class was generated from the following files:
Generated on Wed Nov 26 12:27:57 2008 for LTKCPP-- LLRP Toolkit C Plus Plus Library by  doxygen 1.3.9.1