Exemple #1
0
void Interpreter(void){char inchar;

  char inString1[MAXSTRLEN];

 for(;;){
  UART_InString(inString1, MAXSTRLEN);
  
    process_cmd(inString1);
  if(StreamToFile){
		UART_OutChar('\n');
		UART_OutChar('\r');
		
    inchar = UART_InChar();
		UART_OutChar(inchar);
	
   while(inchar != 0x1B){ //while user doesn't press escape
    eFile_Write(inchar);
		inchar = UART_InChar();
		 UART_OutChar(inchar);
   }
    eFile_EndRedirectToFile();
  }
  UART_OutChar(CR);
    UART_OutChar(LF);
 }
  }
Exemple #2
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();
}
Exemple #3
0
int fputc (int ch, FILE *f) {
 if(streamToFile()){
	if(eFile_Write(ch)){ // close file on error
		eFile_EndRedirectToFile(); // cannot write to file
		return 1; // failure
	}
	return 0; // success writing
 }
 // regular UART output
 UART_OutChar(ch);
 return 0;
}
Exemple #4
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();
}
Exemple #5
0
static void _SH_EndRedirect(void)
{
	if(_SH_Redirected)
		eFile_EndRedirectToFile();
	_SH_Redirected = 0;
}