open_urg_sensor.c
Go to the documentation of this file.
1 
11 #include "open_urg_sensor.h"
12 #include "urg_c/urg_utils.h"
13 #include "urg_c/urg_detect_os.h"
14 #include <string.h>
15 #include <stdio.h>
16 
17 
18 int open_urg_sensor(urg_t *urg, int argc, char *argv[])
19 {
20 #if defined(URG_WINDOWS_OS)
21  const char *device = "COM4";
22 #elif defined(URG_LINUX_OS)
23  const char *device = "/dev/ttyACM0";
24  //const char *device = "/dev/ttyUSB0";
25 #else
26  const char *device = "/dev/tty.usbmodemfa131";
27 #endif
28  urg_connection_type_t connection_type = URG_SERIAL;
29  long baudrate_or_port = 115200;
30  //const char *ip_address = "localhost";
31  const char *ip_address = "192.168.0.10";
32  int i;
33 
34  // \~japanese 接続タイプの切替え
35  for (i = 1; i < argc; ++i) {
36  if (!strcmp(argv[i], "-e")) {
37  connection_type = URG_ETHERNET;
38  baudrate_or_port = 10940;
39  device = ip_address;
40  }
41  }
42 
43  // \~japanese 接続
44  if (urg_open(urg, connection_type, device, baudrate_or_port) < 0) {
45  printf("urg_open: %s, %ld: %s\n",
46  device, baudrate_or_port, urg_error(urg));
47  return -1;
48  }
49 
50  return 0;
51 }
URG sensor.
Definition: urg_sensor.h:72
OS の検出.
イーサーネット接続
const char * urg_error(const urg_t *urg)
Definition: urg_utils.c:30
urg_connection_type_t
通信タイプ
int open_urg_sensor(urg_t *urg, int argc, char *argv[])
URG sensor utility.
int urg_open(urg_t *urg, urg_connection_type_t connection_type, const char *device_or_address, long baudrate_or_port)
Definition: urg_sensor.c:684
シリアル, USB 接続


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Thu Jun 6 2019 19:27:49