P2 Serial Differences?

Calls to Serial.printf are quite different timing with the same application code between Argon and p2. I looked in the documentation for clues as to difference without luck. Can you point me in the right direction? The p2 code 'appears' to be slower (20x). Maybe the blocking behavior is different?

Detail:
example print statement:

unsigned long then = micros();
      double cTime;
      if ( sp.tweak_test() ) cTime = double(now)/1000.;
      else cTime = control_time;
      sprintf(cp.buffer, "unit_sel,%13.3f, %d, %d,  %10.7f,  %7.5f,%7.5f,%7.5f,%7.5f,%7.5f,  %7.5f,%7.5f, ",
          cTime, reset, sp.ib_select(),
          Flt->cc_diff(),
          ib_amp_hdwe(), ib_noa_hdwe(), ib_amp_model(), ib_noa_model(), ib_model(), 
          Flt->ib_diff(), Flt->ib_diff_f());
      Serial.print(cp.buffer);
      sprintf(cp.buffer, "  %7.5f,%7.5f,%7.5f,  %d, %7.5f,%7.5f, %d, %7.5f,  %d, %7.5f,%7.5f, %d, %7.5f,  %5.2f,%5.2f, %d, %5.2f, ",
          Mon->voc_soc(), Flt->e_wrap(), Flt->e_wrap_filt(),
          Flt->ib_sel_stat(), ib_hdwe(), ib_hdwe_model(), sp.mod_ib(), ib(),
          Flt->vb_sel_stat(), vb_hdwe(), vb_model(), sp.mod_vb(), vb(),
          Tb_hdwe, Tb, sp.mod_tb(), Tb_filt);
      Serial.print(cp.buffer);
      sprintf(cp.buffer, "%d, %d, %7.3f, %7.3f, %d, %7.3f,%7.3f,%7.3f,%7.3f,%7.3f,%d,",
          Flt->fltw(), Flt->falw(), Flt->ib_rate(), Flt->ib_quiet(), Flt->tb_sel_status(),
          Flt->cc_diff_thr(), Flt->ewhi_thr(), Flt->ewlo_thr(), Flt->ib_diff_thr(), Flt->ib_quiet_thr(), Flt->preserving());
      Serial.print(cp.buffer);
      Serial.printlnf("%c,", '\0');
Serial.printf("print_sel %10.6f\n", float(micros() - then)/1.e6);

result:
argon: print_sel 0.003500
p2 : print_sel 0.071000

1 Like

Yes, the P2 USB serial is slower than nRF52 and STM32. Buffering the output can help in some cases.

More information in this post:

I've just gotten word that USB serial speed on the P2/Photon 2 will be fixed in the next release, which will be 5.4.1 or 5.5.0.

1 Like

Awesome. Not a killer in the meantime.

I confirm it's improved and working great in 5.5.0. It didn't make it to 5.4.1.

I'm also enjoying the crude and effective Backup RAM feature (save every 10 s).

My firmware is capable of running at 2 ms update rate on Photon 2 with the o/s improvements. Though I run it at 100 ms.

1 Like

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