All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
get_timestamp.c
1 
13 #include "urg_ctrl.h"
14 #include <stdio.h>
15 #include <stdlib.h>
16 
17 
18 static void urg_exit(urg_t *urg, const char *message)
19 {
20  printf("%s: %s\n", message, urg_error(urg));
21  urg_disconnect(urg);
22 
23 #ifdef MSC
24  getchar();
25 #endif
26  exit(1);
27 }
28 
29 
31 int main(int argc, char *argv[])
32 {
33  enum {
34  CaptureTimes = 10,
35  };
36 
37  //const char device[] = "COM3"; /* Example for Windows */
38  const char device[] = "/dev/ttyACM0"; /* Example for Linux */
39 
40  long timestamp = 0;
41  int ret = 0;
42  int i;
43 
44  /* Connection */
45  urg_t urg;
46  ret = urg_connect(&urg, device, 115200);
47  if (ret < 0) {
48  urg_exit(&urg, "urg_connect()");
49  }
50 
51  /* Transit to timestamp mode and displays time stamp */
53  for (i = 0; i < CaptureTimes; ++i) {
54  timestamp = urg_currentTimestamp(&urg);
55  printf("%02d: timestamp: %ld [msec]\n", i, timestamp);
56  }
58 
59  return 0;
60 }