LCM
lcm.h
1 #ifndef __lightweight_comunications_h__
2 #define __lightweight_comunications_h__
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdint.h>
9 
10 #include "eventlog.h"
11 
12 #define LCM_MAX_MESSAGE_SIZE (1 << 28)
13 
14 #define LCM_MAX_CHANNEL_NAME_LENGTH 63
15 
16 #ifdef WIN32
17 #define LCM_API_FUNCTION __declspec(dllexport)
18 #else
19 #define LCM_API_FUNCTION
20 #endif
21 
48 typedef struct _lcm_t lcm_t;
49 
53 typedef struct _lcm_subscription_t lcm_subscription_t;
54 
59 typedef struct _lcm_recv_buf_t lcm_recv_buf_t;
61 {
65  void *data;
69  uint32_t data_size;
74  int64_t recv_utime;
79 };
80 
90 typedef void (*lcm_msg_handler_t) (const lcm_recv_buf_t *rbuf,
91  const char *channel, void *user_data);
92 
190 LCM_API_FUNCTION
191 lcm_t * lcm_create (const char *provider);
192 
196 LCM_API_FUNCTION
197 void lcm_destroy (lcm_t *lcm);
198 
212 LCM_API_FUNCTION
213 int lcm_get_fileno (lcm_t *lcm);
214 
240 LCM_API_FUNCTION
241 lcm_subscription_t *lcm_subscribe (lcm_t *lcm, const char *channel,
242  lcm_msg_handler_t handler, void *userdata);
243 
259 LCM_API_FUNCTION
260 int lcm_unsubscribe (lcm_t *lcm, lcm_subscription_t *handler);
261 
277 LCM_API_FUNCTION
278 int lcm_publish (lcm_t *lcm, const char *channel, const void *data,
279  unsigned int datalen);
280 
299 LCM_API_FUNCTION
300 int lcm_handle (lcm_t *lcm);
301 
323 LCM_API_FUNCTION
324 int lcm_handle_timeout (lcm_t *lcm, int timeout_millis);
325 
344 LCM_API_FUNCTION
345 int lcm_subscription_set_queue_capacity(lcm_subscription_t* handler, int num_messages);
346 
348 #define LCM_MAJOR_VERSION 1
349 
351 #define LCM_MINOR_VERSION 3
352 
354 #define LCM_MICRO_VERSION 1
355 
360 #ifdef __cplusplus
361 }
362 #endif
363 
364 #endif
lcm_subscription_t
struct _lcm_subscription_t lcm_subscription_t
Definition: lcm.h:53
lcm_subscribe
lcm_subscription_t * lcm_subscribe(lcm_t *lcm, const char *channel, lcm_msg_handler_t handler, void *userdata)
Subscribe a callback function to a channel, without automatic message decoding.
lcm_create
lcm_t * lcm_create(const char *provider)
Constructor.
lcm_subscription_set_queue_capacity
int lcm_subscription_set_queue_capacity(lcm_subscription_t *handler, int num_messages)
Adjusts the maximum number of received messages that can be queued up for a subscription.
lcm_get_fileno
int lcm_get_fileno(lcm_t *lcm)
Returns a file descriptor or socket that can be used with select(), poll(), or other event loops for ...
lcm_publish
int lcm_publish(lcm_t *lcm, const char *channel, const void *data, unsigned int datalen)
Publish a message, specified as a raw byte buffer.
lcm_msg_handler_t
void(* lcm_msg_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, void *user_data)
Callback function prototype.
Definition: lcm.h:90
lcm_unsubscribe
int lcm_unsubscribe(lcm_t *lcm, lcm_subscription_t *handler)
Unsubscribe a message handler.
lcm_handle
int lcm_handle(lcm_t *lcm)
Wait for and dispatch the next incoming message.
lcm_handle_timeout
int lcm_handle_timeout(lcm_t *lcm, int timeout_millis)
Wait for and dispatch the next incoming message, up to a time limit.
_lcm_recv_buf_t::data
void * data
Definition: lcm.h:65
_lcm_recv_buf_t
Definition: lcm.h:60
_lcm_recv_buf_t::recv_utime
int64_t recv_utime
Definition: lcm.h:74
lcm_t
struct _lcm_t lcm_t
Definition: lcm.h:48
_lcm_recv_buf_t::data_size
uint32_t data_size
Definition: lcm.h:69
lcm_destroy
void lcm_destroy(lcm_t *lcm)
Destructor.
_lcm_recv_buf_t::lcm
lcm_t * lcm
Definition: lcm.h:78