QUESTION and maybe a bug: Are there system LOCKS during Web Thing Server transactions ?

Issue #104 resolved
Turgut Guneysu created an issue

Hello John,

Noticed the following condition, while creating a program that updates micro:bit from a SNAP! program.

  • microBlocks is running the WebThing Server.
  • micro:bit is USB connected.
  • I am sending a 25 character string representing the on/off condition of virtual micro:bit LEDs from SNAP.

On the microBlocks side, there is a While block checking if the receiving string var is not equal to its initial value (which is “!”, just so I have a visible value in there.

If it is not equal, it processes the new value of the variable, and sets the micro:bit LEDs on and off accordingly.

What is happening is:

  • the string variable “starts becoming not equal” but not quite all the way in all 25 characters;
  • and in that interim instant the routine processes whatever it happened to see, MOSTY partial info, less than 25 characters !

This drove me crazy trying to troubleshoot what was going on !

I ended up putting checks for the full length of the string, which is 25, to make it work right.

Back to the question:

Is it possible to lock / freeze program parts of the mB VM while receiving Web data to make sure the variables are fully updated ?

I have NOT tried this with number data. It might be OK

I am curious to hear your take on this.

Comments (5)

  1. John Maloney repo owner

    Have you tried this with the new Web Things library? Most of the server (except the low level HTTP primitives) is now implemented in MicroBlocks, so it should be possible to make sure it has received a complete JSON update before updating the variable.

    It may not do that right now, but if it doesn’t it will be easy to fix.

  2. John Maloney repo owner

    We are replacing the “Web Thing Server” built into the IDE with a simpler “HTTP Server”. Updates to variables, including strings, should be atomic. I’m marking this issue resolved since it applies to the old server but you find a similar issue with the new server please create a new issue.

  3. Log in to comment