LCM
lcm.h
1 #ifndef __lightweight_communications_h__
2 #define __lightweight_communications_h__
3 
4 #include <stdint.h>
5 
6 #include "lcm_version.h"
7 
8 #ifdef LCM_PYTHON
9 #define LCM_EXPORT
10 #else
11 #include "lcm_export.h"
12 #endif
13 
14 #include "eventlog.h"
15 
16 #define LCM_MAX_MESSAGE_SIZE (1 << 28)
17 
18 #define LCM_MAX_CHANNEL_NAME_LENGTH 63
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
50 typedef struct _lcm_t lcm_t;
51 
55 typedef struct _lcm_subscription_t lcm_subscription_t;
56 
61 typedef struct _lcm_recv_buf_t lcm_recv_buf_t;
66  void *data;
70  uint32_t data_size;
75  int64_t recv_utime;
80 };
81 
91 typedef void (*lcm_msg_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, void *user_data);
92 
190 LCM_EXPORT
191 lcm_t *lcm_create(const char *provider);
192 
196 LCM_EXPORT
197 void lcm_destroy(lcm_t *lcm);
198 
212 LCM_EXPORT
214 
240 LCM_EXPORT
241 lcm_subscription_t *lcm_subscribe(lcm_t *lcm, const char *channel, lcm_msg_handler_t handler,
242  void *userdata);
243 
259 LCM_EXPORT
261 
277 LCM_EXPORT
278 int lcm_publish(lcm_t *lcm, const char *channel, const void *data, unsigned int datalen);
279 
298 LCM_EXPORT
299 int lcm_handle(lcm_t *lcm);
300 
322 LCM_EXPORT
323 int lcm_handle_timeout(lcm_t *lcm, int timeout_millis);
324 
343 LCM_EXPORT
345 
349 LCM_EXPORT
351 
356 #ifdef __cplusplus
357 }
358 #endif
359 
360 #endif
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.
int lcm_subscription_get_queue_size(lcm_subscription_t *handler)
Query the current number of unhandled messages queued up for a subscription.
void(* lcm_msg_handler_t)(const lcm_recv_buf_t *rbuf, const char *channel, void *user_data)
Callback function prototype.
Definition: lcm.h:91
struct _lcm_subscription_t lcm_subscription_t
Definition: lcm.h:55
int lcm_handle_timeout(lcm_t *lcm, int timeout_millis)
Wait for and dispatch the next incoming message, up to a time limit.
void lcm_destroy(lcm_t *lcm)
Destructor.
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 ...
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.
int lcm_unsubscribe(lcm_t *lcm, lcm_subscription_t *handler)
Unsubscribe a message handler.
int lcm_handle(lcm_t *lcm)
Wait for and dispatch the next incoming message.
struct _lcm_t lcm_t
Definition: lcm.h:50
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_t * lcm_create(const char *provider)
Constructor.
Definition: lcm.h:62
int64_t recv_utime
Definition: lcm.h:75
lcm_t * lcm
Definition: lcm.h:79
uint32_t data_size
Definition: lcm.h:70
void * data
Definition: lcm.h:66