Can't Call Function, Can Read Variable

An app that has been running fine for months is behaving oddly tonight. I can read particle variables, but I can’t call the functions. I’ve tried both through my iOS app, and through the CLI. I get a timed out message when I do a function call from the CLI.

I don’t know if this is related to the fast blinking cyan problem that I’m also experiencing tonight (but the Photon in question is obviously online and connected to the cloud since I can read variables, and it is breathing cyan).

Breathing cyan does not tell anything about the quality of the connection. You can keep breathing cyan, but still be blocking for up to 10sec. And the difference between variable retrieval and function call is that variables are read and submitted by the system thread while function callbacks have to run in the user thread.

Well, that explains why one can work while the other doesn’t. However, what’s baffling me is that everything else is still working. The app is a Photon enhanced cat door that’s activated by pressure plates. In loop, the plates are read (analog reads), the values are looked at to see if they’re different from the running average, and then it goes to a state machine to determine whether or not to open or close the door. All of that is still working, and has been working for months. I’m also sending data to ThingSpeak every 15 seconds (from inside loop), and that is also still working.

So, I don’t think the problem is blocking code. I haven’t tried resetting the Photon yet because I was trying to think of anything else I can do to determine the cause of the failure before I do that. Given that this is C, I’m thinking that the most likely cause is that I’m exceeding the bounds of one of the char arrays, and overwriting something I shouldn’t.

I was right (I hope) in my suspicions about a char array overflow. I have a circular buffer (4 minutes worth of readings) that keeps the last 1200 readings of my pressure plate for diagnostic purposes. If the door stays open for 45 seconds, I report an error (push notification through Pushover), stop the data collection, and convert it to a char array. The intent was to read this array via TCP from my computer, but if it happens twice before I read the first one (which also zeros out the array), then I fail to clear the array before writing data to it again. I’ve now corrected that.

Anyway, thanks for pointing out the difference between variables and function calls, that got me thinking that something was wrong in my code, not that something was wonky in the cloud.

2 Likes