Example #1
0
//******** Robot *************** 
// foreground thread, accepts data from producer
// inputs:  none
// outputs: none
void Robot(void){   
unsigned long data;      // ADC sample, 0 to 1023
unsigned long voltage;   // in mV,      0 to 3000
unsigned long time = 0;      // in 10msec,  0 to 1000 
unsigned long t=0;
unsigned int i;
  //OS_ClearMsTime();
  char string[100];    
  DataLost = 0;          // new run with no lost data 
  OSuart_OutString(UART0_BASE, "Robot running...");
  eFile_Create("Robot");
  eFile_RedirectToFile("Robot");
  OSuart_OutString(UART0_BASE, "time(sec)\tdata(volts)\n\r");
  for(i = 1000; i > 0; i--){
    t++;
    time+=OS_Time()/10000;            // 10ms resolution in this OS
    while(!OS_Fifo_Get(&data));        // 1000 Hz sampling get from producer
    voltage = (300*data)/1024;   // in mV
    sprintf(string, "%0u.%02u\t\t%0u.%03u\n\r",time/100,time%100,voltage/1000,voltage%1000);
    OSuart_OutString(UART0_BASE, string);
  }
  eFile_EndRedirectToFile();
  OSuart_OutString(UART0_BASE, "done.\n\r");										    
  Running = 0;                // robot no longer running
  OS_Kill();
}
Example #2
0
static void _SH_BeginRedirect(void)
{
	int i;
	for(i = 0; i < SH_MAX_ARGS - 1; i++)
	{
		if(_SH_cmd.args[i][0] == '>')
		{
			if((_SH_cmd.args[i][1] == '>' && _SH_cmd.args[i][2]) || !_SH_cmd.args[i+1][0])
			{
				printf("Invalid file redirection\n");
				return;
			}
			if(_SH_cmd.args[i][1] == '\0')
				eFile_Delete(_SH_cmd.args[i+1]);
			eFile_RedirectToFile(_SH_cmd.args[i+1]);
			_SH_Redirected = 1;
			_SH_cmd.args[i][0] = 0;
			return;
		}
	}
}
Example #3
0
//******** Robot *************** 
// foreground thread, accepts data from producer
// inputs:  none
// outputs: none
void Robot(void){   
unsigned long data;      // ADC sample, 0 to 1023
unsigned long voltage;   // in mV,      0 to 3000
unsigned long time;      // in 10msec,  0 to 1000 
unsigned long t=0;
  OS_ClearMsTime();    
  DataLost = 0;          // new run with no lost data 
  printf("Robot running...");
  eFile_RedirectToFile("Robot");
  printf("time(sec)\tdata(volts)\n\r");
  do{
    t++;
    time=OS_MsTime();            // 10ms resolution in this OS
    data = OS_Fifo_Get();        // 1000 Hz sampling get from producer
    voltage = (300*data)/1024;   // in mV
    printf("%0u.%02u\t%0u.%03u\n\r",time/100,time%100,voltage/1000,voltage%1000);
  }
  while(time < 1000);       // change this to mean 10 seconds
  eFile_EndRedirectToFile();
  printf("done.\n\r");
  Running = 0;                // robot no longer running
  OS_Kill();
}
Example #4
0
int process_cmd(char *input){
// static int screen1Line;
// unsigned short adc_val;
// char *strptr;
// char inString1[MAXSTRLEN];
// char inString2[MAXSTRLEN];
// int i;
unsigned char outVal;

  

 
//   1) print performance measures 
//    time-jitter, number of data points lost, number of calculations performed
//    i.e., NumSamples, NumCreated, MaxJitter-MinJitter, DataLost, FilterWork, PIDwork

 if(strncmp(input, "initFileSystem", 14) == 0){
  eFile_Init();
	 return 1;

 }
  
  if(strncmp(input, "formatDisk", 10) == 0){
   //format disk
   if(eFile_Format())  printf("Error: efile_format");
    return 1; 
  }
  
  if(strncmp(input, "printDirectory", 14) == 0){
   //output disk directory
	 UART_OutChar('\n');
	 UART_OutChar('\r');	
   eFile_Directory(UART_OutChar);
   return 1;
  }
  
  if(strncmp(input, "printFile ", 9) == 0){
		UART_OutChar('\n');
		UART_OutChar('\r');
   eFile_ROpen(input + 10);
   while(eFile_ReadNext(&outVal) == 0)
		 { 
			 UART_OutChar(outVal);
		 }
	 eFile_RClose();
   return 1;
  }
  
  if(strncmp(input, "deleteFile ", 11) == 0){
   eFile_Delete(input + 11);
   return 1;
  }
  
  if(strncmp(input, "redirect ", 9) == 0){
    eFile_RedirectToFile(input + 9);
	return 1;
  }   
  
  return 0;
  
  
  

}