Go Down

Topic: Issue with variable declaration (Read 1 time) previous topic - next topic

brantn

Upon some other testing this appears to only happen after using sdfat getline. If I move the function WebRequest() before MyFileRead() then the variables appear fine. So it appears that something in MyFileRead() is breaking the variable.

PaulS

A couple of suggestions. First, print the values of all 5 arrays after each call to sscanf. Perhaps something is stepping on some part of memory that it shouldn't. Determining that that is happening is the first step in solving the problem. Determining where is the second step.

Second, sscanf() returns a value. Save and print it, instead of discarding. Again, a clue by four might present itself.

wildbill

These are classic symptoms of a buffer overrun. This snippet and others like it are problematic:
Code: [Select]
sscanf(sdbuffer, "dns=%u.%u.%u.%u", &mydns[0], &mydns[1], &mydns[2], &mydns[3]);

Your intent is to treat mydns as an array of ints, but it has type IPAddress, so you're actually treating it as an array of IPAddress. Indexes 1, 2 and 3 don't exist, so that code is stepping all over whatever variables are next in memory, as you observe.

michinyon

I am wondering if the byte should be unsigned byte,   because if it is a signed byte,  the numbers 192 and 168 don't fit.

PaulS

Quote
I am wondering if the byte should be unsigned byte,   because if it is a signed byte,  the numbers 192 and 168 don't fit.

On an Arduino, byte is unsigned.

Go Up