For starters, I'm very new to Arduino ... I have years of expierience with VB and all its variants ... but I'm finding the C++ish implementation on this thing - less than intuitive; and the debugging interfaces pretty much absent. That said, please forgive me if I'm over looking the obvious at this point, I'm probably just doing something dumb.
So for background, my goal is to control a strip of LEDs and the method of control is simply passing parameters on a URL string to the Arduino. In VB, this whole thing would have taken me about 10 minutes, but with Arduino I know have a solid 20 hours of chasing my tail, and am still no closer to a solution. =(
The overall process and logic seems to be working fine, but for some reason, the arduino blows up when the leds array is accessed in the iteration after the Arduino accepts a new value from the URL. The same array can be accessed many times in countless loops prior to that point (I had added a an extra block of code to activate the change proccess every several iterations and even simulated the value assembly methods to firther test it) ... it's not until after a change is submitted via the URL... which doesn't even access the leds array :~
Two urls relavant:
http:///?a=0 (toggling 0 or 1 turns the leds on or off and does so by accessing the leds array)
http:///?c=255000255 (the 9 digits represent the RGB value to be passed to the leds)
The memset on line 84 is the one that seems to kill things, and if I comment it out and just let the following 'for' loop do the change, without clearing the array first, the Arduino hangs there instead. I've tried every method that I can find to maniplate the datatypes for the incoming client.reads, but I think I've concluded after many hours that they aren't actually the problem ... but that leaves me out of ideas and under qualified.
I know the code is rough, and to be honest its quite a bit uglier now than my first version (that worked just as well) ... right now I just want to get a working starting point and then I'll go back to make it better. Any help to get me over this hurdle would be hugely appreciated though. The sketch is attached for anyone willing to take a look ...
That is a pointer which so far doesn't point to anything useful. Doing a memset is likely to clobber low memory. How about doing it like the example code above?
I do think that you're on to something though ... I tried commenting out the line that threw the compile error (as I couldn't find a comperable line in the example provided for the next version that I now see available in dev), and the Arduino hung in the exact same way, only this time on the very first iteration.
Well that fixed the first iteration issue .. but it still hangs on a submitted change.
I think what has me so perplexed is that the exact same lines work on other iterations without issue ... its only once a seemingly unrelated event (the new color codes are recieved) that things fall apart. And they fall apart before the new codes even start to get applied.
I found something ... but I don't see how it's related (although it is). When a new color is received, it's stored in the zero index of another array, and all the previous values shift up for history. If I disable the shift on the 'refs' array, the 'led' array stops hanging the system.
If I un-comment the line inside the for, everything dies again. I'm unclear why this is bad (I figure it must be) ... Is there a better way to accomplish this?
After playing with this some more, your memory allocation suggestion does actually appear to have been the root cause ... I seemed to have an unrelated issue that masked the fact that it probably worked the first time I tried it. Still getting used to this thing
Thank you for your help ... I can finally move on to the next piece of the puzzle.