open_urg_sensor.c
Go to the documentation of this file.
00001 
00011 #include "open_urg_sensor.h"
00012 #include "urg_c/urg_utils.h"
00013 #include "urg_c/urg_detect_os.h"
00014 #include <string.h>
00015 #include <stdio.h>
00016 
00017 
00018 int open_urg_sensor(urg_t *urg, int argc, char *argv[])
00019 {
00020 #if defined(URG_WINDOWS_OS)
00021     const char *device = "COM4";
00022 #elif defined(URG_LINUX_OS)
00023     const char *device = "/dev/ttyACM0";
00024     //const char *device = "/dev/ttyUSB0";
00025 #else
00026     const char *device = "/dev/tty.usbmodemfa131";
00027 #endif
00028     urg_connection_type_t connection_type = URG_SERIAL;
00029     long baudrate_or_port = 115200;
00030     //const char *ip_address = "localhost";
00031     const char *ip_address = "192.168.0.10";
00032     int i;
00033 
00034     // \~japanese 接続タイプの切替え
00035     for (i = 1; i < argc; ++i) {
00036         if (!strcmp(argv[i], "-e")) {
00037             connection_type = URG_ETHERNET;
00038             baudrate_or_port = 10940;
00039             device = ip_address;
00040         }
00041     }
00042 
00043     // \~japanese 接続
00044     if (urg_open(urg, connection_type, device, baudrate_or_port) < 0) {
00045         printf("urg_open: %s, %ld: %s\n",
00046             device, baudrate_or_port, urg_error(urg));
00047         return -1;
00048     }
00049 
00050     return 0;
00051 }


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Wed Aug 26 2015 16:38:27