We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi to all, The posting summery may be simple, but i am not able to fix the error.
Ok lets come to the problem. I am creating an Index File "Test.txt" on Serial Flash using FILESystem which holds 50,000 datas each one is 2 bytes.
Another File is xx.txt which holds same 50,000 datas each size is 4 bytes. Using following function.
//MAX_USERS =50000 int File_Write_Index (unsigned int no_ofData) { unsigned short count[MAX_USERS], i; FILE *fpt; fpt = fopen ("Test.txt","w"); if (fpt == NULL) { printf ("File not found!. Write Failed\n"); return 0; } else { for(i=0; i<MAX_USERS; i++)//MAX_USERS =50000 count[i] = 0x0000 + i; fwrite (&count[0], 2, MAX_USERS, fpt); fclose (fpt); printf("\r\nWrite Succeed"); return 1; } }
and the second function for 4 bytes data same as first one where i change the size as 4.
fwrite (&count[0], 4, MAX_USERS, fpt);
Actually i made this function for 1000 MAX_USERS. But now i want to make it for 5000.
But Creating buffer for 50000 will increase the RAM size. So i Created a line
unsigned long i=0; unsigned char j; for(k=0; k<MAX_USERS; ) { j=(unsigned char *)&k; fwrite (&j, 2, 1, fpt); } unsigned long j; for(k=0x11111111; k<0x11111111+MAX_USERS; k++) { j=(unsigned char *)&k; fwrite (&j, 2, 1, fpt); } But this one getting much time to read and write the files and even to search just for 1000 MAX_USERS. I am not able to go for more than 1000. The code does not print any errors. But its not working. while debugging it goes to Somewhere which i dont know. So i am here for your help and guidelines. Please tell me how to create a line to move my 50000 no of 2 and 4 bytes of datas into my corresponding files? I am using LPC2388.
We can test the fwrite function that whether it has written the whole data or not, using fseek and SEEK_END.
So fseek in the last location gives you the data which you actually written on it.
Does the manual say that fwrite() returns a result code or that it doesn't?
fwrite returns no of data it has been written.
No need to find out the last location.
fseek (fpt, -(1 * 2), SEEK_END);
so
-(1 *2)
gives you the last two bytes of data which is presented in the last location. Whats that result code actually mean?
The result code means that you don't need to wait until you have run the full loop. After each and every call to fwrite() you will know if it has written the expected amount of data or not.
When writing code, you should always consider checking the return values for functions that do return them - they return a value for a reason.
Yes good point per. Thanks for that. I will follow that..... Thanks per.
Hello,
I'm confused with the 'In-Circuit Debugging' and 'Real-Time Debugging'.
I wish to purchase a development system that allows me to change 'variables' as well as continuous display the values of variables during run-time. Which one that I should refer to, the 'In-Circuit Debugging', or the 'Real-Time Debugging'?
Thanks.
Debuggers don't normally show variable values while the application is running. But there are solutions where a background process continuously walks through the RAM and dumps data, allowing you to see variable values with a random time lag.
Why do you "need" to see your variables updated live when the program runs? Most developers manages just fine without this - or maybe implements their own background interrupt to dump critical information (a subset of the RAM) a number of times/s over JTAG, CAN, UART, SPI, ...
You haven't mentioned what processor you have, but NXP has something they call RealMonitor, that is a software module you integrate into your application and that allows real-time viewing of data.
By the way - start new threads for new questions.
And - of course - never hijack someone elses thread.