示例#1
0
文件: debayer.c 项目: scs/ux-view
OSC_ERR Unload()
{
	/* Unload the framework module dependencies */
	OscUnloadDependencies(hFramework, deps, length (deps));
	
	OscDestroy(hFramework);
	
	return SUCCESS;
}
示例#2
0
文件: main.c 项目: Ikem/udgasser
OSC_ERR Unload()
{
	/******** Unload the framework module dependencies **********/
	OscUnloadDependencies(data.hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));

	OscDestroy(data.hFramework);

	return SUCCESS;
}
示例#3
0
/*********************************************************************//*!
 * @brief Shut down system and close framework
 *
 * @param s Pointer to the system state 
 *//*********************************************************************/
void cleanupSystem(struct SYSTEM *s)
{
	/* Destroy modules */
	#if defined(OSC_HOST)
		OscFrdDestroy(s->hFramework);
	#endif

	OscUnloadDependencies(s->hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));
	/* Destroy framework */
	OscDestroy(s->hFramework);
} /* cleanupSysteim */
示例#4
0
文件: main.c 项目: scs/rich-view
OSC_ERR Unload()
{
	/******** Unload the framework module dependencies **********/
	OscUnloadDependencies(data.hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));
	
	OscDestroy(data.hFramework);
	
	/* Close all communication */
	Comm_DeInit(&data.comm);

	/* Clear global data fields. */
	memset(&data, 0, sizeof(struct DATA));
    	
	return SUCCESS;
}
示例#5
0
文件: main.c 项目: Ikem/udgasser
/*********************************************************************//*!
 * @brief Initialize everything so the application is fully operable
 * after a call to this function.
 *
 * @return SUCCESS or an appropriate error code.
 *//*********************************************************************/
static OSC_ERR init(const int argc, const char * argv[])
{
	OSC_ERR err = SUCCESS;
	uint8 multiBufferIds[2] = {0, 1};

	memset(&data, 0, sizeof(struct TEMPLATE));

	/******* Create the framework **********/
	err = OscCreate(&data.hFramework);
	if (err < 0)
	{
		fprintf(stderr, "%s: Unable to create framework.\n", __func__);
		return err;
	}

	/******* Load the framework module dependencies. **********/
	err = OscLoadDependencies(data.hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));

	if (err != SUCCESS)
	{
		fprintf(stderr, "%s: ERROR: Unable to load dependencies! (%d)\n", __func__, err);
		goto dep_err;
	}

	/********* Seed the random generator *************/
	srand(OscSupCycGet());

#if defined(OSC_HOST) || defined(OSC_SIM)
	err = OscFrdCreateConstantReader(&data.hFileNameReader, TEST_IMAGE_FN);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to create constant file name reader for %s! (%d)\n", __func__, TEST_IMAGE_FN, err);
		goto frd_err;
	}
	err = OscCamSetFileNameReader(data.hFileNameReader);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set file name reader for camera! (%d)\n", __func__, err);
		goto frd_err;
	}
#endif /* OSC_HOST or OSC_SIM */

	/* Set the camera registers to sane default values. */
	err = OscCamPresetRegs();
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to preset camera registers! (%d)\n", __func__, err);
		goto fb_err;
	}

	/* Set up two frame buffers with enough space for the maximum
	 * camera resolution in cached memory. */
	err = OscCamSetFrameBuffer(0, OSC_CAM_MAX_IMAGE_WIDTH*OSC_CAM_MAX_IMAGE_HEIGHT, data.u8FrameBuffers[0], TRUE);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up first frame buffer!\n", __func__);
		goto fb_err;
	}
	err = OscCamSetFrameBuffer(1, OSC_CAM_MAX_IMAGE_WIDTH*OSC_CAM_MAX_IMAGE_HEIGHT, data.u8FrameBuffers[1], TRUE);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up second frame buffer!\n", __func__);
		goto fb_err;
	}

	/* Create a double-buffer from the frame buffers initilalized above.*/
	err = OscCamCreateMultiBuffer(2, multiBufferIds);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up multi buffer!\n", __func__);
		goto mb_err;
	}

	/* Register an IPC channel to the CGI for the user interface. */
	err = OscIpcRegisterChannel(&data.ipc.ipcChan, USER_INTERFACE_SOCKET_PATH, F_IPC_SERVER | F_IPC_NONBLOCKING);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to initialize IPC channel to web interface! (%d)\n", __func__, err);
		goto ipc_err;
	}

	err |= OscCamPerspectiveStr2Enum("DEFAULT", &data.perspective);
	if ( err != SUCCESS)
	{
		OscLog(ERROR, "%s: Invalid camera perspective.\n", __func__);
		goto per_err;
	}
	OscCamSetupPerspective( data.perspective);

	return SUCCESS;

per_err:
ipc_err:
mb_err:
fb_err:
#if defined(OSC_HOST) || defined(OSC_SIM)
frd_err:
#endif
	OscUnloadDependencies(data.hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));
dep_err:
	OscDestroy(&data.hFramework);

	return err;
}
示例#6
0
文件: main.c 项目: scs/rich-view
/*********************************************************************//*!
 * @brief Initialize everything so the application is fully operable
 * after a call to this function.
 * 
 * @return SUCCESS or an appropriate error code.
 *//*********************************************************************/
static OSC_ERR init(const int argc, const char * argv[])
{
    OSC_ERR err = SUCCESS;
    uint8 multiBufferIds[2] = {0, 1};
    char strVersion[15]; 
    struct CFG_KEY configKey;
    struct CFG_VAL_STR strCfg;
#ifdef HAS_CPLD
    uint16 exposureDelay;
#endif /* HAS_CPLD */	
    memset(&data, 0, sizeof(struct DATA));
	
    /* Print software version */
    GetVersionString( strVersion); 
	fprintf(stderr, "Software rich-view version: %s\n", strVersion); 	
	
    /******* Create the framework **********/
    err = OscCreate(&data.hFramework);
    if (err < 0)
    {
    	fprintf(stderr, "%s: Unable to create framework.\n", __func__);
    	return err;
    }
	
    /******* Load the framework module dependencies. **********/
    err = OscLoadDependencies(data.hFramework, deps, sizeof(deps)/sizeof(struct OSC_DEPENDENCY));
    
    if (err != SUCCESS)
    {
    	fprintf(stderr, "%s: ERROR: Unable to load dependencies! (%d)\n", __func__, err);
    	goto dep_err;
    }

    /* Set logging levels */
    OscLogSetConsoleLogLevel(INFO);
    OscLogSetFileLogLevel(DEBUG);

    /* Print framework version */
    OscGetVersionString( strVersion);    
    OscLog(INFO, "Oscar framework version: %s\n", strVersion);

	/* Disable watchdog (probably activated from previous application) */
	OscSupWdtInit();
	OscSupWdtClose();
	
	/* Set LED to green, util the idle state is entered */
	OscGpioSetTestLed( TRUE);       
	OscGpioSetTestLedColor(FALSE, TRUE); /* R, G*/ 	

    /* Register configuration file */
    err = OscCfgRegisterFile(&data.hConfig, CONFIG_FILE_NAME, CONFIG_FILE_SIZE);
    if (err != SUCCESS)
    {
    	OscLog(ERROR, "Cannot access config file.\n");
    	goto cfg_err;
    } 
    

    /* Get perspective setting from config file- */
    configKey.strSection = NULL;
    configKey.strTag = "PER";
   
    strcpy( strCfg.str, "");    
    err = OscCfgGetStr( data.hConfig, 
            &configKey, 
            &strCfg);    

    err |= OscCamPerspectiveStr2Enum( strCfg.str, &data.perspective);  
    if( err != SUCCESS)
    {
        OscLog(WARN, 
                 "%s: No (valid) camera-scene perspective configured (%s). "
                 "Use default (%s).\n",
                 __func__, strCfg.str, OSC_CAM_PERSPECTIVE_DEFAULT);
		data.perspective = OSC_CAM_PERSPECTIVE_DEFAULT;
    }             


    /* Get exposure time setting from configuration. */            
    configKey.strSection = NULL;
    configKey.strTag = "EXP";
    err = OscCfgGetUInt32( data.hConfig,
            &configKey, 
            &data.exposureTime);    
    
    if( err != SUCCESS)
    {
        OscLog(WARN, 
                "%s: No (valid) Exposure Time defined in configuration (%d). "
                "Use default (%d).\n",
                __func__, data.exposureTime, DEFAULT_EXPOSURE_TIME);
        data.exposureTime = DEFAULT_EXPOSURE_TIME;
    }  

#ifdef HAS_CPLD		
    /* Get exposure delay setting from configuration. */            
    configKey.strSection = NULL;
    configKey.strTag = "DEL";
    err = OscCfgGetUInt16Range( data.hConfig,
            &configKey, 
            &exposureDelay, 
            0, 
            FINECLK2CLK_RATIO-1);    
    data.exposureDelay = exposureDelay & 0x00ff;
    if( err != SUCCESS)
    {
        OscLog(WARN, 
                "%s: No (valid) Exposure Delay defined in configuration (%d). "
                "Use default (%d).\n",
                __func__, data.exposureDelay, DEFAULT_EXPOSURE_DELAY);
        data.exposureDelay = DEFAULT_EXPOSURE_DELAY;
    }  
#endif /* HAS_CPLD */	
	
	
#ifdef HAS_CPLD	
	/* Get firmware version */
	err = OscCpldRget(OSC_LGX_FWREV, &data.firmwareRevision);	
	if(err != SUCCESS)
	{
	        OscLog(ERROR, "Cannot read firmware version. (%d)\n", err);
		goto cpld_err;
	}	

	/* Apply exposure delay to CPLD and disable. */
	err = OscCpldRset(OSC_LGX_CLKDELAY, 
		(const uint8)(data.exposureDelay & !OSC_LGX_CLKDELAY_ENABLE));		
	if(err != SUCCESS)
	{
		OscLog(ERROR, "Cannot disable clock-delay in CPLD.\n");
		goto cpld_err;
	}
	/* Set CPLD to synchronous mode. */
	err = OscCpldFset(OSC_LGX_VARCTRL, OSC_LGX_VARCTRL_SYNCOUT, OSC_LGX_VARCTRL_SYNCOUT);	
	if(err != SUCCESS)
	{
		OscLog(ERROR, "Cannot set CPLD to synchronous mode.\n");
		goto cpld_err;
	}
#endif /* HAS_CPLD */	
	
	

	/* Set the camera registers to sane default values. */
	err = OscCamPresetRegs();
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to preset camera registers! (%d)\n", __func__, err);
		goto cam_err;
	}
	
	/* Set up two frame buffers with enough space for the maximum
	 * camera resolution in cached memory. */
	err = OscCamSetFrameBuffer(0, IMAGE_AERA, data.u8FrameBuffers[0], TRUE);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up first frame buffer!\n", __func__);
		goto cam_err;
	}
	err = OscCamSetFrameBuffer(1, IMAGE_AERA, data.u8FrameBuffers[1], TRUE);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up second frame buffer!\n", __func__);
		goto cam_err;
	}
	
	/* Create a double-buffer from the frame buffers initilalized above.*/
	err = OscCamCreateMultiBuffer(2, multiBufferIds);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Unable to set up multi buffer!\n", __func__);
		goto mb_err;
	}
	
	OscCamSetupPerspective( data.perspective);

	/* Make the register file known to the communication protocol. */
	data.comm.pRegFile = regfile;
	data.comm.nRegs = (sizeof(regfile)/sizeof(struct CBP_PARAM));

	/* Init communication sockets. */
	err = Comm_Init(&data.comm);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "Communication initialization failed.\n");
		goto comm_err;		
	}	
	
	return SUCCESS;
	
comm_err:    
cfg_err:
#ifdef HAS_CPLD	
cpld_err:
#endif /* HAS_CPLD */
mb_err:
cam_err:
    OscUnloadDependencies(data.hFramework,
            deps,
            sizeof(deps)/sizeof(struct OSC_DEPENDENCY));
dep_err:
	OscDestroy(&data.hFramework);
	
	return err;
}