32 #include <sys/types.h> 37 #endif // HAVE_CONFIG_H 64 sigjmp_buf ctrlc_capture;
66 jmp_buf ctrlc_capture;
67 #endif // HAVE_SIGLONGJMP 70 #if defined(__MINGW32__) 71 BOOL WINAPI win32_ctrlc_handler(DWORD type)
73 fprintf(stderr,
"\n");
90 fprintf(stderr,
"\n");
93 siglongjmp(ctrlc_capture, 1);
95 longjmp(ctrlc_capture, 1);
108 #endif // HAVE_SIGLONGJMP 110 #endif // defined(__MINGW32__) 114 #if defined(__MINGW32__) 115 if (!SetConsoleCtrlHandler(win32_ctrlc_handler, TRUE))
121 #endif // defined(__MINGW32__) 125 int main(
int argc,
char *argv[])
127 pthread_t command_thread;
128 pthread_t control_thread;
129 pthread_t update_thread;
130 int command_thread_en;
131 int control_thread_en;
132 int update_thread_en;
164 close(STDOUT_FILENO);
165 close(STDERR_FILENO);
188 fprintf(stderr,
"YamabicoProject-Spur\n");
189 fprintf(stderr,
" Ver. %s\n", PROJECT_VERSION);
220 command_thread_en = 0;
221 command_thread_en = 0;
224 FILE *temp_paramfile = NULL;
240 int device_current, device_age;
241 sscanf(YP_PROTOCOL_NAME,
"YPP:%d:%d", ¤t, &age);
244 for (i = 0; i < 3; i++)
256 sscanf(version.
protocol,
"YPP:%d:%d", &device_current, &device_age);
259 if (device_current - device_age > current ||
260 device_current < current - age)
275 yprintf(
OUTPUT_LV_ERROR,
"Error: Device doesn't have available YP protocol version.\n(Device: %s, coordinator: %s)\n",
276 version.
protocol, YP_PROTOCOL_NAME);
284 if (device_current != current)
286 if (device_current < current)
330 if (strcmp(driver_param.
robot_name,
"embedded") == 0)
335 temp_paramfile = tmpfile();
351 fprintf(temp_paramfile,
"%s", param);
352 fseek(temp_paramfile, 0L, SEEK_SET);
355 else if (strlen(driver_param.
robot_name) > 0 && strcmp(driver_param.
robot_name,
"unknown") != 0)
449 command_thread_en = 1;
454 control_thread_en = 1;
458 control_thread_en = 0;
468 update_thread_en = 1;
472 update_thread_en = 0;
477 if (sigsetjmp(ctrlc_capture, 1) != 0)
483 if (setjmp(ctrlc_capture) != 0)
488 #endif // HAVE_SIGLONGJMP 503 if (update_thread_en)
505 pthread_cancel(update_thread);
506 pthread_join(update_thread, NULL);
507 update_thread_en = 0;
509 if (control_thread_en)
511 pthread_cancel(control_thread);
512 pthread_join(control_thread, NULL);
513 control_thread_en = 0;
515 if (command_thread_en)
517 pthread_cancel(command_thread);
518 pthread_join(command_thread, NULL);
519 command_thread_en = 0;
553 return (quit ? EXIT_SUCCESS : EXIT_FAILURE);
int set_baudrate(int baud)
MotorControlMode wheel_mode_prev[YP_PARAM_MAX_MOTOR_NUM]
int serial_tryconnect(char *device_name)
double * pp(YPSpur_param id, enum motor_id motor)
void init_command_thread(pthread_t *thread)
int main(int argc, char *argv[])
void arg_longhelp(int argc, char *argv[])
int odometry_receive_loop(void)
MotorControlMode wheel_mode[YP_PARAM_MAX_MOTOR_NUM]
void init_control_thread(pthread_t *thread)
int apply_robot_params(void)
void init_spur_command(void)
void hook_pre_global(void)
int get_embedded_param(char *param)
char parameter_filename[132]
SpurUserParamsPtr get_spur_user_param_ptr()
int set_paramptr(FILE *paramfile)
#define YP_PARAM_MAX_MOTOR_NUM
void yprintf(ParamOutputLv level, const char *format,...)
int get_version(Ver_t *apVer)
Get version info.
int get_parameter(Param_t *apParam)
Get version info.
void ansi_clear_line(ParamOutputLv level)
void init_coordinate_systems(void)
int option(ParamOptions option)
int set_param(char *filename, char *concrete_path)
int serial_connect(char *device_name)
void init_ypspurSSM(int ssm_id)
int arg_analyze(int argc, char *argv[])
ParametersPtr get_param_ptr()
void init_param_update_thread(pthread_t *thread, char *filename)
void arg_help(int argc, char *argv[])