#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:
##Running Code
So what happens when you type tessel run index.js
in your command line?
-
Your command line searches your PATH for the
tessel
executable installed globally withnpm
. This is known as our Command Line Interface (CLI). -
The executable will call
tessel.js
which will search the available built-in commands and identify the requested command astessel run
. -
Tessel will figure out what JavaScript files to push based on dependencies and blacklists in the
package.json
file and the contents of thenode_modules
folder. -
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).
-
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.
-
The runtime defines global JavaScript functions and Node Modules which the lua code calls into.
-
When hardware access is needed, like WiFI calls, transferring data over the communication buses, or writing pin states, the runtime calls into C functions.
-
When the process completes, the runtime is shut down and the script memory is freed.