LTKCPP-- LLRP Toolkit C Plus Plus Library
Public Member Functions
LLRP::CConnection Class Reference

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 a connection to the reader over an unencrypted socket.
int openSecureConnectionToReader (const char *pReaderHostName)
 Open a connection to the reader over an encrypted socket.
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.
 CConnection (const CTypeRegistry *pTypeRegistry, unsigned int nBufferSize)
int openConnectionToReader (const char *pReaderHostName)
int openSecureConnectionToReader (const char *pReaderHostName)
const char * getConnectError (void)
int closeConnectionToReader (void)
CMessagetransact (CMessage *pSendMessage, int nMaxMS)
const CErrorDetailsgetTransactError (void)
EResultCode sendMessage (CMessage *pMessage)
const CErrorDetailsgetSendError (void)
CMessagerecvMessage (int nMaxMS)
CMessagerecvResponse (int nMaxMS, const CTypeDescriptor *pResponseType, llrp_u32_t ResponseMessageID)
const CErrorDetailsgetRecvError (void)

Detailed Description

LLRP connection class.

An LLRP connection consists of:

Definition at line 59 of file Library/ltkcpp_connection.h.


Constructor & Destructor Documentation

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

Construct a new LLRP connection instance.

Parameters:
[in]pTypeRegistryThe LLRP registry of known message/parameter types. Includes standard and custom. Used during decode.
[in]nBufferSizeSize 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 87 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 426 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 409 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 716 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 631 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 537 of file ltkcpp_connection.cpp.

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

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

Open a connection to the reader over an unencrypted socket.

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

Definition at line 183 of file ltkcpp_connection.cpp.

Referenced by openSecureConnectionToReader().

int LLRP::CConnection::openSecureConnectionToReader ( const char *  pReaderHostName)

Open a connection to the reader over an encrypted socket.

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

Definition at line 199 of file ltkcpp_connection.cpp.

References openConnectionToReader().

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 658 of file ltkcpp_connection.cpp.

References LLRP::RC_MiscError, LLRP::RC_OK, 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]pResponseTypeThe type descriptor of the sought or NULL to match all messages. If not NULL, ERROR_MESSAGE will also match.
[in]ResponseMessageIDThe 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 769 of file ltkcpp_connection.cpp.

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

Referenced by transact().

EResultCode LLRP::CConnection::sendMessage ( CMessage pMessage)

Send a LLRP message to a connection.

Parameters:
[in]pMessagePointer 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 567 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]pSendMessagePointer 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 474 of file ltkcpp_connection.cpp.

References LLRP::CErrorDetails::clear(), 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: