This might be programming 102 and I’m missing something obvious as it’s been a little while since i’ve done any serious programming.
I was whipping up a little proof of concept on my photon using the Particle Dev app. I borrowed an arduino sketch for the shield i’m using: https://oceancontrols.com.au/KTA-259.html
Which seemed to run, but get stuck in an infinite loop. I did a little digging and it would appear that the offending loop is:
The Particle reference docs suggests that chars are signed and so I would assume that when i=0 i-- is going to give “-1”. But Serial.print((int)i); seems to suggest it goes to 255.(hence the infinite loop)
The fix is pretty simple - I defined ‘i’ instead as an int/int8_t and it works as designed, but I’d really like to know why it didn’t work the first time?
Have i missed something obvious/generic (although presumably that same code worked fine on the arduino they wrote it for) - or is this an anomaly with the particle dev tool / cloud compiler?