Ejemplo n.º 1
0
int taskResponseTest(void)
{
	struct sigaction newAction;
	//init signal
	newAction.sa_handler = Action;		//set the new handler
	sigemptyset(&newAction.sa_mask);	//no other signals blocked
	newAction.sa_flags = 0;	//no special options

	if(sigaction(SIGINT, &newAction, NULL) == -1)
		printf("Could not install signal handler\n");

	//init semaphore
	semMutex = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
	

	//create task A and B
	if((taskRTA = taskCreate("taskRTA", 100, NULL, STACK_SIZE, (FUNCPTR)TaskRTA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == NULL)
		printf("Could not create task A\n");
	if((taskRTB = taskCreate("taskRTB", 99, NULL, STACK_SIZE, (FUNCPTR)TaskRTB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == NULL )
		printf("Could not create task B\n");
	
	taskRTMaster = taskIdSelf();
	
	//resume task B
	taskResume(taskRTB);
	//resume task A
	taskResume(taskRTA);

	printf("It is task response test.\n");
	return 0;
}
Ejemplo n.º 2
0
int repriseConditionnement() {

	// On reprends l'exécution des deux tâches :
	taskResume(tidTraitementCarton);
	taskResume(tidTraitementPalette);

	semTake(semClapet, WAIT_FOREVER);
	clapet = OUVERT;
	semGive(semClapet);

	message(CLAPET_OUVERT, NULL, NULL, NULL);

	return OK;
}
Ejemplo n.º 3
0
/*
 * Runs the user operator control code. This function will be started in its own task with the
 * default priority and stack size whenever the robot is enabled via the Field Management System
 * or the VEX Competition Switch in the operator control mode. If the robot is disabled or
 * communications is lost, the operator control task will be stopped by the kernel. Re-enabling
 * the robot will restart the task, not resume it from where it left off.
 *
 * If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
 * run the operator control task. Be warned that this will also occur if the VEX Cortex is
 * tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
 *
 * Code running in this task can take almost any action, as the VEX Joystick is available and
 * the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
 * recommended to give other tasks (including system tasks such as updating LCDs) time to run.
 *
 * This task should never exit; it should end with some kind of infinite loop, even if empty.
 */
void operatorControl() {
	taskResume(velocityReader_task);
	printf("velocity Resumed\n\r");
	taskResume(getJoysticks_task);
	printf("joysticks Resumed\n\r");
	taskResume(powerListener_task);
	printf("powerListener Resumed\n\r");
	taskResume(flywheelVelocityControl_task);
	printf("flywheel Resumed\n\r");
	taskResume(driveControl_task);
	while (1) {
		delay(20);
	}
}
Ejemplo n.º 4
0
void sem2Task  (long a0, long a1, long a2, long a3, long a4,
		long a5, long a6, long a7, long a8, long a9)
{
    WIND_TCB *pTcb = taskTcb(taskIdSelf());
    ULONG date;
    int n;

    TEST_ASSERT(pTcb != NULL);

    TEST_ASSERT(taskNameToId("Test2") == (TASK_ID)pTcb);

    TEST_MARK();

    TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(taskResume(a0));

    TEST_MARK();
    date = tickGet();
    for (n = 0; n < 1000000; n++) {
	    ULONG old_date = date;
	    date = tickGet();
	    if (date != old_date)
		    TEST_MARK();
    }

    TEST_MARK(); /* Should not pass this mark */
}
Ejemplo n.º 5
0
/*
 * Runs the user operator control code. This function will be started in its own task with the
 * default priority and stack size whenever the robot is enabled via the Field Management System
 * or the VEX Competition Switch in the operator control mode. If the robot is disabled or
 * communications is lost, the operator control task will be stopped by the kernel. Re-enabling
 * the robot will restart the task, not resume it from where it left off.
 *
 * If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
 * run the operator control task. Be warned that this will also occur if the VEX Cortex is
 * tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
 *
 * Code running in this task can take almost any action, as the VEX Joystick is available and
 * the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
 * recommended to give other tasks (including system tasks such as updating LCDs) time to run.
 *
 * This task should never exit; it should end with some kind of infinite loop, even if empty.
 */
void operatorControl() {
	bool *lcdBacklight = initLcdVals();
	taskResume(catTask);
	while (1) {
		// Joystick control of drive
		checkDrive();

		// Tower and intake control (Y-cabled into ports 3 and 8)
		setTowerAndIntake();

		// Manual catapult control
		setCatapultMotors();

		// Perform battery checks and update LCD
		showBatteryOnLcd(uart1 );

		// Show potentiometer values on second LCD
		showPotVals(uart2, 1);

		// Toggle backlight using buttons
		bool newBacklight = checkBacklight(uart1, lcdBacklight[0]);
		bool newSecondBacklight = checkBacklight(uart2, lcdBacklight[1]);
		lcdBacklight[0] = newBacklight;
		lcdBacklight[1] = newSecondBacklight;

		// Delay 20 ms to concede to other tasks
		delay(20);
	}

}
Ejemplo n.º 6
0
int BeagleBone::SendData(char *p) {
	if (!Connected())
		return 0;
	taskSuspend(tid);
	int writ= write(connsock, p, strlen(p));
	taskResume(tid);
	return writ;
}
Ejemplo n.º 7
0
static int __wind_task_resume(struct pt_regs *regs)
{
	WIND_TCB *pTcb = __wind_lookup_task(__xn_reg_arg1(regs));

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	if (taskResume((TASK_ID) pTcb) == ERROR)
		return wind_errnoget();

	return 0;
}
Ejemplo n.º 8
0
static int __wind_task_resume(struct task_struct *curr, struct pt_regs *regs)
{
	WIND_TCB *pTcb = (WIND_TCB *)xnregistry_fetch(__xn_reg_arg1(regs));

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	if (taskResume((TASK_ID) pTcb) == ERROR)
		return wind_errnoget();

	return 0;
}
Ejemplo n.º 9
0
static INT32 wpiStackTask(INT32 taskId)
{
	taskDelay(1);
	//tt(taskId);

	REG_SET regs;
	taskRegsGet(taskId, &regs);
	trcStack(&regs, (FUNCPTR) wpiCleanTracePrint, taskId);

	// The task should be resumed because it had to be suspended to get the stack trace.
	taskResume(taskId);
	return 0;
}
Ejemplo n.º 10
0
void autonomous() {
	taskResume(velocity_task);
	taskResume(leftFlywheel_task);
	taskResume(rightFlywheel_task);
	leftFlywheel.variables.power =29.5;
	rightFlywheel.variables.power =29.5;
	rightFlywheel.variables.powerRaw = ((rightFlywheel.variables.power)/3.0)*(12/FLYWHEEL_CIRCUMFERENCE)*360;
	leftFlywheel.variables.powerRaw = ((leftFlywheel.variables.power)/3.0)*(12/FLYWHEEL_CIRCUMFERENCE)*360;
	delay(5000);
	motorSet(INTAKE,127);
	motorSet(INTAKE,-127);
	delay(8000);
	taskSuspend(velocity_task);
	taskSuspend(leftFlywheel_task);
	taskSuspend(rightFlywheel_task);
	leftFlywheel.variables.power =0;
	rightFlywheel.variables.power =0;
	rightFlywheel.variables.powerRaw =0;
	leftFlywheel.variables.powerRaw = 0;


}
Ejemplo n.º 11
0
/*
 * Runs the user operator control code. This function will be started in its own task with the
 * default priority and stack size whenever the robot is enabled via the Field Management System
 * or the VEX Competition Switch in the operator control mode. If the robot is disabled or
 * communications is lost, the operator control task will be stopped by the kernel. Re-enabling
 * the robot will restart the task, not resume it from where it left off.
 *
 * If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
 * run the operator control task. Be warned that this will also occur if the VEX Cortex is
 * tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
 *
 * Code running in this task can take almost any action, as the VEX Joystick is available and
 * the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
 * recommended to give other tasks (including system tasks such as updating LCDs) time to run.
 *
 * This task should never exit; it should end with some kind of infinite loop, even if empty.
 */
void operatorControl() {
	twoJoysticks = isJoystickConnected(2);//check for second joystick
	taskResume(leftFlywheel_task);
	taskResume(shooter_task);
	taskResume(velocity_task);
	taskResume(powerListener_task);
	taskResume(joystick_task);
	taskResume(drive_task);
	while (1) {
		delay(20);
	}
}
Ejemplo n.º 12
0
static void peerTask(long a0, long a1, long a2, long a3, long a4,
		     long a5, long a6, long a7, long a8, long a9)
{
	TASK_ID rtid;
	int ret;

	traceobj_enter(&trobj);

	traceobj_mark(&trobj, 1);

	rtid = taskNameToId("rootTask");
	traceobj_assert(&trobj, rtid != ERROR);

	traceobj_mark(&trobj, 2);

	ret = semTake(sem_id, NO_WAIT);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_UNAVAILABLE);

	traceobj_mark(&trobj, 3);

	ret = semTake(sem_id, 100);
	traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_TIMEOUT);

	traceobj_mark(&trobj, 4);

	ret = taskResume(rtid);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 5);

	ret = semTake(sem_id, WAIT_FOREVER);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 6);

	traceobj_exit(&trobj);
}
Ejemplo n.º 13
0
static void
reset2SafeState( int why )  /* argument is the type of exception */
{
   int pTmpId, TmpPrior;
   int tuneactive = 0;

   DPRINT(1,"reset2SafeState");
   DPRINT(1,"stopAPint");
   pcsAbortSort();     /* parallel channel sort to stop and return to APint() */
   abortAPint();   /* like stopAPint() but also cause the Parser to suspend itself */
   /* stopAPint(); */
   DPRINT(1,"stop downLinker");
   setDwnLkAbort();   /* like stop downLinker and set to dump further download to bit bucket */
   DPRINT(1,"reset2SafeState");
   DPRINT(0,"fifoSetNoStuff\n");
   fifoSetNoStuff(pTheFifoObject);    /* stop the stuffer in it's tracks */
   DPRINT(0,"Disable STM Intrps");
   stmItrpDisable(pTheStmObject, STM_ALLITRPS);
   /* reset fifo Object not to use parallel channels */
   fifoClearPChanId(pTheFifoObject);
   DPRINT(0,"fifoReset");

   /* Keep the MTS gradient amp disabled whenever possible! */
   gpaTuneSet(pTheAutoObject, SET_GPAENABLE, GPA_DISABLE_DELAY);

   /* if an interactive abort do not reset the apbus, thus preventing the 
      all amplifier from going to Pulse Mode, thus amps that are in CW 
      will stay that way. This is/was a lockdisplay/shimming issue.
      Where exiting lock display set all the amps to Pulse Mode or blanked!, 
      then one shimmed and obtain a certain lock level. After su command 
      then amps would go back to CW thus injecting noise and lowing the
      lock level, If use wht directly to shimming they could neer re-attain 
      the lock level they had before.  But when enter and exit lock display 
      the level would jump back up. Thus causing no end of
      confusion....
      Thus for INTERACTIVE_ABORT the reset apbus bit is left out when reseting the FIFO.

      Oooops, but wait, we found an exception (of course), when exiting qtune the 
      reset of the apbus reset all the tune relays back to noraml, now of course 
      this does not happen thus leaving the console in tuning mode. Thus we added the 
      following test isTuneActive() and if it is then a full reset including the apbus
      is done.
   */
   tuneactive = isTuneActive();
   /* DPRINT1(-3,"Is Tune active: %d\n",tuneactive); */
   if ((why != INTERACTIVE_ABORT) || (tuneactive == 1))
      fifoReset(pTheFifoObject, RESETFIFOBRD);  /* this now also clear the Fifo Buffer & restart the Stuffer */
   else
      fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */

   /* set initial value of parallel channel free buffer pointer to null */
   clearParallelFreeBufs();

   DPRINT(0,"Stuff FIFO DIRECTLY with Safe State & Run fifo");
   fifoLoadHsl(pTheFifoObject, STD_HS_LINES, pTheFifoObject->SafeHSLines);
   fifoLoadHsl(pTheFifoObject, EXT_HS_LINES, pTheFifoObject->SafeHSLinesExt);
   /* Each SafeState Code is actually two long words */
   if (numSafeStatCodes > 0)
   {
      /*   WARNING: Does not pend for FF Almost Full, BEWARE !! */
      /*   Should only be used in phandler's reset2SafeState() */
      fifoStuffCode(pTheFifoObject, pSafeStateCodes, numSafeStatCodes);
      fifoStuffCode(pTheFifoObject, pTurnOffSshaCodes, numTurnOffSshaCodes);
      fifoStuffCode(pTheFifoObject, pHaltOpCodes, numHaltOpCodes);
	DPRINT(1,"Ready to start FIFO in reset to safe state\n" );
      fifoStart(pTheFifoObject);
      /* fifoWait4Stop(pTheFifoObject);  /* use BusyWait don't what any other lower priority tasks to run ! */
      fifoBusyWait4Stop(pTheFifoObject);  /* use BusyWait don't what any other lower priority tasks to run ! */
	DPRINT(1,"FIFO wait for stop completes in reset to safe state\n" );
   }
   activate_ssha();
   DPRINT(0,"getnGiveShimMutex\n");  
   /* allow any pending serial Shim commands to finish */
   getnGiveShimMutex();
   DPRINT(0,"getnGiveVTMutex\n");
   /* allow any pending serial VT commands to finish */
   getnGiveVTMutex();

/* Now Bump Priority of DownLiner so that it can Dump
   the remaining Data that SendProc wants to send it */

/* If we lost the connection to the host computer, the downlinker is
   is not going to get any more data; nor should this task (problem
   handler) wait for the downlinker to become ready.    April 1997  */

   DPRINT(0,"dlbFreeAllNotLoading Dyn");
   dlbFreeAllNotLoading(pDlbDynBufs);
   DPRINT(0,"dlbFreeAllNotLoading Fix");
   dlbFreeAllNotLoading(pDlbFixBufs);
   if (why != LOST_CONN)
   {
      pTmpId = taskNameToId("tDownLink");
      taskPriorityGet(pTmpId,&TmpPrior);
      taskPrioritySet(pTmpId,(pHandlerPriority-1));  

      /* downLinker has now A. ran and is suspended, 
			    B. Done and in READY state or
	 		    C. still waiting in a read of a socket
      */

      /* start wdog timeout of 20 seconds */ 
      wdStart(pHandlerWdTimeout,sysClkRateGet() * 20, pHandlerWdISR, 0);

      /* if it is busy and not suspend then wait till 
      /* it is Ready or Suspended, or Time-Out */
      while (downLinkerIsActive() &&  !taskIsSuspended(pTmpId) && !pHandlerTimeout)
            taskDelay(1);  /* wait one tick , 16msec */

      wdCancel(pHandlerWdTimeout);

      if (taskIsSuspended(pTmpId))
      {
        taskResume(pTmpId);
        wait4DownLinkerReady();
      }
      taskPrioritySet(pTmpId,TmpPrior);
      DPRINT(0,"downlinker resynchronized\n");
   }
   DPRINT(0,"dlbFreeAll Dyn");
   dlbFreeAll(pDlbDynBufs);
   DPRINT(0,"dlbFreeAll Fix");
   dlbFreeAll(pDlbFixBufs);

   /* 
     Now Bump Priority of Parser so that it can Finish Up  
     We don't have to worry as much about the state of the parser
     since it will completely restarted very soon. 
   */

   pTmpId = taskNameToId("tParser");
   taskPriorityGet(pTmpId,&TmpPrior);
   taskPrioritySet(pTmpId,(pHandlerPriority-1));  
   if (taskIsSuspended(pTmpId))
   {
     taskResume(pTmpId);
     wait4ParserReady();
   }
   taskPrioritySet(pTmpId,TmpPrior);
   resetAPint();
   DPRINT(0,"A-code parser resynchronized\n");

   /* Parser might of made a buffer ready to stuff, so better clear it just incase */
   if (why != INTERACTIVE_ABORT)
      fifoReset(pTheFifoObject, RESETFIFOBRD);  /* this now also clear the Fifo Buffer & restart the Stuffer */
   else
      fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */
   
   return;
}
Ejemplo n.º 14
0
Archivo: taskLib.c Proyecto: phoboz/vmx
STATUS taskActivate(
    int taskId
    )
{
    return taskResume(taskId);
}
Ejemplo n.º 15
0
/**
 * Resumes a paused task.
 * Returns true on success, false if unable to resume or if the task isn't running/paused.
 */
bool Task::Resume()
{
    return HandleError(taskResume(m_taskID));
}
Ejemplo n.º 16
0
void openTrap(){
	if (partProdTid!=0){return;}
	taskResume(partProdTid);
}
Ejemplo n.º 17
0
void
CVMthreadResume(CVMThreadID *t)
{
    taskResume(t->taskID);
}