Skip to content

Latest commit

 

History

History
34 lines (19 loc) · 2.74 KB

system-overview.md

File metadata and controls

34 lines (19 loc) · 2.74 KB

#Tessel System Overview

This is an overview of how all the components of Tessel work. It is intended to be a reference for those wishing to contribute to the internals of Tessel.

Tessel comprises the following:

  • Firmware - C code that is the interface to all the hardware components (Wifi, RAM, Flash, SPI/UART/I2C busses). It also runs the event queue and handles interrupts.
  • Runtime - the Lua VM running Lua code. It also includes the compatibility layer for core JS functions (String, Number, etc), as well as the core Node functions (fs, buffers, etc)
  • Colony - JS -> Lua compiler
  • CLI - the command line interface for communicating to a Tessel over a USB bus.

Here is a hand-drawn diagram of the system connections:

Tessel System Diagram

##Running Code

So what happens when you type tessel run index.js in your command line?

  1. Your command line searches your PATH for the tessel executable installed globally with npm. This is known as our Command Line Interface (CLI).

  2. The executable will call tessel.js which will search the available built-in commands and identify the requested command as tessel run.

  3. Tessel will figure out what JavaScript files to push based on dependencies and blacklists in the package.json file and the contents of the node_modules folder.

  4. Tessel will then use the Colony compiler to transpile those JavaScript files to Lua source code and send a tarball of that code to Tessel (currently, over USB).

  5. Tessel's firmware will receive the command from USB and save the script into flash. We then load the tarball into the Lua VM in the runtime.

  6. The runtime defines global JavaScript functions and Node Modules which the lua code calls into.

  7. When hardware access is needed, like WiFI calls, transferring data over the communication buses, or writing pin states, the runtime calls into C functions.

  8. When the process completes, the runtime is shut down and the script memory is freed.