1 of 9

Bringing the Full Power of Snap!

to Embedded Programming

Devin Jean

1

NetsBlox

2 of 9

Background

  • Snap! is a very powerful general programming language
    • Asynchronous events
    • (Pseudo-)Parallel code execution
    • Declarative and functional programming styles
    • Cyclic structures, closures/rings, etc.
  • Historically trapped in the browser

2

    • Want to to target embedded microcontrollers
  • Some embedded approaches: Snap4Arduino, MicroBlocks, micro:bit extension etc.
    • Either full Snap! but still running on computer
    • Or actually run on device, but not Snap! anymore

3 of 9

NetsBlox Overview

3

  • Fork of Snap! that adds a few networking features:
    • Remote Procedure Calls (RPCs)
    • Message passing between projects
    • Real-time collaborative editing
  • Important: aside from adding networking, identical to Snap!
  • Good platform for intro IoT
    • Just need to solve the microcontroller problem

4 of 9

Our Solution - NetsBloxVM

  • Build a new Snap!/NetsBlox runtime from the ground up

4

    • Web/browser, server, desktop/laptop, mobile, embedded, etc.
  • Support all the advanced Snap!/NetsBlox features
    • Asynchronous, parallel, recursion, rings, watchers, events, networking, etc.
  • Architect it specifically with customizability and extensions in mind
  • Now users can write a project in NetsBlox/Snap! and run it anywhere!
  • Written in “no-std” Rust to target many platforms

5 of 9

How It Works - ESP32 Version

5

1. NetsBloxVM runs on an ESP32

4. Users write whatever Snap!/NetsBlox code they want to run on the device.

2. Board hosts a normal NetsBlox extension for controlling it

3. Board loads in “Native” blocks for accessing sensors and other connected devices

5. Users can upload their code to the device and run/pause/stop it through the connected “Native Terminal”

6 of 9

How It Works - Debugging

6

1. Program output (say blocks) and errors are displayed in a connected browser

2. Errors shown as special red comment stack trace - includes snapshot of all variables in scope

3. If no connected browser, device continues executing and saves output/errors in buffers for next time

4. NetsBloxVM core also supports the pause block as a sort of breakpoint, and watchers.

7 of 9

How It Works - Setup

7

1. Device hosts a config page for managing settings

2. Can access without internet via access point

3. Networked features need connection to a wifi network (with internet)

4. Hardware peripherals added as new entries in the peripherals config. Syscalls automatically populated.

Entirely wireless experience! No flashing needed!

8 of 9

Let’s See It In Action!

8

9 of 9

Resources

  • Visit https://netsblox.org/ for more information about NetsBlox
  • The NetsBloxVM core library: https://crates.io/crates/netsblox-vm
    • Contains everything for executing Snap!/NetsBlox code
  • The ESP32 wrapper for NetsBloxVM: https://github.com/dragazo/netsblox-vm-esp32
    • Uses NetsBloxVM core and just adds support for hardware peripherals
  • Check out some of our NetsBlox and related curriculum: https://csfrontiers.org/curriculum.html
  • Feel free to contact me if you have any questions! devin.c.jean@vanderbilt.edu

9

NetsBlox