Pages: [1] 2   Go Down
Author Topic: Codes working and then failing.  (Read 813 times)
0 Members and 1 Guest are viewing this topic.
Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Folks,

I am working on my alarm clock code - still.

Luckily I am keeping older copies so if problems arise, I can go back to older ones and have something that works.

NOTE:  I am NOT CHANGING ANY ELECTRICAL PART OF THE PROJECT.

I am perplexed.

I have learnt how to do things and "make my life easier" - also so I can release the code for others to use and make it easier for them to change things which are unique to me and allow it to work for them.

So:  Things were going good.

The latest version was working.

I did a few changes and flashed the card.  It hung.  Bugga!

So I went back to the old version.

This worked - originally.

I "debugged" the problem, and flashed it gain, and that time it worked.

So I kept on "building" on that version.

A few steps later, it hung again.

So I went back to my earlier version - which as I said works.

Guess what:  Now it fails too.

About 20 seconds in, up to a few minutes, it hangs.

I now have to go back TWO versions.

I dug around and got a "compare" program.  Went through them and there is very little difference.

A couple of extra lines here and there.  No big code re-structure.  Just a couple of line changes here and there.

So riddle me this:
Why would it be that code which used to work doesn't work now if I haven't done any mechanical changes?

The earlier code (2 revisions back) does work.

THE latest hangs - well that is sort of to be expected as it is still "work in progress".
But my first back up doesn't work, yet before I started this latest effort, it did work.

Thoughts?

Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm guessing the "int" at line 7 should be "unsigned long".

(You're much more likely to get help if you post your code.)

-br
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why would it be that code which used to work doesn't work now if I haven't done any mechanical changes?

It could have a race condition that is temperature dependent.

You could have been just lucky before.

It might rely on uninitialized variables that have different contents this time.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, if someone could PLEASE be bothered looking here is the story:

"afy" works.

afya is one of the "work in progress" but used to and now doesn't.  It hangs anywhere from a few seconds into to a few minutes into running.

afya_old IS the original KNOWN WORKING version.

I luckily had this backed up.

afya_W is the next generation of mods to do and get working.

I am working on another version with a whole lot of code re-written but for now it all has to wait on understanding what is going on with the code now because it used to work and now doesn't.


* V10afy.zip (22.39 KB - downloaded 5 times.)
* V10afya.zip (22.86 KB - downloaded 6 times.)
* V10afya_old.zip (22.89 KB - downloaded 4 times.)
* V10afya_W.zip (22.91 KB - downloaded 7 times.)
Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Other things that were noticed to happen:

(Yeah, shame on me for not really noting which version)

There is a "skip day" function to allow flexy days to be skipped by the alarm.

I was flashing it on said day.

So what happened/s:
When the sketch runs, it looks at the DOW (day of week) and checks it to a value.  If they match, it sets another flag to "Skip the alarm".

As it was on the SKIP DAY, the sketch would run and I would expect the flag to be set.
Some sketches would set it, some would not.
Some would set it then re-set it.

All would also die/hang/crash.

I have studied the { } matching and I can't see any problems.

There is a possible problem that some of my routines return things when the calling routine isn't expecting a value back.
So I tried to tidy that up and put in things like:
dummy = my_routine(1);

but the sketch still died.

Rip me a new one if you must, but I would really find it more useful and educational if I was helped and not anatomically modified.

Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would worry that V10afy_W.zip includes a copy of Arduino.h.  That might cause a conflict with the standard Arduino.h.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

F
I would worry that V10afy_W.zip includes a copy of Arduino.h.  That might cause a conflict with the standard Arduino.h.

They all have a file called Arduino.h so I am missing something.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nothing jumps out as broken.  It is a lot of code.

You don't need to do the dummy=function(…) thing.  The compiler will warn you but it won't break anything.

Your complaints about the problem behavior are very general.  I would start by characterizing what happens when "it dies" a little better using carefully placed Serial.print() statements and maybe toggling an LED or two if that's possible.

-br
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

F
I would worry that V10afy_W.zip includes a copy of Arduino.h.  That might cause a conflict with the standard Arduino.h.
They all have a file called Arduino.h so I am missing something.

WHY do you have a file called Arduino.h?  That's a very important header in the standard Arduino libraries.  If you have one of your own it may cause a conflict.  

I note that your sketch includes:
Code:
#define alarm_EEPROM_storage 100 // Where the alarm is saved.  The first 100 bytes are for other things.
#define EEPROM_user 0           // Where I put my things/

If the format of stuff you store in EEPROM changes from version to version you will have a problem with running different versions in different orders.  Do you have version information in the EEPROM that you check before using any of the data?  Doesn't look like it.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, granted.

The EEPROM data is simply the alarm times, and the list of variables shown/listed/declared shortly after.

There may be new ones added - thus the 100 offset - as the original offset was 10.
I realised that 10 just wasn't enough.

However:  There are no new variables.
As "fanatical" as I may seem with them, I realise that it can become too confusing and I am trying to keep GLOBAL variables to a minimum.

What I was told is that each "routine" should do their thing and return a basic "go/no go" value which tells the bigger program the result.  Nothing too complicated.

But sometimes I can't work out an easier way of doing it than with global names, especially if the same is used by many routines.

It is more the code's structure and functionality which have changed between "releases".


I have sat down and used a compare program to find the differences with the files I use, not the .h and .ccp files, and there are hardly any.

And what I see them as I can't understand how they are causing the crash.


I suspect there are other underlying problems which I haven't seen/found yet.  But I can sit here until the cows come home, I can't see them with the understanding I have.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What you say is true.  You won't solve the problem with the understanding you have.

So go get some more understanding by instrumenting what it's actually doing.  Put some print statements in places you expect to generate periodic output.  What is the last thing it does before it dies?

You haven't even, really, told us what you mean when you say "it dies".  Once you understand that better, by instrumenting your code a bit, you might see the answer.

-br
Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, dying meaning the program just stops running.

I have lines which print the time out the serial port and a wee bit more stuff, but that just stops happening also.

It isn't I want to be spoon fed the solution, but I am stumped to what in the small difference there is between the codes that makes it crash.

As I mentioned, one code works perfectly - as in runs without crashing - but the next version it crashed usually within a few minutes.

I don't know if there is a correlation, but sometimes as soon as I press a button it dies.  Sorry:  crashes.
I can't say if it was caused by the button press or not, but if I reboot it and don't press the button, it doesn't crash then, but does a few seconds/minutes later anyway.
Logged

Central MN, USA
Online Online
Tesla Member
***
Karma: 73
Posts: 7188
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think johnwasser raised a very important question that needs immediate attention. If you had EEPROM_storage as 10 before in past versions and 100 in current versions, then how does your current version know that it should rewrite EEPROM with 100 offset, instead of assuming 100 offset format was already in place and be mistaken. I am sorry I am on my ipad again, no zip files get opened on this tech wonder. Where in your code do you erase EEPROM and rewrite it in 100 offset format?
Logged


Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been researching.

Question:
Has anyone actually tried to compile the codes?


I know this is going to be a bit stupid sounding, but anyway.....
I am not sure what Arduino I have - I am pretty sure it is an "Uno" or copy.

How much memory do these things have?
Will I be told if the program/sketch exceeds the memory limits of the board?

Why I am asking:
The other night I had time to try and find out why the other sketches are failing.

So, starting with the one which does work, I added TWO lines of:
Serial.println("    ");
with text between the "

The sketch failed/died/crashed/hung/what ever.

Removing the lines, it worked.

So when it was compiling, I noticed that it got to 27,xxx of 32,xxx and thought:  Wow that is getting to be  abig sketch.

Then it hit me that maybe there is a memory problem.

Anyone, please?
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2511
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So when it was compiling, I noticed that it got to 27,xxx of 32,xxx and thought:  Wow that is getting to be  abig sketch.
Using that amount of flash probably also point to you running out of RAM.  smiley-sad
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Pages: [1] 2   Go Up
Jump to: