Giter Club home page Giter Club logo

runtime's Introduction

tessel runtime

This is the runtime and JavaScript engine that runs on Tessel, built on Lua's VM. It can be run independently on PC or embedded.

git clone --recursive https://github.com/tessel/runtime.git

Building the firmware requires gcc-arm-embedded, gyp, and ninja.

OS X

To install quickly on a Mac with Brew:

brew tap tessel/tools
brew install gcc-arm gyp ninja

Ubuntu 14.04

All dependencies are in the Ubuntu 14.04 repositories:

sudo apt-get install git nodejs npm nodejs-legacy gcc-arm-none-eabi gyp ninja-build

Building

npm install
npm install -g colony-compiler
make colony
npm link --local
npm test

You can now run code on your PC using colony from your command line (e.g. colony hello-world.js). For building firmware, please see the firmware building instructions.

Documentation

Colony

Colony has support for interacting with the Lua API for handling basic JavaScript primitives. These are included via colony.h.

# void  colony_createarray ( lua_State*  L, int  size )
Creates a new JavaScript array of length size. This sets the object prototype as well as the initial length of the array.

# void  colony_createobj ( lua_State*  L, int  size, int  proto )
Creates a new JavaScript object with an expected (but not required) allocation of size keys. This sets the object prototype as well. If proto is not zero (an invalid stack pointer), it points to an object on the stack to be used as the prototype for the newly created object.

Net

Networking

# typedef  tm_socket_t
socket type

# tm_socket_t  tm_udp_open ()
open a udp socket

# int  tm_udp_close ( int  sock )
close a udp socket

# int  tm_udp_listen ( int  ulSocket, int  port )
listen to udp

# int  tm_udp_receive ( int  ulSocket, uint8_t  *buf, unsigned  long buf_len, uint32_t  *ip );
receive on udp

# int  tm_udp_readable ( tm_socket_t  sock )
is socket readable?

# int  tm_udp_send ( int  ulSocket, uint8_t  ip0, uint8_t  ip1, uint8_t  ip2, uint8_t  ip3, int  port, uint8_t  *buf, unsigned  long buf_len )
send on socket

# tm_socket_t  tm_tcp_open ()
open tcp

# int  tm_tcp_close ()
close tcp

# int  tm_tcp_connect ( tm_socket_t  sock, uint8_t  ip0, uint8_t  ip1, uint8_t  ip2, uint8_t  ip3, uint16_t  port )
connect on tcp

# int  tm_tcp_write ( tm_socket_t  sock, uint8_t  *buf, size_t  buflen )
write on tcp

# int  tm_tcp_read ( tm_socket_t  sock, uint8_t  *buf, size_t  buflen )
read on tcp

# int  tm_tcp_readable ( tm_socket_t  sock )
is socket readable?

# int  tm_tcp_listen ( tm_socket_t  sock, uint16_t  port )
listen on port

# tm_socket_t  tm_tcp_accept ( tm_socket_t  sock, uint32_t  *ip )
accept new incoming connection

# uint32_t  tm_hostname_lookup ( const  uint8_t *hostname )
lookup host

Regular Expressions

Regexes

# typedef  struct {
    size_t re_nsub;
    long re_info;
    int re_csize;
  } regex_t;
Regex created by re_comp. re_nsub is the number of subcapture groups. re_info is a bitmask of information about the regex. re_csize is the length of a character in the regex.

# typedef  struct {
    long rm_so;
    long rm_eo;
  } regmatch_t;
A matched subgroup. rm_so is the start offset in the string, rm_eo is the ending offset.

# int  re_comp( regex_t*  regex, const  wchar_t* pattern, size_t  pattern_len, int  flags );
Compiles a regex pattern with flags in the memory allocated at regex. Use regfree to close this object.

# void  regfree( regex_t*  regex );
Frees the internals of a regex_t object.

# int  re_exec( regex_t*  regex, const  wchar_t* input, size_t  input_len, rm_detail_t*  details, size_t  matches_len, regmatch_t  matches[], int  flags );
Executes a regex on the given string input. Can match up to matches_len subgroups in the array matches.

# size_t  regerror( int  error, const  regex_t* regex, char*  buf, size_t  buf_len );
Returns the meaning of a given regex error.

License

MIT or Apache 2.0, at your option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.