Exemplo n.º 1
0
static int _SH_BinFile(void)
{
	char c;
	int i = 0;
	int (*f)(void);
	void* v;
	
	if(!_SH_cmd.args[0][0])
	{
		fprintf(stderr, "Usage: %s <file_name>\n", _SH_cmd.command);
		return 1;
	}
	if(eFile_ROpen(_SH_cmd.args[0]))
	{
		fprintf(stderr, "Unable to open file for reading!\n");
		eFile_RClose();
		return 1;
	}
	i = 0;
	while(!eFile_ReadNext(&c))
		funcBuff.c[i++] = c;
	eFile_RClose();
	v = (void*)((int)&(funcBuff.c[0]) | 0x1);
	f = (int (*)(void))v;
	f();
	return 0;
}
Exemplo n.º 2
0
void TestFile(void){   int i; char data; 
  printf("\n\rEE345M/EE380L, Lab 5 eFile test\n\r");
  // simple test of eFile
  if(eFile_Init())              diskError("eFile_Init",0); 
  if(eFile_Format())            diskError("eFile_Format",0); 
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  if(eFile_Create("file1"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file1"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    //Serial_OutChar(data);
	UARTPut(data);
  }
  if(eFile_Delete("file1"))     diskError("eFile_Delete",0);
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  printf("Successful test of creating a file\n\r");
  OS_Kill();
}
Exemplo n.º 3
0
void TestFile(void){   int i; char data; DSTATUS result; 
  OSuart_OutString(UART0_BASE, "\n\rEE345M/EE380L, Lab 5 eFile test\n\r");
  // simple test of eFile
  result = eDisk_Init(0);  // initialize disk
  if(result) diskError("eDisk_Init",result);
  if(eFile_Init())              diskError("eFile_Init",0); 
//  if(eFile_Format())            diskError("eFile_Format",0); 
  eFile_Directory();
  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  eFile_Directory();
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    OSuart_OutChar(UART0_BASE, data);
	SysCtlDelay(SysCtlClockGet()/10000);
  }
  eFile_Directory();	
  if(eFile_Create("file1"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file1"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  eFile_Directory();
  if(eFile_Create("file2"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file2"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  eFile_Directory();
/*  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  eFile_Directory();
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    OSuart_OutChar(UART0_BASE, data);
	SysCtlDelay(SysCtlClockGet()/10000);
  }
  eFile_Directory();
  if(eFile_Delete("file1"))     diskError("eFile_Delete",0);
//  eFile_Directory();	 */
  OSuart_OutString(UART0_BASE, "Successful test of creating a file\n\r");
  OS_Kill();
}
Exemplo n.º 4
0
static int _SH_HexDump(void)
{
	char c[4];
	int i, ret = 0;
	if(!_SH_cmd.args[0][0])
	{
		fprintf(stderr, "Usage: %s <filename>\n", _SH_cmd.command);
		return 1;
	}
	if(eFile_ROpen(_SH_cmd.args[0]))
	{
		fprintf(stderr, "Error opening file for reading\n");
		eFile_RClose();
		return 1;
	}
	while(1)
	{
		for(i = 0; i < 4; i++)
		{
			unsigned long l;
			eFile_ReadNext(&c[0]);
			eFile_ReadNext(&c[1]);
			eFile_ReadNext(&c[2]);
			ret = eFile_ReadNext(&c[3]);
			l = ((c[3] << 24) | (c[2] << 16) | (c[1] << 8) | c[0]);
			UART_OutUHex(l);
			printf("\n");
			if(ret || l == 0)
			{
				eFile_RClose();
				printf("\n");
				return 0;
			}
		}
	}
}
Exemplo n.º 5
0
Arquivo: Lab5.c Projeto: oujoshua/445M
void simple_test(void) {
  char c;	
	printf("\r\n\r\n");
	printf("eFile_Init() returned: %d\r\n", eFile_Init());
  printf("eFile_Format() returned: %d\r\n", eFile_Format());
  printf("_eFile_TestFormat() returned: %d\r\n", _eFile_TestFormat());
  printf("eFile_Create() returned: %d\r\n", eFile_Create("test"));
  printf("eFile_WOpen() returned: %d\r\n", eFile_WOpen("test"));
  printf("eFile_Write() returned: %d\r\n", eFile_Write('x'));
  printf("eFile_WClose() returned: %d\r\n", eFile_WClose());
  printf("eFile_ROpen() returned: %d\r\n", eFile_ROpen("test"));
  printf("eFile_ReadNext() returned: %d\r\n", eFile_ReadNext(&c));
	printf("eFile_ReadNext() read: %c\r\n", c);
	printf("eFile_RClose() returned: %d\r\n", eFile_RClose());
  while(1) {
    ;
  }
}
Exemplo n.º 6
0
static int _SH_Read(void)
{
	char c;
	if(!_SH_cmd.args[0][0])
	{
		fprintf(stderr, "Usage: %s <file_name>\n", _SH_cmd.command);
		return 1;
	}
	if(eFile_ROpen(_SH_cmd.args[0]))
	{
		fprintf(stderr, "Error opening file for reading\n");
		eFile_RClose();
		return 1;
	}
	while(!eFile_ReadNext(&c))
		printf("%c", c);
	eFile_RClose();
	printf("\n");
	return 0;
}
Exemplo n.º 7
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;
  
  
  

}