LTKCPP-- LLRP Toolkit C Plus Plus Library
|
LLRP connection class. More...
#include <ltkcpp_connection.h>
Public Member Functions | |
CConnection (const CTypeRegistry *pTypeRegistry, unsigned int nBufferSize) | |
Construct a new LLRP connection instance. More... | |
~CConnection (void) | |
Destruct a LLRP connection instance. | |
int | openConnectionToReader (const char *pReaderHostName) |
Open a connection to the reader over an unencrypted socket. More... | |
int | openSecureConnectionToReader (const char *pReaderHostName) |
Open a connection to the reader over an encrypted socket. More... | |
const char * | getConnectError (void) |
Get the string that explains openReaderConnection() error. More... | |
int | closeConnectionToReader (void) |
Close connection to reader, allow reuse of instance. More... | |
CMessage * | transact (CMessage *pSendMessage, int nMaxMS) |
Transact a LLRP request and response to a connection. More... | |
const CErrorDetails * | getTransactError (void) |
Get the details that explains transact() error. More... | |
EResultCode | sendMessage (CMessage *pMessage) |
Send a LLRP message to a connection. More... | |
const CErrorDetails * | getSendError (void) |
Get the details that explains sendMessage() error. More... | |
CMessage * | recvMessage (int nMaxMS) |
Receive a message from a connection. More... | |
CMessage * | recvResponse (int nMaxMS, const CTypeDescriptor *pResponseType, llrp_u32_t ResponseMessageID) |
Receive a specific message from a connection. More... | |
const CErrorDetails * | getRecvError (void) |
Get the details that explains recvMessage() or recvResponse() error. More... | |
LLRP connection class.
An LLRP connection consists of:
Definition at line 59 of file ltkcpp_connection.h.
LLRP::CConnection::CConnection | ( | const CTypeRegistry * | pTypeRegistry, |
unsigned int | nBufferSize | ||
) |
Construct a new LLRP connection instance.
[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. |
Definition at line 63 of file ltkcpp_connection.cpp.
int LLRP::CConnection::closeConnectionToReader | ( | void | ) |
Close connection to reader, allow reuse of instance.
Definition at line 386 of file ltkcpp_connection.cpp.
Referenced by ~CConnection().
const char * LLRP::CConnection::getConnectError | ( | void | ) |
Get the string that explains openReaderConnection() error.
Definition at line 369 of file ltkcpp_connection.cpp.
const CErrorDetails * LLRP::CConnection::getRecvError | ( | void | ) |
Get the details that explains recvMessage() or recvResponse() error.
Definition at line 666 of file ltkcpp_connection.cpp.
Referenced by getTransactError().
const CErrorDetails * LLRP::CConnection::getSendError | ( | void | ) |
Get the details that explains sendMessage() error.
Definition at line 581 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.
Definition at line 487 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.
[in] | pReaderHostName | String containing the reader host name |
Definition at line 157 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.
[in] | pReaderHostName | String containing the reader host name |
Definition at line 173 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.
[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 |
Definition at line 608 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.
[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. |
Definition at line 719 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.
[in] | pMessage | Pointer to the LLRP message to send. |
Definition at line 517 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().
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.
[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 |
Definition at line 424 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().