microsoft / pxt-microbit

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

bad interaction between radio and jacdac proxy mode #6005

Closed tballmsft closed 2 weeks ago

tballmsft commented 3 weeks ago

See https://makecode.microbit.org/_Eei0YxUotXsy

The program uses the Jacdac extension and sends a radio message. The bad behavior:

  1. the second microbit sim starts up and then disappears
  2. the first microbit sim goes into jacdac proxy mode, which also causes a reset of micro:bit sim (via control.reset)

Expected behavior:

  1. the second micro:bit sim stays up
  2. the first micro:bit sim does not go into jacdac proxy mode
tballmsft commented 2 weeks ago

OK. Here's what's going on (a bad interaction between features):

Sigh...

tballmsft commented 2 weeks ago

I think the solution here is for the Jacdac extension to have a way to specify that only one code (mbit) simulator is allowed. @eanders-ms, @pelikhan, @abchatra - what do you think? This can easily be done via providing a new method in the simulator framework that can be called from Static TypeScript.

tballmsft commented 2 weeks ago

See

tballmsft commented 2 weeks ago

The above changes provide a function to turn off multiple simulators (for the rest of a program execution). See following program

input.onButtonPressed(Button.A, function () {
    radio.sendNumber(0)
})
input.onButtonPressed(Button.B, function () {
    control.reset()
})
input.onButtonPressed(Button.AB, function () {
    control.singleSimulator()
})
tballmsft commented 2 weeks ago

approved and committed (will need to bump pxt, pxt-common-packages, pxt-microbit): @abchatra

abchatra commented 2 weeks ago

Done