microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
726 stars 638 forks source link

web USB reset of micro:bit upsets data logging programs #4681

Closed jaustin closed 1 year ago

jaustin commented 2 years ago

When data logging, the micro:bit has a timestamp which is 'time since boot' - this is nice for quickly previewing data.

If you plug in a battery and then do things over a long period of time the time stamps are reliable, except if you are using MakeCode and web USB - in which case the micro:bit gets arbitrarily reset in a set of cases - certainly when you plug the micro:bit back in while web USB is connected.

The result is that your data doesn't have continuous time stamps.

Is it possible to avoid resetting the micro:bit so often with web USB?

CC @martinwork who noticed that beta does this more than live in https://github.com/microsoft/pxt-microbit/issues/4676#issuecomment-1133945430

martinwork commented 2 years ago

Related: https://github.com/microsoft/pxt-microbit/issues/3418, https://github.com/microsoft/pxt-microbit/issues/3357

pelikhan commented 2 years ago

This is a daplink issue, it resets when setting the baudrate.

jaustin commented 2 years ago

Do you have to set the buadrate? If MakeCode is always 115200 and the micro:bit defaults to that, is it actually necessary?

pelikhan commented 2 years ago

We don't know if the user flashed a program using another environment or changed the baudrate

jaustin commented 2 years ago

But if they have serial at a different baudrate, MakeCode doesn't support that anyway (eg #3537) , and if they changed the baudrate somewhere else, that's a pretty uncommon use-case to drive resetting everyone's board (and therefore resetting all timestamps on data logging programs).

pelikhan commented 2 years ago

Any change in this space would require testing accross (1) V1 vs V2 (2) data logger vs not data logger (3) all versions of DapLink in circulation.

pelikhan commented 2 years ago

Added flags to skip those resets: https://github.com/microsoft/pxt-microbit/commit/347f1e11e66fb3001f644435b83592c76e133d6f

abchatra commented 2 years ago

Fixed

abchatra commented 2 years ago

@jaustin what is the plan of action here?

abchatra commented 2 years ago

We reset while setting the baud rate for logging.

abchatra commented 2 years ago

For the next release get rid of the second reset.

pelikhan commented 2 years ago

Requires a hardware test rig with all versions of DAPLink to validate behavior.

abchatra commented 1 year ago

No actionable thing for makecode here.