int main(int argn, char** argv){ init_xenomai(); // rt_printf("initialized.\n"); // rt_printf("starting up...\n"); startup(); rt_printf("waiting Ctrl+C\n"); wait_for_ctrl_c(); rt_printf("closing...\n"); cleanup(); return 0; }
int main(int argc, char* argv[]) { // code to set things to run xenomai init_xenomai(); //startup code startup(); printf("pause\n"); pause(); }
int main(int argc, char* argv[]) { printf("\nType CTRL-C to end this program\n\n" ); // code to set things to run xenomai init_xenomai(); //startup code startup(); pause(); }
int main(int argc, char* argv[]) { printf("\n Press Ctrl+c to quit\n\n"); init_xenomai(); startup(); wait_for_ctrl_c(); cleanup(); printf("\n Ending program!\n\n"); }
int main(int argc, char* argv[]) { printf("\nType CTRL-C to end this program\n\n" ); // code to set things to run xenomai init_xenomai(); setupLPT1(); //startup code startup(); // wait for CTRL-c is typed to end the program pause(); tearDownLPT1(); }
int main(int argc, char* argv[]) { printf("\n Press Ctrl+c to quit\n\n"); double timeD; time_t begin, end; init_xenomai(); startup(); begin = time(NULL); while(timeD < 3){ end = time(NULL); timeD = (end - begin); } //wait_for_ctrl_c(); flagStop = 1; cleanup(); printf("\n Ending program!\n\n"); }
/** * 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; }