stranger things

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guys, I had a function that when I edited the system would fail, nothing wrong with the code and the error was unrelated to the function.  But when I copied and renamed the function the error was gone.

 

the question is why?

 

 

EDITED: came back again after a while!  bummer

This topic has a solution.
Last Edited: Fri. Nov 8, 2019 - 05:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been caught by something like that a few times in the last 5 years. I was never able to identify the cause with any certainty but the symptoms generally seemed to point at a hidden character (a control character, perhaps, or a character with an ASCII value above 127). The editor that I use (TextWrangler on MacOS) is quite happy to accept such characters and you can see them only if you jump through special hoops. 

 

Your mileage may vary!

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

'nothing wrong' with the code! If only that could be universally true. 'Tis a complex beast we are trying to tame.

 

Invariably if we fudge a fix without determining the root cause, it is bound to come back and bite us. If the compiler is suspicious of something, it will tell us - sometimes we don't listen. Compare good/bad hex/bin files and work backwards. If the output files are different, that suggests 'something' is NQR (not quite right).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

going to just rewrite the function without coping the code.  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Compilers are not perfect, unlike the writers of the target code. cheeky

 

I have found that sometimes the simple placement of the the errant code in a different position in the file can resolve the "problem".

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If that happens, it suggests that the problem is related to memory layout.

 

Something like a buffer overrun - which might "happen" not to break anything in one location, but will trash something important in another.

 

Or an errant pointer.

 

Or uninitialised variables.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the function in question have unit tests ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
when I edited the system would fail

So what, exactly, did you "edit" ?

 

Fianawarrior wrote:
nothing wrong with the code

There must have been something wrong!

 

See #6.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As expected, I re-done the function and the error disappeared.

 

lovely

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Fianawarrior wrote:
As expected, I re-done the function and the error disappeared.
Not a great approach to software engineering - have another go and keep your fingers crossed !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
lovely

Not really!

 

As Kartman wrote:
Invariably if we fudge a fix without determining the root cause, it is bound to come back and bite us.

 

You have a bug! 

 

Sometimes its symptoms are not obvious, but it is still a bug!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

that's what you call debugging lads. if at first you don't succeed try and try again.  Or, as they say, doing the same thing over and over again and expecting different results!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
that's what you call debugging lads.

No.

 

That's what you call hacking - in the pejorative sense of "quick, dirty, nasty programming"

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
it is bound to come back and bite us

Right here: https://www.avrfreaks.net/forum/... !

 

frown

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, found the problem, it was not my code but the sdcard!

 

the problem seemed strange, sometimes a binary would run other times it wouldn't. Strange!

 

 

Thanks for the input guys.

Last Edited: Fri. Nov 8, 2019 - 02:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmm ...

 

A dodgy SD card should not crash your system!

 

Sounds like you still have some work to do to "harden" your system ...

 

Handling stuff when everything goes right is often only ~ 10% of the task - it's gracefully handling the errors & corner cases that distinguished a "quick hack" from good, solid code.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

your quite correct, but when I insert it into windows and run disk manager the sdcard wont allow me to change or delete the volume.  it displays an error message!