Particle Photon and Cloud Function -> Wrong return value

Hi Particle Community,

I’m using multiple Particle Photons with same firmware and same code. Unfortunately one Photon is returning confusing return values for all cloud functions.

Example Code:

    void setup()
    {
        Particle.function("Test", Test);
    }

    int Test(String arg)
    {
        return 0;
    }

Photon A returns “0” (correct)
Photon B returns “537001984” (wrong)

This specific Photon returns this value for every function that is called.

Does anybody know whats the problem with this Photon? Thank you in advance for your help!

1 Like

Have you tried re-flashing it?

Yes, I flashed the correct code multiple times via web ide…

Could you try flashing Tinker and seeing if that works as it should?
What version of system firmware are you on?

I flashed tinker but it is giving me confusing return codes to…

-65536000 or -256000

Firmware is 0.6.3.

1 Like

If you’ve got the CLI installed, could you try updating that, and then issuing “particle update” while in DFU mode?

Update to 7.0.0 solved the Problem.

I don’t understand why this happend to only one device which worked for a year without any problems, but updating seems a good idea anyway.

Thank you for your advice.

2 Likes

Hello,

Good Morning,

We are having a similar issue where our firmware which had been working on Device OS Firmware Version #0.6.3 on Particle Photon P1 boards for about a year, suddenly started to report garbage values for the debug functions being run from the cloud. We checked hardware, bussing and schematics and other possible causes and eventually upgraded to 0.7 to see if that fixed the issue, which it did.

We have observed that 0.6.3 is breaking cloud based particle call functions for some photon P1 chips, but not all of them.

Can support please provide some guidance as to what might be the underlying issue?

Thanks
Amogh

1 Like

For one, we are at 1.4.3 now - 0.7.0 is still ancient and bugs are bugs with little benefit in trying to explain now what went wrong years ago. The change logs of the transition from 0.6.3 to 0.7.0 may already hold that info.

And for your error report it would be better to explicitly state what garbage you receive, what value you expected, how you obtain the return value, whether you have checked via console.particle.io and finally how your function looks that should return the value.

2 Likes

Hello,

Good Morning,

Thanks for such a fast response!

and yes I agree, I can/should/will look into the change logs documents today, and I was just hoping, if someone had an answer for after I am done with my research today…but you are too fast.

Our Aim/Current Program: detects presence of 3 water level sensors and turns on specific bits (Left 3 MSB’s) of a 8 bit number and returns this number as a int.

On the firmware side trying to debug -

  1. We first verified the presence of integer values on I2C bus via logic analyzer, which confirmed.

  2. Then, we looked at console/serial terminal and we see the right values just before they are sent. ( What we expect on cloud/see on terminal window is a value of WaterLevelSensor when it detects sensor 1 is 32, sensor 2 is 64, and sensor 3 is 128, just before the data is packaged for sending.

  • what we see being returned from the exposed cloud functions are big numbers 537001984, 134231873, 134226285.

Thanks

1 Like

If you do that via type casting this may not work (e.g. for Particle.variable()). It would be good to see how that “as a int” is implemented in your code.

When you know your value will only ever feature three significant bits you can always use x & 0x03L to mask out any extra bits.

1 Like