Photon taking longer to flash OTA

Every time I want to reflash my photon it starts blinking purple but then takes about a minute to respond, sometimes just going back to its previous routine. It usually took about 5-10 seconds. Same wifi and everything else.

im using:

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);

could that be a problem?

there is a small part of my code that takes about 20 seconds running “blindly” (using delays and such), each second im executing:
Particle.process();
since I was told to run it as often as possible.

is this related at all?

thanks

Impossible to say without seeing your code. You’re using SYSTEM_MODE(MANIAL) and you say you have a long running process in your loop. We would need to see your code to tell you what’s going on.

Flashing magenta during OTA flash is usually an indication that its updating the device OS, unless its breathing magenta then it’s safe mode.

the code being run is this.
sorry for the bad indentation:

  for(int i=0;i<multiples;i++){   //20 times
      if (publishnow==0){i=multiples;} .   
         long timer1=millis();
    int flagflow = 0;
    pulses=0;
   
    do{
        if(interruptflag==1){timer1=millis()+TiempoLectura;}
        if(digitalRead(flowpin) == LOW){
          if(flagflow == 0)
            {
              pulses++;     //count +1 every FALLING
              flagflow=1;
             
              Serial.print((int)pulses); Serial.print(" ");    
            }
        }
        else if(digitalRead(flowpin) == HIGH) {flagflow=0;}
      }  
    while (millis() - timer1 < 1000 );    //do it for 1000ms
    
    if(WiFi.ready()){         //this is kind of irrelevant
        if(Particle.connected){
            Particle.process();
        }
    }

    Serial.print(flow); Serial.println(" ");
    

the rest is code that runs very quickly

the terminal window shows the prints and it never gets updated while the 20 repetitions happen, only afterwards. My question is, when is the code updated? shouldnt the photon interrupt whatever it is doing and update the code immediately?
One minute seems like not much but it gets boring after a while.

Thanks

Not when running SYSTEM_THREAD(ENABLED).
The downloading of the application binary will be done in parallel. Only once the entire module is downloaded the actual flashing can kick in and that's when your running application will be stopped.

And as @mjones already mentioned you may also see a device OS update happening which will take considerably longer as it needs to update multiple modules with a reset/reconnect cycle for each.

You should put the Particle.process() into that do ... while() loop.

1 Like

ok, thanks.

The Particle.process() is executed every second. If I put it inside the while loop, it will then be executed hundreds of times per second. Is that ok?

Particle.process() is a blocking call, and blocks for a few milliseconds.

I just dont want this to interfere with my readings.

It's not just OK but intended.

But if it's that important to catch all edges it's probable better to use interrupts for your pulse counting.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.