static void exitFunc(void* arg)
{
    long stat = (long)arg;
	epicsThreadSleep(0.1); /* give asub record time to finish */
    if (stat == 0)
	{
	    epicsExit(EXIT_SUCCESS);
	}
	else
	{
	    epicsExit(EXIT_FAILURE);
	}
}
예제 #2
0
static void exitSubroutine(subRecord *precord) {
#ifdef USE_EXIT_LATER
    epicsExitLater((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
#else
    epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
#endif
}
예제 #3
0
static void usage(int status) {
    printf("Usage: %s [-D softIoc.dbd] [-h] [-S] [-a ascf]\n", arg0);
    puts("\t[-m macro=value,macro2=value2] [-d file.db]");
    puts("\t[-x prefix] [st.cmd]");
    puts("Compiled-in path to softIocPVA.dbd is:");
    printf("\t%s\n", base_dbd);
    epicsExit(status);
}
예제 #4
0
int main(int argc,char *argv[])
{
    if(argc>=2) {
        iocsh(argv[1]);
        epicsThreadSleep(.2);
    }
    iocsh(NULL);
    epicsExit(0);
    return(0);
}
예제 #5
0
int main(int argc, char*argv[]) {
	if (argc >= 2) {
		iocsh(argv[1]);
		epicsThreadSleep(.2);
	}
	iocsh(NULL);
	gROOT->CloseFiles();
	epicsExit(0);
	return 0;
}
예제 #6
0
int main(int argc,char *argv[])
{
    iocshRegister(&asinittestFuncDef,asinittestCallFunc);
    if(argc>=2) {
        if (iocsh(argv[1]) < 0)
            return(1);
        epicsThreadSleep(.2);
    }
    iocsh(NULL);
    epicsExit(0);
    return(0);
}
예제 #7
0
int main(int argc,char *argv[])
{
    if(argc!=2) {
        printf("must provide command file\n");
        return(1);
    }
    iocsh(argv[1]);
    epicsThreadSleep(.2);
    iocsh(NULL);
    epicsExit(0);
    return(0);
}
int main(int argc,char *argv[])
{
	int i, j;
	short daemon;
	char stcmd[256];

	/* Need to catch hang up signal to make sure semaphores are
	   cleaned up properly */
	SetSigShutdownHandler();

	daemon = 0;
	if(argc>=2) {    
		snprintf( stcmd, 255, "%s", argv[1]);
		j = 0;
		for( i = 2; i < argc; i++) {
		  if( strcmp( argv[i], "-D") == 0) {
		    i++;
		    DEBUG = atoi( argv[i]);
		  } else if( strcmp( argv[i], "-d") == 0) {
		    daemon = 1;
		  }
		}
	}
	else
	{
		printf( "Syntax: hvcontrol <st.cmd> [-d] [-D <debuglevel>]\n");
		printf( "              -d = run in daemon mode\n");
		printf( "              <debuglevel> = 0 no messages\n");
		printf( "              <debuglevel> = 10 all available messages\n");
	}

	if (strlen(stcmd)>0)	iocsh(stcmd);

	if (daemon)	{
		for(;;)
			epicsThreadSleep(1.0);
	} else {
		iocsh(NULL);
	}
	Shutdown();
    epicsExit(0);
	return(0);
}
예제 #9
0
void pvDataAllTests(void)
{
    testHarness();

    /* pv */
    runTest(testBitSetUtil);
    runTest(testConvert);
    runTest(testFieldBuilder);
    runTest(testIntrospect);
    runTest(testOperators);
    runTest(testPVData);
    runTest(testPVScalarArray);
    runTest(testPVStructureArray);
    runTest(testPVType);
    runTest(testPVUnion);
    runTest(testStandardField);
    runTest(testStandardPVField);

    /* misc */
    runTest(testBaseException);
    runTest(testBitSet);
    runTest(testByteBuffer);
    runTest(testOverrunBitSet);
    runTest(testSerialization);
    runTest(testSharedVector);
    runTest(testThread);
    runTest(testEvent);
    runTest(testTimeStamp);
    runTest(testTimer);
    runTest(testTypeCast);

    /* copy */
    runTest(testCreateRequest);
    runTest(testPVCopy);

    /* property */
    runTest(testCreateRequest);

    epicsExit(0);   /* Trigger test harness */
}
예제 #10
0
파일: rtems_init.c 프로젝트: ukaea/epics
/*
 * RTEMS Startup task
 */
rtems_task
Init (rtems_task_argument ignored)
{
    int                 i;
    char               *argv[3]         = { NULL, NULL, NULL };
    char               *cp;
    rtems_task_priority newpri;
    rtems_status_code   sc;
    rtems_time_of_day   now;

    /*
     * Explain why we're here
     */
    logReset();

    /*
     * Architecture-specific hooks
     */
    if (epicsRtemsInitPreSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0)
        delayedPanic("epicsRtemsInitPreSetBootConfigFromNVRAM");
    if (rtems_bsdnet_config.bootp == NULL) {
        extern void setBootConfigFromNVRAM(void);
        setBootConfigFromNVRAM();
    }
    if (epicsRtemsInitPostSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0)
        delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM");

    /*
     * Override RTEMS configuration
     */
    rtems_task_set_priority (
                     RTEMS_SELF,
                     epicsThreadGetOssPriorityValue(epicsThreadPriorityIocsh),
                     &newpri);

    /*
     * Create a reasonable environment
     */
    initConsole ();
    putenv ("TERM=xterm");
    putenv ("IOCSH_HISTSIZE=20");

    /*
     * Display some OS information
     */
    printf("\n***** RTEMS Version: %s *****\n",
        rtems_get_version_string());

    /*
     * Start network
     */
    if ((cp = getenv("EPICS_TS_NTP_INET")) != NULL)
        rtems_bsdnet_config.ntp_server[0] = cp;
    if (rtems_bsdnet_config.network_task_priority == 0)
    {
        unsigned int p;
        if (epicsThreadHighestPriorityLevelBelow(epicsThreadPriorityScanLow, &p)
                                            == epicsThreadBooleanStatusSuccess)
        {
            rtems_bsdnet_config.network_task_priority = epicsThreadGetOssPriorityValue(p);
        }
    }
    printf("\n***** Initializing network *****\n");
    rtems_bsdnet_initialize_network();
    initialize_remote_filesystem(argv, initialize_local_filesystem(argv));

    /*
     * More environment: iocsh prompt and hostname
     */
    {
        char hostname[1024];
        gethostname(hostname, 1023);
        char *cp = mustMalloc(strlen(hostname)+3, "iocsh prompt");
        sprintf(cp, "%s> ", hostname);
        epicsEnvSet ("IOCSH_PS1", cp);
        epicsEnvSet("IOC_NAME", hostname);
    }

    /*
     * Use BSP-supplied time of day if available otherwise supply default time.
     * It is very likely that other time synchronization facilities in EPICS
     * will soon override this value.
     */
    if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&now) != RTEMS_SUCCESSFUL) {
        now.year = 2001;
        now.month = 1;
        now.day = 1;
        now.hour = 0;
        now.minute = 0;
        now.second = 0;
        now.ticks = 0;
        if ((sc = rtems_clock_set (&now)) != RTEMS_SUCCESSFUL)
            printf ("***** Can't set time: %s\n", rtems_status_text (sc));
    }
    if (getenv("TZ") == NULL) {
        const char *tzp = envGetConfigParamPtr(&EPICS_TIMEZONE);
        if (tzp == NULL) {
            printf("Warning -- no timezone information available -- times will be displayed as GMT.\n");
        }
        else {
            char tz[10];
            int minWest, toDst = 0, fromDst = 0;
            if(sscanf(tzp, "%9[^:]::%d:%d:%d", tz, &minWest, &toDst, &fromDst) < 2) {
                printf("Warning: EPICS_TIMEZONE (%s) unrecognizable -- times will be displayed as GMT.\n", tzp);
            }
            else {
                char posixTzBuf[40];
                char *p = posixTzBuf;
                p += sprintf(p, "%cST%d:%.2d", tz[0], minWest/60, minWest%60);
                if (toDst != fromDst)
                    p += sprintf(p, "%cDT", tz[0]);
                epicsEnvSet("TZ", posixTzBuf);
            }
        }
    }
    tzset();
    osdTimeRegister();

    /*
     * Run the EPICS startup script
     */
    printf ("***** Starting EPICS application *****\n");
    iocshRegisterRTEMS ();
    set_directory (argv[1]);
    epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
    atexit(exitHandler);
    i = main ((sizeof argv / sizeof argv[0]) - 1, argv);
    printf ("***** IOC application terminating *****\n");
    epicsThreadSleep(1.0);
    epicsExit(0);
}
예제 #11
0
static void simRegDevAsyncConfigureFunc (const iocshArgBuf *args)
{
    int status = simRegDevAsyncConfigure(
        args[0].sval, args[1].ival, args[2].ival);
    if (status != 0) epicsExit(1);
}
예제 #12
0
static void exitSubroutine(subRecord *precord) {
    epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
}
예제 #13
0
int main(int argc, char *argv[])
{
    char *dbd_file = const_cast<char*>(base_dbd);
    char *macros = NULL;
    char xmacro[PVNAME_STRINGSZ + 4];
    int startIocsh = 1;	/* default = start shell */
    int loadedDb = 0;
    
    arg0 = strrchr(*argv, '/');
    if (!arg0) {
	arg0 = *argv;
    } else {
	++arg0;	/* skip the '/' */
    }
    
    --argc, ++argv;
    
    /* Do this here in case the dbd file not available */
    if (argc>0 && **argv=='-' && (*argv)[1]=='h') {
	usage(EXIT_SUCCESS);
    }
    
    if (argc>1 && **argv=='-' && (*argv)[1]=='D') {
	dbd_file = *++argv;
	argc -= 2;
	++argv;
    }
    
    if (dbLoadDatabase(dbd_file, NULL, NULL)) {
	epicsExit(EXIT_FAILURE);
    }
    
    softIocPVA_registerRecordDeviceDriver(pdbbase);
    registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);

    while (argc>1 && **argv == '-') {
	switch ((*argv)[1]) {
	case 'a':
	    if (macros) asSetSubstitutions(macros);
	    asSetFilename(*++argv);
	    --argc;
	    break;
	
	case 'd':
	    if (dbLoadRecords(*++argv, macros)) {
		epicsExit(EXIT_FAILURE);
	    }
	    loadedDb = 1;
	    --argc;
	    break;
	
	case 'h':
	    usage(EXIT_SUCCESS);
	
	case 'm':
	    macros = *++argv;
	    --argc;
	    break;
	
	case 'S':
	    startIocsh = 0;
	    break;
	
	case 's':
	    break;
	
	case 'x':
	    epicsSnprintf(xmacro, sizeof xmacro, "IOC=%s", *++argv);
	    if (dbLoadRecords(exit_db, xmacro)) {
		epicsExit(EXIT_FAILURE);
	    }
	    loadedDb = 1;
	    --argc;
	    break;
	
	default:
	    printf("%s: option '%s' not recognized\n", arg0, *argv);
	    usage(EXIT_FAILURE);
	}
	--argc;
	++argv;
    }
    
    if (argc>0 && **argv=='-') {
	switch((*argv)[1]) {
	case 'a':
	case 'd':
	case 'm':
	case 'x':
	    printf("%s: missing argument to option '%s'\n", arg0, *argv);
	    usage(EXIT_FAILURE);
	
	case 'h':
	    usage(EXIT_SUCCESS);
	
	case 'S':
	    startIocsh = 0;
	    break;
	
	case 's':
	    break;
	
	default:
	    printf("%s: option '%s' not recognized\n", arg0, *argv);
	    usage(EXIT_FAILURE);
	}
	--argc;
	++argv;
    }
    
    if (loadedDb) {
	iocInit();
	epicsThreadSleep(0.2);
    }
    
    /* run user's startup script */
    if (argc>0) {
	if (iocsh(*argv)) epicsExit(EXIT_FAILURE);
	epicsThreadSleep(0.2);
	loadedDb = 1;	/* Give it the benefit of the doubt... */
    }
    
    /* start an interactive shell if it was requested */
    if (startIocsh) {
	iocsh(NULL);
    } else {
	if (loadedDb) {
	    epicsThreadExitMain();
	} else {
	    printf("%s: Nothing to do!\n", arg0);
	    usage(EXIT_FAILURE);
	}
    }
    epicsExit(EXIT_SUCCESS);
    /*Note that the following statement will never be executed*/
    return 0;
}
예제 #14
0
static void exitNow(void *junk)
{
    epicsExit(exitLaterStatus);
}