Exemple #1
0
static int timeRegister(void)
{
    /* If TIMEZONE not defined, set it from EPICS_TIMEZONE */
    if (getenv("TIMEZONE") == NULL) {
        const char *timezone = envGetConfigParamPtr(&EPICS_TIMEZONE);
        if (timezone == NULL) {
            printf("timeRegister: No Time Zone Information\n");
        } else {
            epicsEnvSet("TIMEZONE", timezone);
        }
    }

    // Define EPICS_TS_FORCE_NTPTIME to force use of NTPTime provider
    bool useNTP = getenv("EPICS_TS_FORCE_NTPTIME") != NULL;

    if (!useNTP &&
        (taskNameToId(sntp_sync_task) != ERROR ||
         taskNameToId(ntp_daemon) != ERROR)) {
        // A VxWorks 6 SNTP/NTP sync task is running
        struct timespec clockNow;

        useNTP = clock_gettime(CLOCK_REALTIME, &clockNow) != OK ||
            clockNow.tv_sec < BUILD_TIME;
            // Assumes VxWorks and the host OS have the same epoch
    }

    if (useNTP) {
        // Start NTP first so it can be used to sync SysTime
        NTPTime_Init(100);
        ClockTime_Init(CLOCKTIME_SYNC);
    } else {
        ClockTime_Init(CLOCKTIME_NOSYNC);
    }
    return 1;
}
Exemple #2
0
startNodeHBPub(int priority, int taskoptions, int stacksize)
{

    if (taskNameToId("tAppHBPub") == ERROR)
        taskSpawn("tAppHBPub",priority,0,stacksize,pubHB,1,
                  2,3,4,5,6,7,8,9,10);
}
/* --------------------------------------------------------------------------------------
Name: OS_ShellOutputToFile

Purpose: Takes a shell command in and writes the output of that command to the specified file

Returns: OS_SUCCESS if success
         OS_FS_ERR_INVALID_FD if the file descriptor passed in is invalid
         OS_FS_ERROR if Error
---------------------------------------------------------------------------------------*/
int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd)
{
    char LocalCmd [OS_MAX_CMD_LEN];
    int32 Result;
    int32 ReturnCode = OS_FS_SUCCESS;
    int32 fdCmd;
    char * shellName;

    /*
    ** Check parameters
    */
    if (Cmd == NULL)
    {
        return(OS_FS_ERR_INVALID_POINTER);
    }

    /* Make sure the file descriptor is legit before using it */
    if (OS_fd < 0 || OS_fd >= OS_MAX_NUM_OPEN_FILES || OS_FDTable[OS_fd].IsValid == FALSE)
    {
        ReturnCode = OS_FS_ERR_INVALID_FD;
    }
    else
    {
        /* Create a file to write the command to (or write over the old one) */
        fdCmd = OS_creat(OS_SHELL_CMD_INPUT_FILE_NAME,OS_READ_WRITE);

        if (fdCmd < OS_FS_SUCCESS)
        {
            Result = OS_FS_ERROR;
        }

        else
        {
            /* copy the command to the file, and then seek back to the beginning of the file */

            strncpy(LocalCmd,Cmd, OS_MAX_CMD_LEN);
            OS_write(fdCmd,Cmd, strlen(LocalCmd));
            OS_lseek(fdCmd,0,OS_SEEK_SET);

            /* Create a shell task the will run the command in the file, push output to OS_fd */
            Result = shellGenericInit("INTERPRETER=Cmd",0,NULL, &shellName, FALSE, FALSE, OS_FDTable[fdCmd].OSfd,	OS_FDTable[OS_fd].OSfd, OS_FDTable[OS_fd].OSfd);

            /* Wait for the command to terminate */
           do{
              taskDelay(sysClkRateGet());
            }while (taskNameToId(shellName) != ERROR);

            /* Close the file descriptor */
            OS_close(fdCmd);

        } /* else */

        if (Result != OK)
        {
             ReturnCode =  OS_FS_ERROR;
        }

    }
    return ReturnCode;
}/* end OS_ShellOutputToFile */
Exemple #4
0
/**
 * Start the task that is responsible for sending images to the PC.
 */
int PCVideoServer::StartServerTask()
{
	if (StatusIsFatal())
	{
		return -1;
	}
	int id = 0;
	m_stopServer = false;
	// Check for prior copy of running task
	int oldId = taskNameToId((char*)m_serverTask.GetName());
	if(oldId != ERROR)
	{
		// TODO: Report error. You are in a bad state.
		taskDelete(oldId);
	}

	// spawn video server task
	// this is done to ensure that the task is spawned with the
	// floating point context save parameter.
	bool started = m_serverTask.Start((int)this);

	id = m_serverTask.GetID();

	if (!started)
	{
		wpi_setWPIError(TaskError);
		return id;
	}
	taskDelay(1);
	return id;
}
Exemple #5
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 */
}
Exemple #6
0
/* default priority adjustment functions */
void SetTaskPrio(const char* tName, const int tgtPrio)
{
    int tid=0, curPrio=0, newPrio=0;

    if ((tName != NULL) && (strlen(tName) > 0))
    {
        newPrio = tgtPrio;
        if (newPrio < 0)
        {
            newPrio = 0;
        }
        else if (newPrio > 255)
        {
            newPrio = 255;
        }

        tid = taskNameToId(tName);
        if (tid != ERROR)
        {
            if (taskPriorityGet(tid, &curPrio) != ERROR)
            {
                printf("Setting %s priority from %d to %d\n", tName, curPrio, newPrio);
                taskPrioritySet(tid, newPrio);
            }
        }
    }
}
int vxhGo()
{
  vxhStop();
  tid = taskNameToId("tShell");
  taskPrioritySet(tid,4);
  tid = taskNameToId("tLogTask");
  taskPrioritySet(tid,3);
  tid = taskNameToId("tExcTask");
  taskPrioritySet(tid,3);
  tid = taskNameToId("tTelnetd");
  taskPrioritySet(tid,5);
  tid = taskNameToId("tTelnetOutTask");
  taskPrioritySet(tid,6);
  tid = taskNameToId("tTelnetInTask");
  taskPrioritySet(tid,6);
  tid = taskNameToId("tWdbTask");
  taskPrioritySet(tid,7);

  vxh_stop_flag=0;
  vxh_count=0;
  vxh_id =  taskSpawn(0, //name
		1,		// priority
		VX_FP_TASK,	// options
		0x2000,		// stack size
		(FUNCPTR) vxh_task, // entry point
		      0,0,0,0,0,
		      0,0,0,0,0);
  return(0);
}
Exemple #8
0
/*----------------------------------------------------------------------*/
static
void resetNameBufs()   /* free all named buffers */
{
   int retrys;
   int callTaskId,DwnLkrTaskId;
   int callTaskPrior;

   /* Since reset2SafeState should have left the downLinker in a ready
      state we now longer need change priority/etc. here to get it to clean
      up.     8/6/97
   */
#ifdef XXX
   callTaskId = taskIdSelf();
   DwnLkrTaskId = taskNameToId("tDownLink");
   taskPriorityGet(callTaskId,&callTaskPrior);
#endif


   retrys=0;

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

   /* free buffers until all are free or watch-dog timeout has occurred */
   while ( ((dlbUsedBufs(pDlbDynBufs) > 0) || (dlbUsedBufs(pDlbFixBufs) > 0)) &&
		(!pHandlerTimeout) )
   {
        retrys++;
   	DPRINT(0,"dlbFreeAll Dyn");
   	dlbFreeAll(pDlbDynBufs);
   	DPRINT(0,"dlbFreeAll Fix");
   	dlbFreeAll(pDlbFixBufs);
	Tdelay(1);
	DPRINT1(0,"resetNameBufs: retrys: %d\n",retrys);
#ifdef XXX
        /* Lower priority to allow downlinker in */
	if (callTaskPrior <= DOWNLINKER_TASK_PRIORITY)
           taskPrioritySet(callTaskId,(DOWNLINKER_TASK_PRIORITY+1));  
	Tdelay(10);

	DPRINT1(-1,"resetNameBufs: retrys: %d\n",retrys);
        if (retrys > 7)
        {
	   if (taskIsSuspended(DwnLkrTaskId))
	   {
	      DPRINT(-1,"resetNameBufs: clearCurrentNameBuffer()\n");
  	      clearCurrentNameBuffer();
           }
        }
#endif
   }
   wdCancel(pHandlerWdTimeout);
   /* taskPrioritySet(callTaskId,callTaskPrior);   */

  /*    resumeDownLink(); */
}
Exemple #9
0
restartComLnk()
{
   int tid,stat,priority,stacksize,taskoptions;
   /* if tComLink still around then Connection was never made */
   DPRINT(1,"Time to Restart Exppproc Link.");
    if ((tid = taskNameToId("tMonitor")) != ERROR)
    {
       stat = taskDelete(tid);
    }
    if ((tid = taskNameToId("tStatAgent")) != ERROR)
    {
       stat = taskDelete(tid);
    }
    if ((tid = taskNameToId("tStatMon")) != ERROR)
    {
       stat = taskDelete(tid);
    }
   }
Exemple #10
0
cleanAupdt()
{
  int tid;
  if (pMsgesToAupdt != NULL)
  {
    msgQDelete(pMsgesToAupdt);
    pMsgesToAupdt = NULL;
  }
  tid = taskNameToId("tAupdt");
  if (tid != ERROR)
    taskDelete(tid);
}
Exemple #11
0
//=========================================================================
// ddrTask: DDR task initialization function utility
//=========================================================================
int ddrTask(char *name, void* task, int priority)
{
    int tid=taskNameToId(name);
    
    if(tid != ERROR)
        taskDelete(tid);
    
    if(tid=taskSpawn(name,priority,0,10000,
        task,0,0,0,0,0,0,0,0,0,0)==ERROR)
            //perror("ddrTask:%s",name); 
            perror("ddrTask"); 
    return tid;
}
Exemple #12
0
/**
 * 
 * Start the robot code.
 * This function starts the robot code running by spawning a task. Currently tasks seemed to be
 * started by LVRT without setting the VX_FP_TASK flag so floating point context is not saved on
 * interrupts. Therefore the program experiences hard to debug and unpredictable results. So the
 * LVRT code starts this function, and it, in turn, starts the actual user program.
 */
void RobotBase::startRobotTask(FUNCPTR factory)
{
#ifdef SVN_REV
	if (strlen(SVN_REV))
	{
		printf("WPILib was compiled from SVN revision %s\n", SVN_REV);
	}
	else
	{
		printf("WPILib was compiled from a location that is not source controlled.\n");
	}
#else
	printf("WPILib was compiled without -D'SVN_REV=nnnn'\n");
#endif

	// Check for startup code already running
	int32_t oldId = taskNameToId(const_cast<char*>("FRC_RobotTask"));
	if (oldId != ERROR)
	{
		// Find the startup code module.
		char moduleName[256];
		moduleNameFindBySymbolName("FRC_UserProgram_StartupLibraryInit", moduleName);
		MODULE_ID startupModId = moduleFindByName(moduleName);
		if (startupModId != NULL)
		{
			// Remove the startup code.
			unldByModuleId(startupModId, 0);
			printf("!!!   Error: Default code was still running... It was unloaded for you... Please try again.\n");
			return;
		}
		// This case should no longer get hit.
		printf("!!!   Error: Other robot code is still running... Unload it and then try again.\n");
		return;
	}

	// Let the framework know that we are starting a new user program so the Driver Station can disable.
	FRC_NetworkCommunication_observeUserProgramStarting();

	// Let the Usage Reporting framework know that there is a C++ program running
	nUsageReporting::report(nUsageReporting::kResourceType_Language, nUsageReporting::kLanguage_CPlusPlus);
	
	RobotBase::WriteVersionString();

	// Start robot task
	// This is done to ensure that the C++ robot task is spawned with the floating point
	// context save parameter.
	Task *task = new Task("RobotTask", (FUNCPTR)RobotBase::robotTask, Task::kDefaultPriority, 64000);
	task->Start((int32_t)factory, (int32_t)task);
}
Exemple #13
0
startPhandler(int priority, int taskoptions, int stacksize)
{
   int pHandler();

   if (taskNameToId("tPHandlr") == ERROR)
   {
     pHandlerPriority = priority;
     pHandlerTid = taskSpawn("tPHandlr",priority,taskoptions,stacksize,pHandler,
		   pMsgesToPHandlr,2, 3,4,5,6,7,8,9,10);
   
     pHandlerWdTimeout = wdCreate();
     pHandlerTimeout = 0;
   }

}
Exemple #14
0
startLockParser(int priority, int taskoptions, int stacksize)
{
   DPRINT1(-1,"sizeof(Lock_Cmd) = %d\n", sizeof(Lock_Cmd));
   if (pMsgesToLockParser == NULL)
      pMsgesToLockParser = msgQCreate(300,sizeof(Lock_Cmd),MSG_Q_PRIORITY);
   if (pMsgesToLockParser == NULL)
   {
      errLogSysRet(LOGIT,debugInfo,"could not create Lock Parser MsgQ, ");
      return;
   }
   
   if (taskNameToId("tLkParser") == ERROR)
      taskSpawn("tLkParser",priority,0,stacksize,LkParser,pMsgesToLockParser,
						2,3,4,5,6,7,8,9,10);
}
Exemple #15
0
startAupdt(int priority, int taskoptions, int stacksize)
{
   if (pMsgesToAupdt == NULL)
     pMsgesToAupdt = msgQCreate(300,100,MSG_Q_PRIORITY);
   if (pMsgesToAupdt == NULL)
   {
      errLogSysRet(LOGIT,debugInfo,
     	  "could not create X Parser MsgQ, ");
      return;
   }
   
   if (taskNameToId("tAupdt") == ERROR)
    taskSpawn("tAupdt",priority,0,stacksize,Aupdt,pMsgesToAupdt,
						2,3,4,5,6,7,8,9,10);
}
Exemple #16
0
/*
 *   Spawn the Non-Master Tune Task
 *
 *     Author:  Greg Brissey 12/20/04
 */
int startTuneTask(int priority, int taskoptions, int stacksize)
{
   if (pTuneMsgQ == NULL)
   {
      pTuneMsgQ = msgQCreate(10, sizeof(TUNE_MSG), MSG_Q_FIFO);
      if (pTuneMsgQ == NULL)
      {
          errLogSysRet(LOGIT,debugInfo,
	      "startCntlrTuneTask: Failed to allocate pTuneMsgQ MsgQ:");
          return(ERROR);
      }
   }
   
   if (taskNameToId("tTune") == ERROR)
      taskSpawn("tTune",priority,0,stacksize,cntlrTune,1,2,3,4,5,6,7,8,9,10);
}
void BSP_PromptSet()
{
    SHELL_ID    shellId;
    int taskId;

    /* Get the shell context */
    taskId = taskNameToId ("tShell0");
    shellId = shellFirst ();

    while (shellId != (SHELL_ID)0)
    {
        if (((SHELL_CTX *)shellId)->taskId == taskId)
            break;
        shellId = shellNext (shellId);
    }

    shellInterpPromptSet(shellId,"C","[C]->");
    taskPrioritySet(taskId, 9);/*优先级与V9一致*/
}
Exemple #18
0
static void unload_old_module(void)
{
	/* FIXME: This code currently does what WPILib does, but it isn't clear
	 *        why we should check that the task is running at all */
	int32_t old_task_id = taskNameToId((char *)TASK_NAME);
	if (old_task_id == ERROR)
		return;

	/* XXX: how do we avoid finding ourselves and ensure we find the old
	 * module?
	 *
	 * - Right now we just find the oldest (earliest in the system)
	 */
	MODULE_ID old_module_id = module_find_earliest_by_symbolname(STR(INIT_FUNC));
	if (!old_module_id)
		return;

	unldByModuleId(old_module_id, 0);
}
Exemple #19
0
/*--------------------------------------------------------------*/
AupdtAA()
{
   char	msg4Aupdt[ 32 ];
   int msgesCount;
   int tid;
   if ((tid = taskNameToId("tAupdt")) != ERROR)
   {
	/* taskSuspend(tid); */
	msgesCount = cleanMsgesToAupdt();
	if ((pTheAcodeObject != NULL) && 
				(pTheAcodeObject->pAcodeControl != NULL))
	{
		semGive(pTheAcodeObject->pAcodeControl);
	}
	if (msgesCount > 0)
	{
	   sprintf( &msg4Aupdt[ 0 ], "0;" );
	   msgQSend(pMsgesToAupdt, &msg4Aupdt[ 0 ], 3, NO_WAIT, MSG_PRI_NORMAL);
        }
	taskRestart(tid);
   }
}
Exemple #20
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);
}
Exemple #21
0
startFidCtStatPub(int priority, int taskoptions, int stacksize)
{
   /* if (pFidCtPubSem == NULL) */
   if (pFidCtPubMsgQ == NULL)
   {
      /* char *tmpbuf = (char*) malloc(1024); see Bugzilla bug# 150 */
      /* pFidCtPubSem = semBCreate(SEM_Q_FIFO,SEM_EMPTY); */
      /* pFidCtPubSem = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY); */

      pFidCtPubMsgQ = msgQCreate(10,sizeof(FidCt_Stat),MSG_Q_PRIORITY);
      /* if ( (pFidCtPubSem == NULL) ) */
      if ( (pFidCtPubMsgQ == NULL) )
      {
        errLogSysRet(LOGIT,debugInfo,
	   "startConsoleStatPub: Failed to allocate pFidCtPubSem Semaphore:");
        return(ERROR);
      }
   }
   
   /* DPRINT1(-1,"pFidCtPubSem: 0x%lx\n",pFidCtPubSem); */
   if (taskNameToId("tFidCtPub") == ERROR)
      taskSpawn("tFidCtPub",priority,0,stacksize,pubFidCtStatus,1,
						2,3,4,5,6,7,8,9,10);
}
Exemple #22
0
/*******************************************************************************
*
* remShellTelnetConn - connect shell to telnet
*
* This routine is called by the telnet demon to connect the shell with the 
* remote telnet user.
* Remote telnet requests will cause `stdin', `stdout', and `stderr' to be stolen
* away from the console.  When the remote user disconnects, `stdin', `stdout',
* and `stderr' are restored, and the shell is restarted.
*
* RETURNS: OK or ERROR.
*/
STATUS remShellTelnetConn
    (
    int              interpConnArg,	/* argument for interpConn () */
    int              slaveFd,
    int              exitArg,		/*  */
    int *            disconnArg,
    char *           msg
    )
    {
    /* wait for shell to exist */

    while (taskNameToId (telnetShellName) == ERROR)
        taskDelay (sysClkRateGet ());

    /* check to see if there's already an active connection */

    if (activeFlag)
        {
        strcpy(msg, "\r\nSorry, this system is engaged.\r\n");

        return ERROR;
        }

    if (!shellLock (TRUE))
	{
	strcpy(msg, "\r\nSorry, shell is locked.\r\n");

	printErr ("telnetd: someone tried to login into.\n");
        return ERROR;
	}

    printErr ("\ntelnetd: This system *IN USE* via telnet.\n");

    shellLogoutInstall ((FUNCPTR) telnetdExit, exitArg);
    activeFlag    = TRUE;

    /* get the shell's standard I/O fd's so we can restore them later */

    shellInFd  = ioGlobalStdGet (STD_IN);
    shellOutFd = ioGlobalStdGet (STD_OUT);
    shellErrFd = ioGlobalStdGet (STD_ERR);

#ifndef BROADCOM_DEBUG
#if VX_VERSION == 55 || VX_VERSION == 542
    /* set shell's standard I/O to pty device; add extra logging device */

    shellOrigStdSet (STD_IN, slaveFd);
    shellOrigStdSet (STD_OUT, slaveFd);
    shellOrigStdSet (STD_ERR, slaveFd);

    logFdAdd (slaveFd);
    logFdFromRlogin = slaveFd;      /* store pty fd for logFdSet() */
#endif
#endif	/* BROADCOM_DEBUG */

    /* the shell is currently stuck in a read from the console, so we
     * restart it */

#ifndef BROADCOM_DEBUG
#if (_WRS_VXWORKS_MAJOR >= 6) 
    excJobAdd((VOIDFUNCPTR)shellRestart,
                  (int)CURRENT_SHELL_SESSION , 0, 0, 0, 0, 0);
#else
    excJobAdd (shellRestart, TRUE, 0, 0, 0, 0, 0);
#endif
#else
    sp (copyStreams, slaveFd, slaveFd,0,0,0,0,0,0,0); /* !!! */
#endif	/* BROADCOM_DEBUG */

    (void) ioctl (slaveFd, FIOFLUSH, 0 /*XXX*/);

    return OK;
    } /* remShellTelnetConn */
Exemple #23
0
void rootTask (long a0, long a1, long a2, long a3, long a4,
	       long a5, long a6, long a7, long a8, long a9)
{
    WIND_TCB *pTcb;

    TEST_START(0);

    pTcb = taskTcb(taskIdSelf());
    TEST_ASSERT(pTcb != NULL);

    bsemid = semBCreate(0xffffffff,0);
    TEST_ASSERT(bsemid == 0 && errno == S_semLib_INVALID_QUEUE_TYPE);

    bsemid = semBCreate(SEM_Q_PRIORITY,0);
    TEST_ASSERT(bsemid != 0);

    mutexid = semMCreate(0xffffffff);
    TEST_ASSERT(mutexid == 0 && errno == S_semLib_INVALID_QUEUE_TYPE);

    mutexid = semMCreate(SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE);
    TEST_ASSERT(mutexid != 0);

    taskSpawn("Test1",
	      20,		/* low-pri */
	      0,
	      32768,
	      sem1Task,
	      taskIdSelf(),0,0,0,0,0,0,0,0,0);

    taskSpawn("Test2",
	      10,		/* intermediate-pri */
	      0,
	      32768,
	      sem2Task,
	      taskIdSelf(),0,0,0,0,0,0,0,0,0);

    /* This runs at high-pri */

    TEST_MARK();

    TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(taskSuspend(0));

    TEST_MARK();

    TEST_ASSERT_OK(semTake(mutexid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(semGive(mutexid));

    TEST_MARK();

    TEST_ASSERT(taskIsReady(taskNameToId("Test2")));

    TEST_ASSERT(!taskIsSuspended(taskNameToId("Test2")));

    TEST_ASSERT_OK(taskDelay(1));

    TEST_MARK();

    TEST_CHECK_SEQUENCE(SEQ("root",1),
			SEQ("Test2",1),
			SEQ("root",1),
			SEQ("Test2",1),
			SEQ("Test1",2),
			SEQ("Test2",1),
			SEQ("root",1),
			SEQ("Test1",1),
			SEQ("root",2),
			SEQ("Test2",1),
			SEQ("root",1),
			END_SEQ);
    TEST_FINISH();
}
Exemple #24
0
killAupdt()
{
   int tid;
   if ((tid = taskNameToId("tAupdt")) != ERROR)
      taskDelete(tid);
}
Exemple #25
0
killLkParser()
{
   int tid;
   if ((tid = taskNameToId("tLkParser")) != ERROR)
      taskDelete(tid);
}
//---------------------------------------------------------------------------
//
// Function:    openPowerlinkInit
//
// Description:
//    Initialize and start the openPOWERLINK demo application
//
// Parameters:
//    pszEthName = pointer to string with name of network interface to use
//
// Returns: int
//
//---------------------------------------------------------------------------
int openPowerlinkInit (char *pszEthName, unsigned int uiDevNumber)
{
    tEplKernel          EplRet;
    static tEplApiInitParam EplApiInitParam = {0};
    char*               sHostname = HOSTNAME;
    BOOL                fApiInit = FALSE;
    int                 tid;

    // Adjust task priorities of system tasks

    /* shell task is normally set to priority 1 which could disturb
     * openPOWERLINK if long-running commands are entered. Therefore
     * we lower the performance to 20
     */
    tid = taskIdSelf();
    printf ("Task ID: %d\n", tid);
    taskPrioritySet(tid, 20);

    /* The priority of the network stack task has to be increased (default:50)
     * in order to get network packets in time!
     */
    if ((tid = taskNameToId("tNet0")) != -1 )
    {
        taskPrioritySet(tid, 5);
    }

    // Initialize high-resolution timer library
    hrtimer_init(EPL_TASK_PRIORITY_HRTIMER, EPL_TASK_STACK_SIZE);

    // get node ID from insmod command line
    EplApiInitParam.m_uiNodeId = uiNodeId_g;

    if (EplApiInitParam.m_uiNodeId == EPL_C_ADR_INVALID)
    {   // invalid node ID set
        // set default node ID
        EplApiInitParam.m_uiNodeId = NODEID;
    }

    uiNodeId_g = EplApiInitParam.m_uiNodeId;

    // calculate IP address
    EplApiInitParam.m_dwIpAddress = (0xFFFFFF00 & IP_ADDR) |
                                    EplApiInitParam.m_uiNodeId;

    EplApiInitParam.m_fAsyncOnly = FALSE;

    // store the specified device name
    EplApiInitParam.m_HwParam.m_pszDevName = pszEthName;
    EplApiInitParam.m_HwParam.m_uiDevNumber = uiDevNumber;

    EplApiInitParam.m_uiSizeOfStruct = sizeof (EplApiInitParam);
    EPL_MEMCPY(EplApiInitParam.m_abMacAddress, abMacAddr,
               sizeof (EplApiInitParam.m_abMacAddress));
    EplApiInitParam.m_dwFeatureFlags = (DWORD) ~0UL;
    EplApiInitParam.m_dwCycleLen = uiCycleLen_g;  // required for error detection
    EplApiInitParam.m_uiIsochrTxMaxPayload = 100; // const
    EplApiInitParam.m_uiIsochrRxMaxPayload = 100; // const
    EplApiInitParam.m_dwPresMaxLatency = 50000;   // const; only required for IdentRes
    EplApiInitParam.m_uiPreqActPayloadLimit = 36; // required for initialisation (+28 bytes)
    EplApiInitParam.m_uiPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes)
    EplApiInitParam.m_dwAsndMaxLatency = 150000;  // const; only required for IdentRes
    EplApiInitParam.m_uiMultiplCycleCnt = 0;      // required for error detection
    EplApiInitParam.m_uiAsyncMtu = 1500;          // required to set up max frame size
    EplApiInitParam.m_uiPrescaler = 2;            // required for sync
    EplApiInitParam.m_dwLossOfFrameTolerance = 500000;
    EplApiInitParam.m_dwAsyncSlotTimeout = 3000000;
    EplApiInitParam.m_dwWaitSocPreq = 0;
    EplApiInitParam.m_dwDeviceType = (DWORD) ~0UL;      // NMT_DeviceType_U32
    EplApiInitParam.m_dwVendorId = (DWORD) ~0UL;        // NMT_IdentityObject_REC.VendorId_U32
    EplApiInitParam.m_dwProductCode = (DWORD) ~0UL;     // NMT_IdentityObject_REC.ProductCode_U32
    EplApiInitParam.m_dwRevisionNumber = (DWORD) ~0UL;  // NMT_IdentityObject_REC.RevisionNo_U32
    EplApiInitParam.m_dwSerialNumber = (DWORD) ~0UL;    // NMT_IdentityObject_REC.SerialNo_U32
    EplApiInitParam.m_dwSubnetMask = SUBNET_MASK;
    EplApiInitParam.m_dwDefaultGateway = 0;
    EPL_MEMCPY(EplApiInitParam.m_sHostname, sHostname, sizeof(EplApiInitParam.m_sHostname));
    EplApiInitParam.m_uiSyncNodeId = EPL_C_ADR_SYNC_ON_SOA; // for fSyncOnPrcNode==TRUE, this means last PRC node
    EplApiInitParam.m_fSyncOnPrcNode = TRUE;

    // set callback functions
    EplApiInitParam.m_pfnCbEvent = AppCbEvent;
    EplApiInitParam.m_pfnCbSync  = AppCbSync;
    EplApiInitParam.m_pfnObdInitRam = EplObdInitRam;

    printf("\n\n Hello, I'm a VxWorks POWERLINK node running as %s!\n"
           "(build: %s / %s)\n\n",
            (uiNodeId_g == EPL_C_ADR_MN_DEF_NODE_ID ?
                "Managing Node" : "Controlled Node"),
            __DATE__, __TIME__);

    // initialize POWERLINK stack
    EplRet = EplApiInitialize(&EplApiInitParam);
    if(EplRet != kEplSuccessful)
    {
        goto Exit;
    }
    fApiInit = TRUE;

    // set CDC filename
    EplRet = EplApiSetCdcFilename(pszCdcFilename_g);
    if(EplRet != kEplSuccessful)
    {
    	printf ("Error set cdc filename!\n");
        goto Exit;
    }

    // initialize application
    printf ("Initializing openPOWERLINK application...\n");
    EplRet = AppInit();
    if(EplRet != kEplSuccessful)
    {
        printf("ApiInit() failed!\n");
        goto Exit;
    }

    // initialize process image
    printf("Initializing process image...\n");
    printf("Size of input process image: %ld\n", sizeof(AppProcessImageIn_g));
    printf("Size of output process image: %ld\n", sizeof (AppProcessImageOut_g));
    AppProcessImageCopyJob_g.m_fNonBlocking = FALSE;
    AppProcessImageCopyJob_g.m_uiPriority = 0;
    AppProcessImageCopyJob_g.m_In.m_pPart = &AppProcessImageIn_g;
    AppProcessImageCopyJob_g.m_In.m_uiOffset = 0;
    AppProcessImageCopyJob_g.m_In.m_uiSize = sizeof (AppProcessImageIn_g);
    AppProcessImageCopyJob_g.m_Out.m_pPart = &AppProcessImageOut_g;
    AppProcessImageCopyJob_g.m_Out.m_uiOffset = 0;
    AppProcessImageCopyJob_g.m_Out.m_uiSize = sizeof (AppProcessImageOut_g);

    EplRet = EplApiProcessImageAlloc(sizeof (AppProcessImageIn_g),
                                     sizeof (AppProcessImageOut_g), 2, 2);
    if (EplRet != kEplSuccessful)
    {
        goto Exit;
    }

    EplRet = EplApiProcessImageSetup();
    if (EplRet != kEplSuccessful)
    {
        goto Exit;
    }

    // start the NMT state machine
    EplRet = EplApiExecNmtCommand(kEplNmtEventSwReset);

Exit:
    PRINTF("%s(): returns 0x%X\n", __func__, EplRet);
    if (EplRet != kEplSuccessful)
    {
        if (fApiInit != FALSE)
        {
            EplApiShutdown();
        }

        // Shutdown high-resolution timer library
        hrtimer_shutdown();
        fOpenPowerlinkIsRunning_g = FALSE;
        return -ENODEV;
    }
    else
    {
        fOpenPowerlinkIsRunning_g = TRUE;
        return 0;
    }
}
Exemple #27
0
killPhandler()
{
   int tid;
   if ((tid = taskNameToId("tPHandlr")) != ERROR)
	taskDelete(tid);
}
Exemple #28
0
STATUS shellParserControl
    (
    UINT32 remoteEvent,	/* Starting or stopping a connection? */
    UINT32 sessionId, 	/* Unique identifier for each session */
    UINT32 slaveFd      /* File descriptor for character i/o  */
    )
    {

    if ((taskNameToId ("tShell")) == ERROR)   /* Shell not started yet. */
        return (ERROR);

    if (remoteEvent == REMOTE_START)
        {
        /* Handle a new telnet or rlogin session. */

        if (remoteId != 0)    /* Failed request - only one session allowed. */
            return (ERROR); 

        if (!shellLock (TRUE)) 	/* Shell is not available. */
            {
	    fdprintf (slaveFd, "The shell is currently in use.\n");
            return (ERROR);
            }

        /* Let the user try to login */
	if (shellLogin (slaveFd) != OK)
	    { 
 	    shellLock (FALSE);
            return (ERROR);
            }

        /* setup the slave device to act like a terminal */

        (void) ioctl (slaveFd, FIOOPTIONS, OPT_TERMINAL);

        shellLogoutInstall ((FUNCPTR) telnetdExit, sessionId);

        /* get the shell's standard I/O fd's so we can restore them later */

        shellInFd  = ioGlobalStdGet (STD_IN);
        shellOutFd = ioGlobalStdGet (STD_OUT);
        shellErrFd = ioGlobalStdGet (STD_ERR);

        /* set shell's standard I/O to new device; add extra logging device */

        shellOrigStdSet (STD_IN, slaveFd);
        shellOrigStdSet (STD_OUT, slaveFd);
        shellOrigStdSet (STD_ERR, slaveFd);

        logFdAdd (slaveFd);
        logFdFromRlogin = slaveFd;      /* store new fd for logFdSet() */

        /* Store the session identifier. */

        remoteId = sessionId;

        /* notify the shell we have started a remote session */
        
        shellIsRemoteConnectedSet (TRUE);

        printErr ("\ntelnetd: This system *IN USE* via telnet.\n");

        /* Prevent network denial of service attacks by waiting a second */

        taskDelay (sysClkRateGet() / 2); 
       
        /* Restart the shell to access the redirected file descriptors. */

        excJobAdd (shellRestart, TRUE, 0, 0, 0, 0, 0);

        return (OK);
        }
    else if (remoteEvent == REMOTE_STOP)
        {
        /*
         * End an active telnet or rlogin session. This event occurs
         * after the server closes the socket.
         */

        if (remoteId != sessionId)    /* Unknown remote session. */
            return (ERROR);

        shellLogoutInstall ((FUNCPTR) NULL, 0);  /* remove logout function */

        if (logFdFromRlogin != NONE)
            {
            logFdDelete (logFdFromRlogin);       /* cancel extra log device */
            logFdFromRlogin = NONE;              /* reset fd */
            }

        shellOrigStdSet (STD_IN,  shellInFd);    /* restore shell's stnd I/O */
        shellOrigStdSet (STD_OUT, shellOutFd);
        shellOrigStdSet (STD_ERR, shellErrFd);

        shellLock (FALSE);                       /* unlock shell */

        /*
         * For typical remote sessions, restoring the standard I/O
         * descriptors is enough to reconnect the shell to the console
         * because closing the pty device will cause the shell to unblock
         * from its read() and use the restored descriptors. However,
         * problems can occur upon logout if the remote user has disabled
         * the line editor and/or put the pty device in raw mode, so the
         * shell is restarted in all cases.
         */

        remoteId = 0;    /* Allow a new session. */

       /* notify the shell we have ended a remote session */
        
        shellIsRemoteConnectedSet (FALSE);

        excJobAdd (shellRestart, FALSE, 0, 0, 0, 0, 0);

        return (OK);
        }

    return (ERROR);    /* Ignore unknown control operations. */
    }
Exemple #29
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;
}
Exemple #30
0
killConsolePub()
{
   int tid;
   if ((tid = taskNameToId("tFidCtPub")) != ERROR)
      taskDelete(tid);
}