/* ================================================================
** send_tick.c
**
** Send LCM tick_t
**
** 02 JAN 2009 Ryan Eustice  Created and written.
** ================================================================
*/

#include <stdio.h>

#include "libcommon/getopt.h"
#include "libcommon/timestamp.h"

#include "lcmtypes/perlcm_ticktock_t.h"


int
main (int argc, char *argv[])
{
    lcm_t * lcm;

    getopt_t *gopt = getopt_create ();
    getopt_add_bool (gopt, 'h', "help", 0, "Show this");
    getopt_add_string (gopt, 'C', "channel", "TICKTOCK", "LCM channel");

    if (!getopt_parse (gopt, argc, argv, 1) || getopt_get_bool (gopt, "help") ||
        gopt->extraargs->len != 0) {
        
        getopt_do_usage (gopt);
    }

    lcm = lcm_create (NULL);
    if (!lcm)
        return 1;

    perlcm_ticktock_t tt;
    const char *channel = getopt_get_string (gopt, "channel");
    tt.utime = timestamp_now ();
    perlcm_ticktock_t_publish (lcm, channel, &tt);

    lcm_destroy (lcm);
    return 0;
}
