Пример #1
0
void parseUsart()
{
	const char delimiters[] = " ";

	char *param;
	char *value;
	if(strstr(recvbuffer, "STREAM")!=NULL)
	{
		strtok(recvbuffer,delimiters); //first param
		value = strtok(NULL,delimiters);
		if(strstr(value,"START"))
		{
			serial_stream_enabled=1;
			usart_send_stream();
		}
		else
			serial_stream_enabled=0;
	}
	if(strstr(recvbuffer, "SET")!=NULL)
	{
	  strtok(recvbuffer,delimiters); //first param
	  param = strtok(NULL,delimiters);
	  value = strtok(NULL,delimiters);
	  if(param!=NULL && value!=NULL)
		  setConfig(param,atoi(value));

	}
	if(strstr(recvbuffer, "SAVE")!=NULL)
	{
		usart_sendStr("Saving:\n\r");
		printConfiguration();
		writeConfig(s);
		usart_sendStr("SAVE OK\n\r");
	}
	if(strstr(recvbuffer, "GET")!=NULL)
	{
		//getConfig();
		printConfiguration();
	}


	if(recvctr < 3)
	{

		uint16_t len =sprintf(txbuffer, "Count: %d, Hall: %d, error: %d, max_error: %d\n\r",(int)encoder_count, (int)hallpos, (int)position_error, (int)max_error);
		max_error=0;
		usart_startDMA(len);


	}
}
Пример #2
0
void SerialImpl::setConfiguration (const char *pszDevName, const int iBaudRate)
{
	if (NULL != pszDevName) {
		m_strDevName	= pszDevName;
	}

	m_iBaudRate	= iBaudRate;

	printConfiguration ();
}
Пример #3
0
int main(int argc, char** argv) {

    struct config* config = parseArgs(argc, argv);
    printConfiguration(config);

    setupLoad(config);
    createWorkers(config);
    statsLoop(config);
    return 0;

}//End main()
Пример #4
0
// intended constructor
Serializer::Serializer() : TransactionController() {

  /* All Transaction Controllers Should Execute the following code */
  /* [Begin] */
        
  m_type = Transaction_Controller_Serializer;  // Substitute proper enum here (define in TransactionControl.h)
  printConfiguration(cout);
  
  /* [End] */
  
}
Пример #5
0
int main(int argc, char* argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <m> [<numTrials> <alpha> <epsilon>]\n", argv[0]);
    fprintf(stderr, "  m is the problem size\n");
    fprintf(stderr, "  numTrials is the number of trials to run\n");
    fprintf(stderr, "  alpha is the scalar multiplier\n");
    fprintf(stderr, "  epsilon is the tolerance for verification\n");
    exit(0);
  }

  m = atoi(argv[1]);
  if (argc >= 3) {
    numTrials = atoi(argv[2]);
    if (argc >= 4) {
      alpha = atof(argv[3]);
      if (argc >= 5) {
        epsilon = atof(argv[4]);
      }
    }
  }
  

  printConfiguration();
  elemType* const __restrict A = (elemType*)malloc(m*sizeof(elemType));
  elemType* const __restrict B = (elemType*)malloc(m*sizeof(elemType));
  elemType* const __restrict C = (elemType*)malloc(m*sizeof(elemType));
  
  initVectors(B, C);

  double execTime[numTrials];

  int trial;
  for (trial=0; trial<numTrials; trial++) {
    double startTime = getCurrentTime();

    int j;
    double* __restrict APtr = A;
    const double* __restrict BPtr = B;
    const double* __restrict CPtr = C;
    for (j=0; j<m; j++) {
      *(APtr++) = *(BPtr++) + alpha * *(CPtr++);
    }
    
    execTime[trial] = getCurrentTime() - startTime;
  }

  int validAnswer = verifyResults(A, B, C);
  printResults(validAnswer, execTime);

  return 0;
}
Пример #6
0
 /*! Prints the configuration of log streams and log output streams.
  *  \deprecated Obsolete coding style.
  */
 void LoggingManager::PrintConfiguration() const
 {
   printConfiguration();
 }
Пример #7
0
static void doPrintConfiguration(void) {
	printConfiguration(engineConfiguration, engineConfiguration2);
}
Пример #8
0
static void doPrintConfiguration(Engine *engine) {
	printConfiguration(engineConfiguration);
}
Пример #9
0
int
main()
{


	motor_running=0;
	updateCtr=0;
	dir=1;

	FLASH_Unlock();
	getConfig();
	FLASH_Lock();
	initUSART(s.usart_baud);
	printConfiguration();

	initPWM();
	initADC();
	if( s.commutationMethod == commutationMethod_HALL)
	{
		initHALL();
	}

	if(s.inputMethod == inputMethod_stepDir)
	{
		initStepDirInput();
	}
	else if (s.inputMethod == inputMethod_pwmVelocity)
	{
		initPWMInput();
	}
	if(s.inputMethod == inputMethod_stepDir || s.commutationMethod == commutationMethod_Encoder)
	{
		initEncoder();
	}

	if(s.inputMethod == inputMethod_stepDir)
	{
		initPid();
	}
	initLeds();
//	errorInCommutation=1;
	uint8_t ena;
	//check if ENA is on already at start. If it is, start motor.
#if ENA_POLARITY == 1
		ena = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5);
#else
		ena = (~(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5)))&1;
#endif
	if(ena)
	{
		pwm_motorStart();
		ENABLE_LED_ON;
	}
	//two different types of main loops depending on commutation method
	if(s.commutationMethod == commutationMethod_Encoder)
	{
		while (1)
		{


			  getEncoderCount();
			  if(encoder_commutation_pos != encoder_commutation_table[encoder_shaft_pos])
			  {
				  //usart_sendStr("commutation to ");
				  //usart_sendChar(encoder_commutation_table[encoder_shaft_pos]+48);
				  encoder_commutation_pos = encoder_commutation_table[encoder_shaft_pos];
				  pwm_Commute(encoder_commutation_pos);
				//  usart_sendStr("\n\r");
			  }
		}

    }
	else
	{
		while(1)
		{

		}
	}

}
Пример #10
0
 /*! Prints the list of connected log output streams.
  *  \deprecated Obsolete coding style.
  */
 void LogStream::PrintConfiguration() const
 {
   printConfiguration();
 }
Пример #11
0
// Initialize GLUT & OpenSG and start the cluster server
int main(int argc,char **argv)
{
#ifdef WIN32
	OSG::preloadSharedObject("OSGFileIO");
    OSG::preloadSharedObject("OSGImageFileIO");
	OSG::preloadSharedObject("OSGEffectGroups");
#endif
	ChangeList::setReadWriteDefault();
    osgInit(argc, argv);
	
	std::string name("ClusterServer");
    std::string connectionType("StreamSock");
    std::string address("127.0.0.1");
	bool fullscreen = true;
	bool always_on_top = false;
	bool stereo = false;
	WindowGeometry geometry = {0,0,500,500};

	if (!parseCmdLineArgs(argc, argv, name, connectionType, address, geometry, fullscreen, always_on_top, stereo))
		return 0;

	printConfiguration(name, address, connectionType, stereo, fullscreen, always_on_top);

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | (stereo ? GLUT_STEREO : 0));
	glutInitWindowPosition(geometry.x, geometry.y);
	glutInitWindowSize(geometry.w, geometry.h);
    int winid = glutCreateWindow(name.c_str());
    if(fullscreen) 
	{
        glutFullScreen();
    }
	if (always_on_top)
	{
		setAlwaysOnTop(name);
	}
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);
    glutSetCursor(GLUT_CURSOR_NONE);

    ract = RenderAction::create();

    window     = GLUTWindow::create();
	OSGCompat::setGlutId(window, winid);
    window->init();

	bool failed = false;
	do
	{
		try 
		{
			delete server;
			server = new ClusterServer(window, name, connectionType, address);
			server->start();
			failed = false;
		}
		catch (OSG_STDEXCEPTION_NAMESPACE::exception& e)
		{
			SLOG << "ERROR: " << e.what() << endLog;
			SLOG << "Attempting to restart ClusterServer..." << endLog;
			failed = true;
		}
	} while (failed);

    glutMainLoop();

    return 0;
}