Functions to communicate using LLRP messages over a socket. More...
#include <assert.h>#include "ltkc_platform.h"#include "ltkc_base.h"#include "ltkc_frame.h"#include "ltkc_connection.h"Functions | |
| LLRP_tSConnection * | LLRP_Conn_construct (const LLRP_tSTypeRegistry *pTypeRegistry, unsigned int nBufferSize) |
| Construct a new LLRP connection instance. | |
| void | LLRP_Conn_destruct (LLRP_tSConnection *pConn) |
| Destruct a LLRP connection instance. | |
| int | LLRP_Conn_openConnectionToReader (LLRP_tSConnection *pConn, const char *pReaderHostName) |
| Open the connection to the reader. | |
| const char * | LLRP_Conn_getConnectError (LLRP_tSConnection *pConn) |
| Get the string that explains LLRP_Conn_openReaderConnection() error. | |
| int | LLRP_Conn_closeConnectionToReader (LLRP_tSConnection *pConn) |
| Close connection to reader, allow reuse of instance. | |
| LLRP_tSMessage * | LLRP_Conn_transact (LLRP_tSConnection *pConn, LLRP_tSMessage *pSendMessage, int nMaxMS) |
| Transact a LLRP request and response to a connection. | |
| const LLRP_tSErrorDetails * | LLRP_Conn_getTransactError (LLRP_tSConnection *pConn) |
| Get the details that explains LLRP_Conn_transact() error. | |
| LLRP_tResultCode | LLRP_Conn_sendMessage (LLRP_tSConnection *pConn, LLRP_tSMessage *pMessage) |
| Send a LLRP message to a connection. | |
| const LLRP_tSErrorDetails * | LLRP_Conn_getSendError (LLRP_tSConnection *pConn) |
| Get the details that explains LLRP_Conn_sendMessage() error. | |
| LLRP_tSMessage * | LLRP_Conn_recvMessage (LLRP_tSConnection *pConn, int nMaxMS) |
| Receive a message from a connection. | |
| const LLRP_tSErrorDetails * | LLRP_Conn_getRecvError (LLRP_tSConnection *pConn) |
| Get the details that explains LLRP_Conn_recvMessage() or LLRP_Conn_recvResponse() error. | |
| LLRP_tSMessage * | LLRP_Conn_recvResponse (LLRP_tSConnection *pConn, int nMaxMS, const LLRP_tSTypeDescriptor *pResponseType, llrp_u32_t ResponseMessageID) |
| Receive a specific message from a connection. | |
Functions to communicate using LLRP messages over a socket.
This provides a simple interface to send and receive LLRP messages using a network socket.
This is simplified. It is possible, even likely, that some applications could require much more sophistication. To that end this source file serves as an example to illustrate how framing, encoding, decoding, and response matching are done.
| int LLRP_Conn_closeConnectionToReader | ( | LLRP_tSConnection * | pConn | ) |
Close connection to reader, allow reuse of instance.
| [in] | pConn | Pointer to the connection instance. |
| LLRP_tSConnection* LLRP_Conn_construct | ( | const LLRP_tSTypeRegistry * | 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. |
| void LLRP_Conn_destruct | ( | LLRP_tSConnection * | pConn | ) |
Destruct a LLRP connection instance.
| [in] | pConn | Pointer to the connection instance. |
| const char* LLRP_Conn_getConnectError | ( | LLRP_tSConnection * | pConn | ) |
Get the string that explains LLRP_Conn_openReaderConnection() error.
| [in] | pConn | Pointer to the connection instance. |
| const LLRP_tSErrorDetails* LLRP_Conn_getRecvError | ( | LLRP_tSConnection * | pConn | ) |
Get the details that explains LLRP_Conn_recvMessage() or LLRP_Conn_recvResponse() error.
| [in] | pConn | Pointer to the connection instance. |
| const LLRP_tSErrorDetails* LLRP_Conn_getSendError | ( | LLRP_tSConnection * | pConn | ) |
Get the details that explains LLRP_Conn_sendMessage() error.
| [in] | pConn | Pointer to the connection instance. |
| const LLRP_tSErrorDetails* LLRP_Conn_getTransactError | ( | LLRP_tSConnection * | pConn | ) |
Get the details that explains LLRP_Conn_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 LLRP_Conn_sendMessage(), LLRP_Conn_recvMessage() or LLRP_CONN_recvResponse() since LLRP_Conn_transact() will distort the error.
| int LLRP_Conn_openConnectionToReader | ( | LLRP_tSConnection * | pConn, | |
| const char * | pReaderHostName | |||
| ) |
Open the connection to the reader.
The steps:
| [in] | pConn | Pointer to the connection instance. |
| [in] | pReaderHostName | String containing the reader host name |
| LLRP_tSMessage* LLRP_Conn_recvMessage | ( | LLRP_tSConnection * | pConn, | |
| int | nMaxMS | |||
| ) |
Receive a message from a connection.
The message could have already arrived and be pending on the input queue.
| [in] | pConn | Pointer to the connection instance. |
| [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 |
| LLRP_tSMessage* LLRP_Conn_recvResponse | ( | LLRP_tSConnection * | pConn, | |
| int | nMaxMS, | |||
| const LLRP_tSTypeDescriptor * | 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] | pConn | Pointer to the connection instance. |
| [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. |
| LLRP_tResultCode LLRP_Conn_sendMessage | ( | LLRP_tSConnection * | pConn, | |
| LLRP_tSMessage * | pMessage | |||
| ) |
Send a LLRP message to a connection.
| [in] | pConn | Pointer to the connection instance. |
| [in] | pMessage | Pointer to the LLRP message to send. |
| LLRP_tSMessage* LLRP_Conn_transact | ( | LLRP_tSConnection * | pConn, | |
| LLRP_tSMessage * | pSendMessage, | |||
| int | nMaxMS | |||
| ) |
Transact a LLRP request and response to a connection.
This is a combination of LLRP_Conn_sendMessage() and LLRP_Conn_recvResponse(). The MessageID is taken from the outgoing messages. It's best to not use MessageID 0. The expected response type is also taken from the outgoing message. ERROR_MESSAGE is also deemed a response;
| [in] | pConn | Pointer to the connection instance. |
| [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 |
1.6.3