Go Down

Topic: Error in opening existing file in SdFat library? (Read 5900 times) previous topic - next topic

PaulS

Code: [Select]
    if (digitalRead(Input[x]) == HIGH); //read evry input if high continue else break;

    else

      break;

Why write code that needs comments and study?

Code: [Select]
    if (digitalRead(Input[x]) == LOW)
      break;

No comments and no study needed.

There is a Keypad library. Why aren't you using it?

Code: [Select]
void loop() {
  {

{What's} {with} {the} {useless} {curly} {braces} ?

Code: [Select]
    sprintf(filename, "%d.txt", sd_recall_pointer);
sd_recall_pointer is not a pointer. It can contain a value from -32768 to 32767. Even if you assume that it will never be negative, you still need to deal with values up to 5 characters in length. Adding .txt and a NULL to the end means that the array size must be 10 characters or larger. Yours is 7 characters.

There is NO reason to use goto. Try writing your code properly.

yatin

Here is my edited code!
I used sd_recall_pointer but i am taking care of not excedding array limit, currently its value is 26 so resulting in 26.txt as i share on last serial output reply!

Yatin
Hard work is only solution if you are not smart!!

yatin

Ok Here is new error now!
With the great help of fat16lib I able to make my code for remove and rename!
I am attaching those codes below!
now 1st file is of fat16lib which he given me and it runs awfully!
Second is one I tried to mold in my project style along with keypad and its working too!
Now here is the problem, when I put this in my main code it executes the remove operation then execute rename and after rename operation get executed any command other than delay makes my controller reset!( my memory occupied is 80%)
What should I do?
I did check that the instruction get executed completely and then it get reset!
Can anyone could guide me its really weird!
Yatin
Hard work is only solution if you are not smart!!

PaulS

Quote
my memory occupied is 80%
Doesn't that trigger the instability message? Aren't you experiencing instability issues?

Use the F() macro to keep string literals out of SRAM.
  Serial.println(F("I am in setup"));

Code: [Select]
String trial;
Use the delete key to keep Strings out of your code.

yatin

Yes it do flash instability message!
Thats why I posted my occupied memory!
What do u mean by keeping string out?
Also I didnt no about this F, after serial print do you have any documentation about this so I could learn this all!
Yatin
Hard work is only solution if you are not smart!!

PaulS

Quote
Also I didnt no about this F, after serial print do you have any documentation about this so I could learn this all!
https://www.arduino.cc/en/Serial/Print

Quote
What do u mean by keeping string out?
I did not say that. String and string are NOT the same things. C style strings are good. Strings are not.

yatin

Then how to convert String in string as I have some functions where I need String or string!
Yatin
Hard work is only solution if you are not smart!!

PaulS

Quote
Then how to convert String in string as I have some functions where I need String or string!
You don't. There are no intelligent functions that NEED a String. There are stupid ones that declare that they only take a String. They are for lazy people that think that they have terabytes of memory. That doesn't describe you, does it?

Forget that the String class even exists.

yatin

Thanks for the guidance for Serial.print(F());
Here is result of it
Quote
Before
ketch uses 155,426 bytes (61%) of program storage space. Maximum is 253,952 bytes.
Global variables use 6,643 bytes (81%) of dynamic memory, leaving 1,549 bytes for local variables. Maximum is 8,192 bytes.

And now
Sketch uses 156,436 bytes (61%) of program storage space. Maximum is 253,952 bytes.
Global variables use 5,521 bytes (67%) of dynamic memory, leaving 2,671 bytes for local variables. Maximum is 8,192 bytes.
But the most sad part is my controller still reset after rename and now there is no instability warning!
Yatin
Hard work is only solution if you are not smart!!

yatin

Yatin
Hard work is only solution if you are not smart!!

PaulS

Guys please help I am really stucked!
Post your current code that does not use Strings.

yatin

Quote
Post your current code that does not use Strings.
I have attached my code which I made by removing String, but for it I use 'sprintf' many times hope it shouldn't causing any trouble!
And still controller restarts at rename!
Yatin
Hard work is only solution if you are not smart!!

yatin

Guys please, I really need an expert advice as I am unable to solve this problem by my own at all!
Sorry to irritate you guys but really I am badly stuck!
Yatin
Hard work is only solution if you are not smart!!

yatin

Yatin
Hard work is only solution if you are not smart!!

yatin

#29
Jun 09, 2016, 09:15 am Last Edit: Jun 09, 2016, 09:42 am by yatin
Here is some code part where my controller stuck after adding this!
The first code is runnung fine and renaming my files properly! but as soon as I add those lines
Code: [Select]
       sd_import_basic();
            sd_import_graph();
            picture_loop_with_fps(SD_IR);

it stuck again!
the code is in second file.
Could any one can guide me over it?
Yatin
Hard work is only solution if you are not smart!!

Go Up