Пример #1
0
//opening two files
int main1(void){
	if(eFile_Init())              diskError("eFile_Init",0); 
  if(eFile_Format())            diskError("eFile_Format",0); 
  eFile_Directory(UART_OutChar);
  eFile_Create("file1");    
  eFile_WOpen("file1");  

  eFile_Create("file2");    
  eFile_WOpen("file2");	
 
 return 0;
}
Пример #2
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();
}
Пример #3
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();
}
Пример #4
0
static int _SH_LoadBin(void)
{
	int i;
	long* l;
	char* c = funcBuff.c;
	if(!_SH_cmd.args[0][0])
	{
		fprintf(stderr, "Usage: %s <filename>\n", _SH_cmd.command);
		return 1;
	}
	funcBuff.f = &_SH_Time;
	l = (long*)(((c[3] << 24) | (c[2] << 16) | (c[1] << 8) | c[0]) - 1);
	memcpy((void*)((int)&funcBuff.c[0]), l, 200);
	if(eFile_WOpen(_SH_cmd.args[0]))

	{
		fprintf(stderr, "Unable to open file for writing\n");
		return 1;
	}
	for(i = 0; i < 200; i++)
	{
		if(eFile_Write(funcBuff.c[i]))
		{
			fprintf(stderr, "Error writing to file\n");
			return 1;
		}
	}
	eFile_WClose();
	return 0;
}
Пример #5
0
static int _SH_Write(void)
{
	int i;
	if(!_SH_cmd.args[0][0])
	{
		fprintf(stderr, "Usage: %s <file_name>\n", _SH_cmd.command);
		return 1;
	}
	memset(_SH_Buffer, 0, 512);
	if(eFile_WOpen(_SH_cmd.args[0]))
	{
		fprintf(stderr, "Unable to open file for writing!\n");
		return 1;
	}
	UART_InString(_SH_Buffer, 512);
	printf("\nWriting to file %s...\n", _SH_cmd.args[0]);
  for(i = 0; i < 512 && _SH_Buffer[i]; i++)
	{
		if(eFile_Write(_SH_Buffer[i]))
		{
			fprintf(stderr, "Error writing to file!\n");
			eFile_WClose();
			return 1;
		}
	}
	eFile_Write('\n');
	eFile_WClose();
	return 0;
}
Пример #6
0
//writing to a file that does not exit
int main3(void){
	if(eFile_Init())              diskError("eFile_Init",0); 
  if(eFile_Format())            diskError("eFile_Format",0); 
  eFile_Directory(UART_OutChar);
	if(eFile_WOpen("f"))          diskError("eFile_WOpen", 0);
	eFile_Write('f');
	
return 0;
 }
Пример #7
0
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) {
    ;
  }
}