Beispiel #1
0
// Convert wait() status into name
char *statusName(int state)
{
    if (WIFEXITED(((state))))
    {
	static char buffer[256];

	sprintf(buffer, "Exit %d", (int)WEXITSTATUS(((state))));
	return buffer;
    }
    else if (WIFSIGNALED(((state))))
        return sigName(WTERMSIG(((state))));
    else if (WIFSTOPPED(((state))))
        return sigName(WSTOPSIG(((state))));

    return (char *)"Unknown state change";
}
Beispiel #2
0
/**
 * This function is called when the control program is loaded to zenom.
 * Use this function to register control parameters, to register log variables
 * and to initialize control parameters.
 *
 * @return Return non-zero to indicate an error.
 */
int ZenomMatlab::initialize()
{
    
    int paramIdx, sigIdx;
    int nBlockParams, nSignals;
    const char* status;
    
    // İsmi gözükmeyen parametrelerin sayısını tutar.
    unknown_param_counter = 0;

    /* Here is where Q8 dirver is  loaded to kernel space */
     
    //system(STR(sudo insmod DQ8));
    fd = rt_dev_open(DEV_NAME, O_RDWR);

    if(fd < 0)
        fprintf(stderr, "target:Q8 device open error!\n");
    
    
    init_xenomai();

    rtM = MODEL();

    if (rtmGetErrorStatus(rtM) != NULL) {
        (void)fprintf(stderr,"Error during model registration: %s\n",
                      rtmGetErrorStatus(rtM));
        exit(EXIT_FAILURE);
    }
    
    MdlInitializeSizes();
    MdlInitializeSampleTimes();

    status = rt_SimInitTimingEngine(rtmGetNumSampleTimes(rtM),
                                    rtmGetStepSize(rtM),
                                    rtmGetSampleTimePtr(rtM),
                                    rtmGetOffsetTimePtr(rtM),
                                    rtmGetSampleHitPtr(rtM),
                                    rtmGetSampleTimeTaskIDPtr(rtM),
                                    rtmGetTStart(rtM),
                                    &rtmGetSimTimeStep(rtM),
                                    &rtmGetTimingData(rtM));


    if (status != NULL) {
        (void)fprintf(stderr, "Failed to initialize sample time engine: %s\n", status);
        exit(EXIT_FAILURE);
    }

    rt_CreateIntegrationData(rtM);

    mmi = &(rtmGetDataMapInfo(rtM).mmi);

    if (mmi!=NULL){
        //exception here 
    }    

    bp = rtwCAPI_GetBlockParameters(mmi);
    sig = rtwCAPI_GetSignals(mmi);

    nBlockParams = rtwCAPI_GetNumBlockParameters(mmi);
    nSignals = rtwCAPI_GetNumSignals(mmi);

    xrtpi = new XrtTargetParamInfo[nBlockParams];
    xtsi = new XrtTargetSignalInfo[nSignals];

    /** Get parameter and register */      
    
    Xrt_GetParameterInfo(mmi);
    Xrt_GetSignalInfo(mmi);

    /**************** ZENOM PART  ***************/
    
    for(paramIdx = 0; paramIdx < rtwCAPI_GetNumBlockParameters(mmi); paramIdx++){
        
        std::string paramName(xrtpi[paramIdx].paramName);
        std::string blockName(xrtpi[paramIdx].blockName);

        if(paramName.empty()){
            paramName = std::string("unknownBlock");
        }
            

        for (std::size_t found = paramName.find_first_of(" "); 
            found != std::string::npos ; 
            found = paramName.find_first_of(" "))
        {
            paramName.erase (found);
        }

        for (std::size_t found = blockName.find_first_of(" "); 
            found != std::string::npos ; 
            found = blockName.find_first_of(" "))
        {
            blockName.erase (found);
        }

        paramName = blockName + "-" + paramName;
        
        registerControlVariable( xrtpi[paramIdx].dataValue, 
                                 paramName, 
                                 xrtpi[paramIdx].numRows, 
                                 xrtpi[paramIdx].numColumns );
    }

    for (sigIdx = 0; sigIdx < rtwCAPI_GetNumSignals(mmi); ++sigIdx){

        std::string sigName(xtsi[sigIdx].signalName);  

        if(sigName.empty()){
            sigName = std::string("unknownSignal");
            sigName += unknown_param_counter;
        }

        for (std::size_t found = sigName.find_first_of(" "); 
            found != std::string::npos ; 
            found = sigName.find_first_of(" "))
        {
            sigName.erase (found);
        }

        registerLogVariable(xtsi[sigIdx].dataValue,
                        sigName,
                        xtsi[sigIdx].numRows,
                        xtsi[sigIdx].numColumns);
    }

    setFrequency( (double)rtmGetStepSize(rtM) );
    setDuration ( (double)rtmGetTFinal(rtM) );

    fprintf(stderr, "init done!");
    
    return 0;
}
Beispiel #3
0
bool CZipReader::scanLocalHeader2()
{
	c8 buf [ 128 ];
	c8 *c;

	File->read( &temp.header.Sig, 4 );

#ifdef __BIG_ENDIAN__
	os::Byteswap::byteswap(temp.header.Sig);
#endif

	sprintf ( buf, "sig: %08x,%s,", temp.header.Sig, sigName ( temp.header.Sig ) );
	OutputDebugStringA ( buf );

	// Local File Header
	if ( temp.header.Sig == 0x04034b50 )
	{
		File->read( &temp.header.VersionToExtract, sizeof( temp.header ) - 4 );

		temp.zipFileName.reserve( temp.header.FilenameLength+2);
		c = (c8*) temp.zipFileName.c_str();
		File->read( c, temp.header.FilenameLength);
		c [ temp.header.FilenameLength ] = 0;
		temp.zipFileName.verify();

		sprintf ( buf, "%d,'%s'\n", temp.header.CompressionMethod, c );
		OutputDebugStringA ( buf );

		if (temp.header.ExtraFieldLength)
		{
			File->seek( temp.header.ExtraFieldLength, true);
		}

		if (temp.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRIPTOR)
		{
			// read data descriptor
			File->seek(sizeof(SZIPFileDataDescriptor), true );
		}

		// compressed data
		temp.fileDataPosition = File->getPos();
		File->seek( temp.header.DataDescriptor.CompressedSize, true);
		FileList.push_back( temp );
		return true;
	}

	// Central directory structure
	if ( temp.header.Sig == 0x04034b50 )
	{
		//SZIPFileCentralDirFileHeader h;
		//File->read( &h, sizeof( h ) - 4 );
		return true;
	}

	// End of central dir
	if ( temp.header.Sig == 0x06054b50 )
	{
		return true;
	}

	// eof
	if ( temp.header.Sig == 0x02014b50 )
	{
		return false;
	}

	return false;
}