void* sensor_init(void *null_pointer) { port = scipConnect("/dev/ttyACM0"); if (port == NULL) { perror("Could not connect to the sensor "); exit(EXIT_FAILURE); } // use SCIP2.0 switchToScip2(port); if(scip2SetComSpeed(port,115200)!=0) { fprintf(stderr,"Could not change speed\n"); exit(EXIT_FAILURE); } last_poll = utime() - poll_time; }
void* sensor_init(void *null_pointer) { int max_data_size; urg_connection_type_t type_eth = URG_ETHERNET; urg_measurement_type_t m_type_eth = URG_MULTIECHO; char *device_eth = "192.168.0.10"; char *device_usb = "/dev/ttyACM0"; eth = 0; usb = 0; if (urg_open(&connection_eth, type_eth, device_eth, 10940) < 0) { printf("Could not connect to the ethernet sensor\n"); } else eth = 1; connection_usb = scipConnect(device_usb); if (connection_usb == NULL) { printf("Could not connect to the usb sensor\n"); } else usb = 1; // start measurement if (eth) { max_data_size = urg_max_data_size(&connection_eth); buffer_eth = malloc(sizeof(int)*max_data_size); urg_start_measurement(&connection_eth, m_type_eth, 0, 0); last_poll_eth = utime() - poll_time_eth; } if (usb) { switchToScip2(connection_usb); scip2SetComSpeed(connection_usb,115200); last_poll_usb = utime() - poll_time_usb; } return NULL; }