bool BaseFile::ReadData(char *pData, uint Length, qint64 DWpos) { bool mReadSuccessFlag = false; uint mRead = 0; QFile ReadTestFile(FilePathName); if(!ReadTestFile.open(QIODevice::ReadWrite)) { qDebug()<<"Read file fail!"; return mReadSuccessFlag; } ReadTestFile.seek(DWpos); mRead=ReadTestFile.read(pData,Length); if(mRead == Length) mReadSuccessFlag = true; ReadTestFile.close(); return mReadSuccessFlag; }
int main(void) { static unsigned char buffer[BUFFER_SIZE]; unsigned short i; unsigned char timeout = 3; RTCTime local_time; SystemInit(); // IODIR0 |= (P0_15|P0_16|P0_17); // some outputs for debugging and measures //P0_16 ReadSector() in mmc_spi.c //P0_17 enc28j60 write packet //P0_15 general purpose, BE AWARE ! // uart1Init(B38400, UART_8N1, UART_FIFO_8); // setup the UART uart1Init(B115200, UART_8N1, UART_FIFO_8); // setup the UART rprintf_devopen( uart1_sendchar ); /* init rprintf */ VICIntEnClear = 0xFFFFFFFF; VICIntSelect = 0x00000000; RTCInit(); /* current date 05.08.2007 20:45:00*/ local_time.RTC_Sec = 0; local_time.RTC_Min = 45; local_time.RTC_Hour = 20; local_time.RTC_Mday = 5; local_time.RTC_Wday = 3; // My monday has 0 local_time.RTC_Yday = 1; local_time.RTC_Mon = 8; local_time.RTC_Year = 2007; RTCSetTime( local_time ); /* Set local time */ // RTCStart(); init_timer(); enableIRQ(); printf("Holgi's ARM7 LPC213x MultiFAT Speed Test\n\r"); MMC_IO_Init(); enc28j60_io_init(); // You don't need this ! It's for my board only. while (GetDriveInformation() != F_OK && timeout--) { printf ("MMC/SD-Card not found !\n\r"); HaltCPU(); } ShowDOSConfig(); // show selected DOS details from dosdefs.h /* // test time measurement StartTimer(); timer_value = SetDelay10ms(1000); // delay 10 seconds while(CheckDelay10ms(timer_value)==0); StopTimer(); // stop measure and show results // result is 2MB in 10s -> 200kB/s // end test time measurement */ printf("\nTest directory functions\n"); Chdir("dir1"); Remove("dir4"); Chdir("/"); // Back to root Remove("dir1"); Mkdir("dir1"); Chdir("dir1"); Mkdir("dir2"); Mkdir("dir3"); Rename("dir3","dir4"); Remove("dir2"); // You should have now: // dir1/dir4 Chdir("/"); // Back to root printf("\nDeleting files\n"); Remove("01.bin"); //Remove last data Remove("02.bin"); Remove("04.bin"); Remove("08.bin"); Remove("16.bin"); Remove("32.bin"); Remove("64.bin"); Remove("77.bin"); Remove("128.bin"); Remove("MAX.bin"); //Fill the test buffer for(i=0; i<BUFFER_SIZE; i++) buffer[i]=(unsigned char)(i); printf("\nStart writing files\n"); WriteTestFile("01.bin",buffer,1); WriteTestFile("02.bin",buffer,2); WriteTestFile("04.bin",buffer,4); WriteTestFile("08.bin",buffer,8); WriteTestFile("16.bin",buffer,16); WriteTestFile("32.bin",buffer,32); WriteTestFile("64.bin",buffer,64); WriteTestFile("77.bin",buffer,77); WriteTestFile("128.bin",buffer,128); WriteTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("\nStart reading files\n"); ReadTestFile("01.bin",buffer,1); ReadTestFile("02.bin",buffer,2); ReadTestFile("04.bin",buffer,4); ReadTestFile("08.bin",buffer,8); ReadTestFile("16.bin",buffer,16); ReadTestFile("32.bin",buffer,32); ReadTestFile("64.bin",buffer,64); ReadTestFile("77.bin",buffer,77); ReadTestFile("128.bin",buffer,128); ReadTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("\nVerifying files\n"); VerifyTestFile("32.bin",buffer,32); VerifyTestFile("64.bin",buffer,64); VerifyTestFile("77.bin",buffer,77); VerifyTestFile("128.bin",buffer,128); VerifyTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("Test done.\n"); // test if RTC is running local_time=RTCGetTime(); printf("%02u:%02u:%02u %02u.%02u.%04u\n\r",local_time.RTC_Hour,local_time.RTC_Min,local_time.RTC_Sec ,local_time.RTC_Mday,local_time.RTC_Mon,local_time.RTC_Year ); while(1) { /* if(CheckDelay10ms(timer_value)) { timer_value = SetDelay10ms(1000); // delay 10 seconds // test if RTC is running local_time=RTCGetTime(); printf("%02u:%02u:%02u %02u.%02u.%04u\n\r",local_time.RTC_Hour,local_time.RTC_Min,local_time.RTC_Sec ,local_time.RTC_Mday,local_time.RTC_Mon,local_time.RTC_Year ); } */ } return(0); }