LCM

Classes | Functions
lcm_eventlog_t
C API Reference

Read and write LCM log files. More...

## Classes
struct | lcm_eventlog_t
struct | lcm_eventlog_event_t

## Functions
lcm_eventlog_t * | lcm_eventlog_create (const char *path, const char *mode)
lcm_eventlog_event_t * | lcm_eventlog_read_next_event (lcm_eventlog_t *eventlog)
void | lcm_eventlog_free_event (lcm_eventlog_event_t *event)
int | lcm_eventlog_seek_to_timestamp (lcm_eventlog_t *eventlog, int64_t ts)
int | lcm_eventlog_write_event (lcm_eventlog_t *eventlog, lcm_eventlog_event_t *event)
void | lcm_eventlog_destroy (lcm_eventlog_t *eventlog)

## Detailed Description

Read and write LCM log files.

#include <lcm/lcm.h>

Linking: ``pkg-config --libs lcm``

## Function Documentation

## ◆ lcm_eventlog_create()

lcm_eventlog_t* lcm_eventlog_create | ( | const char * | path,
|  | const char * | mode
| ) |  |

Open a log file for reading or writing.

Parameters

  path | Log file to open
  mode | "r" (read mode), "w" (write mode), or "a" (append mode)

Returns
  a newly allocated lcm_eventlog_t, or NULL on failure.

## ◆ lcm_eventlog_destroy()

void lcm_eventlog_destroy | ( | lcm_eventlog_t * | eventlog | ) |

Close a log file and release allocated resources.

Parameters

  eventlog | The log file object

## ◆ lcm_eventlog_free_event()

void lcm_eventlog_free_event | ( | lcm_eventlog_event_t * | event | ) |

Free a structure returned by lcm_eventlog_read_next_event().

Parameters

  event | A structure returned by lcm_eventlog_read_next_event()

## ◆ lcm_eventlog_read_next_event()

lcm_eventlog_event_t* lcm_eventlog_read_next_event | ( | lcm_eventlog_t * | eventlog | ) |

Read the next event in the log file. Valid in read mode only. Free the returned structure with lcm_eventlog_free_event() after use.

Parameters

  eventlog | The log file object

Returns
  the next event in the log file. Returns NULL when the end of the file has been reached or when invalid data is read.

## ◆ lcm_eventlog_seek_to_timestamp()

int lcm_eventlog_seek_to_timestamp | ( | lcm_eventlog_t * | eventlog,
|  | int64_t | ts
| ) |  |

Seek (approximately) to a particular timestamp.

Parameters

  eventlog | The log file object
  ts | Timestamp of the target event in the log file.

Returns
  0 on success, -1 on failure

## ◆ lcm_eventlog_write_event()

int lcm_eventlog_write_event | ( | lcm_eventlog_t * | eventlog,
|  | lcm_eventlog_event_t * | event
| ) |  |

Write an event into a log file. Valid in write mode only.

Parameters

  eventlog | The log file object
  event | The event to write to the file. On return, the eventnum field will be filled in for you.

Returns
  0 on success, -1 on failure.