Ejemplo n.º 1
0
/*
void bluetooth(void) {
  unsigned int redata,Ddata,choice;
  if(identityset==1)
  {
    redatah=LPLD_UART_GetChar(UART4);
    if(redatah==255)
    {
      identityset=0;
    }
  }
  
  if(identityset==2)
  {
    identityset=0;
    redata=LPLD_UART_GetChar(UART4)+redatah*256;
    choice=redata/4096;
    redata=redata%4096;
    Ddata=redata/256*100+redata/16%16*10+redata%16;
    
    switch(choice)
    {        
    case 0:  turnleft_time_set=Ddata*10;break;
    case 1:  testvalue1=Ddata;break;//将想要实时修改的全局变量替换掉null 在串口调试助手中  
    case 2:  PID_KP=Ddata;break;//输入四位的十六进制字符串 当做十进制的输入就可以了
    case 3:  testvalue3=Ddata;break;//第一个数位你想要改变的变量对应编号
    case 4:  testvalue4=Ddata;break;
    case 5:  testvalue5=Ddata;break;
    case 6:  haoswitch=Ddata;break;
    //case 7:  kd1=Ddata;break;
    //case 8:  kd2=Ddata;break;
    //case 9:  kd3=Ddata;break;
    //case 10:  kd4=Ddata;break;
    //case 11:  kd5=Ddata;break;
    //case 12:  kd6=Ddata;break;
    //case 13:  jiuzheng=Ddata;break;
    //case 14:  null=Ddata;break;
    //case 15:  null=Ddata;break;
    default : break;
    }
    
  }
  identityset++;
}

void sendblue(int a,int b)
{
  char sendbluedata[2];
  
  sendbluedata[0]=a*16+b/256;
  
  sendbluedata[1]=b%256;  
  LPLD_UART_PutCharArr(UART4,(char*)sendbluedata,2);
}

*/
void do_control(void)
{
	switch (routechoice) {
	case C_AHEAD:
		do_goahead();		break;
	case C_GETCORNER:
		do_getcorner();		break;
	case C_LEFT:
		do_turnleft();		break;
	case C_RIGHT:
		do_turnright();		break;
	case C_STOP:
		do_stop();			break;
	case C_AROUND:
		do_turnaround();	break;
	case C_BREAK:
		do_break();			break;
	case C_START:
		do_start(); 		break;
	case C_LETSWIN:
		do_letswin(); 		break;
	default:
		do_stop();
  }
}
Ejemplo n.º 2
0
void do_control()
{
         
	switch(control_action)
	{
        case TURN_LEFT:
			do_turn_left();
            break;
		case TURN_RIGHT:
			do_turn_right();
            break;
		case TURN_BACK:
			do_turn_back();
            break;
		case GO_AHEAD:
			do_go_ahead();
            break;
        case STOP:
			do_stop();
            break;
		case GET_CROSS:
			do_get_cross();
                        break;
		default:
			do_stop();
            break;
	}
	
	#ifdef STOP_DEBUG
	car_set_left_speed(0);
	car_set_right_speed(0);
	#endif
}
Ejemplo n.º 3
0
// Prepare deck to go into 'READY' state
void do_cue(float cuepoint)
{
	if (verbose) printf("-> do_cue(%f)\n", cuepoint);

	// Stop first
	if (get_state() == MADJACK_STATE_PLAYING ||
	    get_state() == MADJACK_STATE_PAUSED)
	{
		do_stop();
	}
	
	// Had cue-point changed?
	if (get_state() == MADJACK_STATE_READY &&
	    input_file->position != cuepoint)
	{
		if (verbose) printf("Stopping because cuepoint changed.\n");
		do_stop();
	}
	
	// Start the new thread
	if (get_state() == MADJACK_STATE_LOADING ||
	    get_state() == MADJACK_STATE_STOPPED )
	{

		// Set the decoder running
		start_decoder_thread( input_file, cuepoint );
		
	}
	else if (get_state() != MADJACK_STATE_READY)
	{
		fprintf(stderr, "Warning: Can't change from %s to state READY.\n", get_state_name(get_state()) );
	}

}
Ejemplo n.º 4
0
void test_syscall(int syscall) {

	//clear_log();
	do_intercept(syscall, 0);
	do_as_guest("./test_full nonroot %d", syscall, 0);
	do_start(syscall, -2, -EINVAL);
	do_start(syscall, 0, 0);
	do_stop(syscall, 0, 0);
	do_start(syscall, 1, 0);
	do_as_guest("./test_full stop %d 1 %d", syscall, -EPERM);
	do_stop(syscall, 1, 0);
	do_as_guest("./test_full start %d -1 %d", syscall, 0);
	do_stop(syscall, last_child, -EINVAL);
	do_release(syscall, 0);

	puts("----- START OF test_PASS -----");
	test_PASS(syscall);
	puts("----- END OF test_PASS -----");
	puts("----- START OF test_A -----");
	test_A(syscall);
	puts("----- END OF test_A -----");
	puts("----- START OF test_B -----");
	test_B(syscall, TRUE);
	puts("----- END OF test_B -----");
	puts("----- START OF test_CDE ----");
	test_CDE(syscall);
	puts("----- END OF test_CDE ----");
}
Ejemplo n.º 5
0
static int
flush_data(ProfilerObject *self)
{
    /* Need to dump data to the log file... */
    size_t written = fwrite(self->buffer, 1, self->index, self->logfp);
    if (written == (size_t)self->index)
        self->index = 0;
    else {
        memmove(self->buffer, &self->buffer[written],
                self->index - written);
        self->index -= written;
        if (written == 0) {
            char *s = PyString_AsString(self->logfilename);
            PyErr_SetFromErrnoWithFilename(PyExc_IOError, s);
            do_stop(self);
            return -1;
        }
    }
    if (written > 0) {
        if (fflush(self->logfp)) {
            char *s = PyString_AsString(self->logfilename);
            PyErr_SetFromErrnoWithFilename(PyExc_IOError, s);
            do_stop(self);
            return -1;
        }
    }
    return 0;
}
Ejemplo n.º 6
0
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
        switch (Msg) {
	case WM_USER:
		switch (lParam) {
		case WM_LBUTTONDBLCLK:
			ShowWindow(hWndDlg, SW_SHOW);
			return TRUE;
		}
		break;
		
	case WM_TERM:
		do_stop(hWndDlg);
		break;

	case WM_INITDIALOG:
		_hwnd = hWndDlg;
		do_init();
		do_stop(_hwnd);

		start_stop(hWndDlg); /* didn't we say on by default? ;D */
		break;

	case WM_SYSCOMMAND:
		if ((wParam & 0xfff0) == SC_MINIMIZE) {
			minimize(hWndDlg);
			return TRUE;
		}
		break;

        case WM_CLOSE:
		minimize(hWndDlg);
                return TRUE;

        case WM_COMMAND:
                switch(wParam) {
		case IDOK:
			start_stop(hWndDlg);
			return TRUE;
		case IDCANCEL:
			netstat();
			return TRUE;

		case IDC_BUTTON1:
			EndDialog(hWndDlg, 0);
			return TRUE;

		case IDC_BUTTON2:
			hof();
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Ejemplo n.º 7
0
int do_nonroot(int syscall) {
	do_intercept(syscall, -EPERM);
	do_release(syscall, -EPERM);
	do_start(syscall, 0, -EPERM);
	do_stop(syscall, 0, -EPERM);
	do_start(syscall, 1, -EPERM);
	do_stop(syscall, 1, -EPERM);
	do_start(syscall, getpid(), 0);
	do_start(syscall, getpid(), -EBUSY);
	do_monitor(syscall);
	do_stop(syscall, getpid(), 0);
	do_stop(syscall, getpid(), -EINVAL);
	return 0;
}
Ejemplo n.º 8
0
static void moving(Info * info) {
    if (checkDone()) {
        mylogfd(SCHFD, "[sche]checkDone moving\n");
		info->state = FACE_DOOR;
		return;
	}
	if (!IsBallCatch(info)) {
		do_stop(info);
		info->state = SEARCH_BALL;
		return;
	}
    mylogfd(SCHFD,"MOVING");
    /*static int step = 0;
    if (step == 1 && checkDone()) {
        step = 0;
        info->state = BALL_CATCHED;
        do_rota_with_ball(info, 360, 1);
        return;    
    }    
    if (step == 0 && checkDone()) {
        step = 1;
        info->destP.y = 70;
        info->destP.x = 0;  
        do_catch_ball(info);
        return;
    }*/
}
Ejemplo n.º 9
0
static
int stop_handler(const char *path, const char *types, lo_arg **argv, int argc,
		 lo_message msg, void *user_data)
{
	do_stop();
    return 0;
}
Ejemplo n.º 10
0
/*
 * This is an in-fix recursive function called before s is started to
 * stop every service that depends on s, in reverse order *or* after s
 * was started to start again every service that depends on s. The
 * action parametere controls if this function should start or stop
 * the procceses that depends on s.
 * @param s A Service_T object
 * @param action An action to do on the dependant services
 */
static void do_depend(Service_T s, const char *action) {

  Service_T child;
  
  ASSERT(s);

  for(child= servicelist; child; child= child->next) {
    
    if(child->dependantlist) {

      Dependant_T d;
    
      for(d= child->dependantlist; d; d= d->next) {

	if(IS(d->dependant, s->name)) {
	
	  if(IS(action, "start"))
	    do_start(child);
          else if(IS(action, "monitor"))
	    do_monitor(child);
	
	  do_depend(child, action);
	
	  if(IS(action, "stop"))
	    do_stop(child);
          else if(IS(action, "unmonitor"))
	    do_unmonitor(child);

	  break;

	}
      }
    }
  }
}
Ejemplo n.º 11
0
void pit_isr0() //电机控制5ms
{  
  //读脉冲
	pulsecount = LPLD_LPTMR_GetPulseAcc();
	pulseaccu += pulsecount;
  //pulsetotal+=pulsecount;
	LPLD_LPTMR_Reset();       
	LPLD_LPTMR_Init(MODE_PLACC, 0, LPTMR_ALT1, IRQ_DISABLE, NULL);
  
  
  //分析
  //  analyse();
  //控制
	scan_infrared(r1, r2, r3, r4);
  //fisrthongwaierror();
  //secondhongwaierror();//边沿跳变获得误差
	calculate_infrared_error(r1, INFRARED_LINE1_NUM, &r1_error);
	calculate_infrared_error(r2, INFRARED_LINE2_NUM, &r2_error);
  
	if (is_enabled) do_control();
	else do_stop();
  
	static int __scan_infront_counter = 0;
	
	if (__adc > SCAN_INFRONT_THRESHOLE_SMALL 
		&& abs(r1_error - r2_error) < 2) __scan_infront_counter ++;
	else {
		__scan_infront_counter = 0;
	}
	is_car_infront = __scan_infront_counter > 5;
}
Ejemplo n.º 12
0
Archivo: control.c Proyecto: hafiz/yoke
/*
 * This is an in-fix recursive function called before s is started to
 * stop every service that depends on s, in reverse order *or* after s
 * was started to start again every service that depends on s. The
 * action parametere controls if this function should start or stop
 * the procceses that depends on s.
 * @param s A Service_T object
 * @param action An action to do on the dependant services
 */
static void do_depend(Service_T s, int action) {
  Service_T child;
  
  ASSERT(s);

  for (child = servicelist; child; child = child->next) {
    if (child->dependantlist) {
      Dependant_T d;
    
      for (d = child->dependantlist; d; d = d->next) {
	if (IS(d->dependant, s->name)) {
	  if (action == ACTION_START)
	    do_start(child);
          else if (action == ACTION_MONITOR)
	    do_monitor(child);
	  do_depend(child, action);
	  if (action == ACTION_STOP)
	    do_stop(child);
          else if (action == ACTION_UNMONITOR)
	    do_unmonitor(child);
	  break;
	}
      }
    }
  }
}
Ejemplo n.º 13
0
void test_syscall(int syscall) {

	//clear_log();
	do_intercept(syscall, 0);
	do_intercept(syscall, -EBUSY);
	do_as_guest("./test_full nonroot %d", syscall, 0);
	do_start(syscall, -2, -EINVAL);
	do_start(syscall, 0, 0);
	do_stop(syscall, 0, 0);
	do_start(syscall, 1, 0);
	do_as_guest("./test_full stop %d 1 %d", syscall, -EPERM);
	do_stop(syscall, 1, 0);
	do_as_guest("./test_full start %d -1 %d", syscall, 0);
	do_stop(syscall, last_child, -EINVAL);
	do_release(syscall, 0);
}
void
gtk_gui::do_load_settings() {
	if (m_mainloop && m_mainloop->is_open())
		do_stop();

	m_settings_chooser = GTK_FILE_CHOOSER (gtk_file_chooser_dialog_new(gettext("Please, select a settings file"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN,"Cancel", GTK_RESPONSE_CANCEL, "Open", GTK_RESPONSE_ACCEPT, NULL));

	GtkFileFilter *filter_xml = gtk_file_filter_new();
	gtk_file_filter_set_name(filter_xml, gettext("XML files"));
	gtk_file_filter_add_pattern(filter_xml, "*.xml");
	gtk_file_chooser_add_filter(m_settings_chooser, filter_xml);

	gint result = gtk_dialog_run (GTK_DIALOG (m_settings_chooser));
	if (result == GTK_RESPONSE_ACCEPT) {
		do_settings_selected();
	}
	gtk_widget_hide(GTK_WIDGET (m_settings_chooser));

	/* Ensure that the dialog box is hidden when the user clicks a button.
	We don't need anymore the callbacks, because they can be embedded in this part of the code */
/*
	g_signal_connect_swapped (GTK_FILE_SELECTION (m_settings_selector)->ok_button,
		"clicked",
		G_CALLBACK (gtk_widget_hide),
		m_settings_selector);

	g_signal_connect_swapped (GTK_FILE_SELECTION (m_settings_selector)->cancel_button,
		"clicked",
		G_CALLBACK (gtk_widget_hide),
		m_settings_selector);
	g_signal_connect_swapped (G_OBJECT ((m_settings_selector)->ok_button),"clicked", G_CALLBACK (gtk_C_callback_settings_selected),(void*) this);
*/
}
Ejemplo n.º 15
0
RIOTRtnE RServerCSLtr_Stop(RServerCSLtr * csLtr) {

	RC_ASSERT(csLtr);

	do_stop(csLtr);

	return RC_SUCCESS;
}
int
start_stop_daemon_main(int argc, char **argv)
{
	unsigned long opt;
	char *signame = NULL;
	char *startas = NULL;

	bb_applet_long_options = ssd_long_options;

	bb_opt_complementaly = "K~S:S~K";
	opt = bb_getopt_ulflags(argc, argv, "KSba:n:s:u:x:", 
			&startas, &cmdname, &signame, &userspec, &execname);

	/* Check one and only one context option was given */
	if ((opt & 0x80000000UL) || (opt & (SSD_CTX_STOP | SSD_CTX_START)) == 0) {
		bb_show_usage();
	}

	if (signame) {
		signal_nr = bb_xgetlarg(signame, 10, 0, NSIG);
	}

	if (!execname && !userspec)
		bb_error_msg_and_die ("need at least one of -x or -u");

	if (!startas)
		startas = execname;

	if ((opt & SSD_CTX_START) && !startas)
		bb_error_msg_and_die ("-S needs -x or -a");

	argc -= optind;
	argv += optind;

	if (userspec && sscanf(userspec, "%d", &user_id) != 1)
		user_id = my_getpwnam(userspec);

	do_procfs();

	if (opt & SSD_CTX_STOP) {
		do_stop();
		return EXIT_SUCCESS;
	}

	if (found) {
		printf("%s already running.\n%d\n", execname ,found->pid);
		return EXIT_SUCCESS;
	}
	*--argv = startas;
	if (opt & SSD_OPT_BACKGROUND) {
		if (daemon(0, 0) == -1)
			bb_perror_msg_and_die ("unable to fork");
	}
	setsid();
	execv(startas, argv);
	bb_perror_msg_and_die ("unable to start %s", startas);
}
Ejemplo n.º 17
0
int
start_stop_daemon_main(int argc, char **argv)
{
	int flags;
	char *signame = NULL;
	bb_applet_long_options = ssd_long_options;

	flags = bb_getopt_ulflags(argc, argv, "KSba:n:s:u:x:", 
			&startas, &cmdname, &signame, &userspec, &execname);

	/* Be sneaky and avoid branching */
	stop = (flags & 1);
	start = (flags & 2);
	fork_before_exec = (flags & 4);

	if (signame) {
		signal_nr = bb_xgetlarg(signame, 10, 0, NSIG);
	}

	if (start == stop)
		bb_error_msg_and_die ("need exactly one of -S or -K");

	if (!execname && !userspec)
		bb_error_msg_and_die ("need at least one of -x or -u");

	if (!startas)
		startas = execname;

	if (start && !startas)
		bb_error_msg_and_die ("-S needs -x or -a");

	argc -= optind;
	argv += optind;

	if (userspec && sscanf(userspec, "%d", &user_id) != 1)
		user_id = my_getpwnam(userspec);

	do_procfs();

	if (stop) {
		do_stop();
		return EXIT_SUCCESS;
	}

	if (found) {
		printf("%s already running.\n%d\n", execname ,found->pid);
		return EXIT_SUCCESS;
	}
	*--argv = startas;
	if (fork_before_exec) {
		if (daemon(0, 0) == -1)
			bb_perror_msg_and_die ("unable to fork");
	}
	setsid();
	execv(startas, argv);
	bb_perror_msg_and_die ("unable to start %s", startas);
}
Ejemplo n.º 18
0
static void sighandler(int signum)
{
	switch (signum) {
	case SIGINT:
	case SIGTERM:
		do_stop();
		break;
	}
}
Ejemplo n.º 19
0
/* note this test is run after all processes have been intercepted*/
int do_nonroot(int syscall) {
	do_intercept(syscall, -EPERM);
	do_release(syscall, -EPERM);
	do_start(syscall, 0, -EPERM);
	do_stop(syscall, 0, -EPERM);
	do_start(syscall, 1, -EPERM);
	do_stop(syscall, 1, -EPERM);
	do_start(syscall, getpid(), 0);
	do_start(syscall, getpid(), -EBUSY);
	test_monitor(syscall, TRUE);
	do_stop(syscall, getpid(), 0);
	do_stop(syscall, getpid(), -EINVAL);

	puts("----- START OF test_B -----");
	test_B(syscall, FALSE);
	puts("----- END OF test_B -----");

	return 0;
}
Ejemplo n.º 20
0
void test_B(int syscall, int iamroot) {
#define subtestroot(s) printf((s" as %s\n"), (iamroot)?"root":"nonroot")

	subtestroot("EPERM: intercept");
	do_intercept(syscall, iamroot ? 0 : -EPERM);
	subtestroot("EPERM: monitor self");
	do_start(syscall, -1, 0);
	do_stop(syscall, -1, 0);
	subtestroot("EPERM: monitor all processes");
	do_start(syscall, 0, iamroot ? 0 : -EPERM);
	do_stop(syscall, 0, iamroot ? 0 : -EPERM);
	subtestroot("EPERM: monitor init process");
	do_start(syscall, 1, iamroot ? 0 : -EPERM);
	do_stop(syscall, 1, iamroot ? 0 : -EPERM);
	subtestroot("EPERM: release");
	do_release(syscall, iamroot ? 0 : -EPERM);

#undef subtestroot
}
Ejemplo n.º 21
0
static void forwarding_ball(Info * info) {
        if (IsRight(info)) info->sched_var.search_dir = -2;
        if (IsLeft(info)) info->sched_var.search_dir = 2;
        if (IsBallCatch(info))   {
            mylogfd(SCHFD, "[sche]forwarding_ball->ball_catched\n");
            info->last_cmd = CMD_STOP; 
            info->state = BALL_CATCHED;
            info->sched_var.doorseen = 0;        
            do_stop(info);            //  delet // -- redwalker
            if (!IsDoorSeen(info)) do_rota_with_ball(info, POSITI*360, 1);
           return;
        }
        if (!IsBallSeen(info)) {  
            mylogfd(SCHFD, "[sche]forwarding_ball->stop when lose ball\n");
            info->state = SEARCH_BALL;
            do_stop(info);
            return;
        }
       /* else if (IsBallVeryNear(info))
        {
            mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n");
            info->state = CATCHING_BALL;
            info->destP.x = gety(info);
            iinfo->destP.y = -getx(info);
            do_catch_ball(info);
        }*/
        if (IsMiddle(info)) {
            do_adjust(-1);
        }
        if (IsLeft(info)) {
            do_adjust(1);
        }
        if (IsRight(info)) {
            do_adjust(0);
        }
        if (checkDone ()) {
            mylogfd(SCHFD, "[sche]checkDone forwarding_ball\n");
            info->state = SEARCH_BALL;
            mylogfd(SCHFD, "[sche]forwarding_ball->SEARCH_BALL\n");
            return;
        }         
}
Ejemplo n.º 22
0
RIOTRtnE RServer_Stop() {

	RC_LOG_I("RServer was preparing to stop.");

	do_stop(gRServerCtx);
	do_status_change(gRServerCtx, RC_STATUS_STOPPED);

	RC_LOG_I("RServer was stopped.");

	return RC_SUCCESS;
}
Ejemplo n.º 23
0
int dispatch_cmd(otts_synth_plugin_t *synth, char *cmd_line)
{
	char *cmd = NULL;
	size_t cmd_len;
	char *msg = NULL;

	cmd_len = strcspn(cmd_line, " \t\n\r\f");
	cmd = g_strndup(cmd_line, cmd_len);
	pthread_mutex_lock(&module_stdout_mutex);

	if (!strcasecmp("audio", cmd)) {
		msg = do_audio(synth);
	} else if (!strcasecmp("set", cmd)) {
		msg = do_set(synth);
	} else if (!strcasecmp("speak", cmd)) {
		msg = do_speak(synth);
	} else if (!strcasecmp("key", cmd)) {
		msg = do_key(synth);
	} else if (!strcasecmp("sound_icon", cmd)) {
		msg = do_sound_icon(synth);
	} else if (!strcasecmp("char", cmd)) {
		msg = do_char(synth);
	} else if (!strcasecmp("pause", cmd)) {
		do_pause(synth);
	} else if (!strcasecmp("stop", cmd)) {
		do_stop(synth);
	} else if (!strcasecmp("list_voices", cmd)) {
		msg = do_list_voices(synth);
	} else if (!strcasecmp("loglevel", cmd)) {
		msg = do_loglevel(synth);
	} else if (!strcasecmp("debug", cmd)) {
		msg = do_debug(synth, cmd_line);
	} else if (!strcasecmp("quit", cmd)) {
		do_quit(synth);
	} else {
/*should we log?*/
		printf("300 ERR UNKNOWN COMMAND\n");
		fflush(stdout);
	}

	if (msg != NULL) {
		if (0 > printf("%s\n", msg)) {
			log_msg(OTTS_LOG_CRIT, "Broken pipe, exiting...\n");
			synth->close(2);
		}
		fflush(stdout);
		g_free(msg);
	}

	pthread_mutex_unlock(&module_stdout_mutex);
	g_free(cmd);

	return (0);
}
Ejemplo n.º 24
0
int do_reset_stop(int argc, param *argv) {
    swdp_core_halt();
    // enable vector-trap on reset, enable DWT/FPB
    swdp_ahb_write(DEMCR, DEMCR_VC_CORERESET | DEMCR_TRCENA | vcflags);
    // core reset and sys reset
    swdp_ahb_write(0xe000ed0c, 0x05fa0005);
    //swdp_core_wait_for_halt();
    do_stop(0,0);
    swdp_ahb_write(DEMCR, DEMCR_TRCENA | vcflags);
    return 0;
}
Ejemplo n.º 25
0
static void finding_dir(Info * info) {
//mylogfd(SCHFD, "[sche]finding_dir:%d %d\n", IsEdgeValid(info), getEdgeX(info));
    if (IsEdgeValid(info) && (!IsOutSide(info) || getEdgeX(info) > 100)) {
        info->destP.x = 50 + Random(200);
        if (info->destP.x > getEdgeX(info) - 10) info->destP.x = getEdgeX(info) - 10;
        info->destP.y = 0; 
        info->state = CHANGING_PLACE; 
        do_stop(info);      
        do_forward(info, MAX_A);
        mylogfd(SCHFD, "[sche]finding_dir->changing_place");
    }
}
Ejemplo n.º 26
0
static void protect_door(Info * info) {
       static int angle = 180;
       if (IsBallSeen(info)) {
          do_stop(info);
       
          
       }
       if (checkDone()) {
          do_rota(info, angle, 1);
          angle = -angle;          
       }
}
Ejemplo n.º 27
0
int PulleyDispatcher::exec(const std::string& verb, const Values& values, Object& response)
{
	if (verb == "connect") return do_connect(values, response);
	else if (verb == "stop") return do_stop(values);
	else if (verb == "serverinfo") return do_serverinfo(values, response);
	else if (verb == "follow") return do_follow(values, response);
	else if (verb == "unfollow") return do_unfollow(values, response);
	else if (verb == "dump_dit") return do_dump_dit(values, response);
	else if (verb == "resync") return do_resync(values, response);
	else if (verb == "script") return do_script(values, response);
	return -1;
}
Ejemplo n.º 28
0
static void catching_ball(Info* info) {
        if (IsBallCatch(info)) {
            mylogfd(SCHFD, "[sche]State changing:catching_ball->ball_catched\n"); 
            info->state = BALL_CATCHED;
            info->sched_var.doorseen = 0;
            info->sched_var.waitlost = 3;       
            do_stop(info);
            if (!IsDoorSeen(info)) do_rota_with_ball(info, -POSITI*360, 1);    // get in a paramiter -- redwalker

        }
        else if (!IsBallAllSeen(info)) {
             mylogfd(SCHFD, "[sche]catching_ball->SEARCH_BALL\n");
             info->state = SEARCH_BALL;
             do_stop(info);
        }
        else if (!IsBallVeryNear(info))
        {
            mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n");
            info->state = FORWARDING_BALL;
            info->destP.x = gety(info);
            info->destP.y = - getx(info);
            do_forward(info, DEFAULT_A);
        }
        else if (checkDone()) {
            mylogfd(SCHFD,"[sche]checkDone catching_ball \n");
            info->last_cmd = CMD_CATCH_BALL;
            info->destP.x = gety(info);
            info->destP.y = - getx(info); 
            do_catch_ball(info);
        }
        if (IsMiddle(info)) {
            do_adjust(-1);
        }
        if (IsLeft(info)) {
            do_adjust(1);
        }
        if (IsRight(info)) {
            do_adjust(0);
        }
}
Ejemplo n.º 29
0
void test_A(int syscall) {
	// test negative syscall number
	do_intercept(-1, -EINVAL);
	do_release(-1, -EINVAL);
	do_start(-1, -1, -EINVAL);
	do_stop(-1, -1, -EINVAL);
	// test the last syscall
	do_intercept(MAX_SYSCALLS - 1, 0);
	do_start(MAX_SYSCALLS - 1, -1, 0);
	do_stop(MAX_SYSCALLS - 1, -1, 0);
	do_release(MAX_SYSCALLS - 1, 0);
	// test greater than NR_syscalls
	do_intercept(MAX_SYSCALLS, -EINVAL);
	do_release(MAX_SYSCALLS, -EINVAL);
	do_start(MAX_SYSCALLS, -1, -EINVAL);
	do_stop(MAX_SYSCALLS, -1, -EINVAL);
	do_intercept(MAX_SYSCALLS + 1, -EINVAL);
	do_release(MAX_SYSCALLS + 1, -EINVAL);
	do_start(MAX_SYSCALLS + 1, -1, -EINVAL);
	do_stop(MAX_SYSCALLS + 1, -1, -EINVAL);
	// test MY_CUSTOM_SYSCALL
	do_intercept(MY_CUSTOM_SYSCALL, -EINVAL);
	do_release(MY_CUSTOM_SYSCALL, -EINVAL);
	do_start(MY_CUSTOM_SYSCALL, -1, -EINVAL);
	do_stop(MY_CUSTOM_SYSCALL, -1, -EINVAL);

	// test on pids
	do_intercept(syscall, 0);
	do_start(syscall, -2, -EINVAL);
	do_stop(syscall, -2, -EINVAL);
	do_release(syscall, 0);
}
Ejemplo n.º 30
0
static
void read_keypress()
{
	// Get keypress
	int c = fgetc( stdin );

	// Ignore EOF (e.g. when stdin is /dev/null)
	if (c == EOF) return;

	switch(c) {
	
		// Pause/Play
		case 'p': 
			if (get_state() == MADJACK_STATE_PLAYING) {
				do_pause();
			} else {
				do_play();
			}
		break;
		
		// Load
		case 'l': {
			char* filepath = read_filepath();
			do_load( filepath );
			free( filepath );
			break;
		}

		case 'e': do_eject(); break;
		case 's': do_stop(); break;
		case 'q': do_quit(); break;
		case 'c': do_cue(0.0f); break;

		case 'C': {
			float cuepoint = read_cuepoint();
			do_cue( cuepoint );
			break;
		}
		
		default:
			printf( "Unknown command '%c'.\n", (char)c );
		case 'h':
		case '?':
			display_keyhelp();
		break;
		
		// Ignore return and enter
		case 13:
		case 10:
		break;
	}
}