Coder Social home page Coder Social logo

jerryscript-project / iotjs Goto Github PK

View Code? Open in Web Editor NEW
2.6K 134.0 440.0 63.24 MB

Platform for Internet of Things with JavaScript http://www.iotjs.net

License: Other

CMake 3.50% C++ 0.32% JavaScript 39.32% C 43.41% Makefile 0.39% Assembly 0.11% Shell 1.38% Python 11.57%

iotjs's Introduction

IoT.js: Platform for Internet of Things with JavaScript

License Build Status Coverity Scan Build Status SonarCloud Status FOSSA Status IRC Channel

You can find project details on our project page and wiki.

Memory usage and Binary footprint are measured at here with real target daily.

The following table shows the latest results on the devices:

Raspberry Pi 3 Remote Testrunner
Raspberry Pi 2 Remote Testrunner
STM32F4-Discovery Remote Testrunner

IRC channel: #iotjs on freenode Mailing list: [email protected], you can subscribe here and access the mailing list archive here.

Quick Start

Getting the sources

git clone https://github.com/jerryscript-project/iotjs.git
cd iotjs

How to Build

tools/build.py

How to Test

tools/testrunner.py build/x86_64-linux/debug/bin/iotjs

Trying out with a REPL

build/x86_64-linux/debug/bin/iotjs tools/repl.js

For Additional information see Getting Started.

Documentation

License

IoT.js is Open Source software under the Apache 2.0 license. Complete license and copyright information can be found within the code.

FOSSA Status

Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright Node.js contributors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This license applies to parts of '*.js' files in '/src/js', implementing node.js compatible API, originating from the https://github.com/nodejs/node repository:

iotjs's People

Contributors

akhilkedia avatar akosthekiss avatar bzsolt avatar chunseoklee avatar daeyeon avatar danielballaszte avatar fbmrk avatar galpeter avatar haesik avatar hs0225 avatar ilyoan avatar irishair7 avatar jiangzidong avatar knightburton avatar kolipka avatar laszlolango avatar lemmaa avatar nova0821 avatar robertsipka avatar rtakacs avatar rzr avatar sae-bom avatar seanshpark avatar seo-young avatar tadziopazur avatar tdusnoki avatar wateret avatar yichoi avatar yuyupo avatar zherczeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iotjs's Issues

NuttX build and run simple hello world

NuttX build with current iotjs, run simple hello world script.

console.log("Hello IoT.js");

Implement socket.end

We've landed first implementation for socket.write(), socket.readStart().

To finish connection, socket.end() is needed which will shutdown writable stream and readable stream as well but only if there are no more data to read.

For #31

Revise ugly looking module wrapper

Currently, to make module a function we wrapping over js source with wrapper looking somewhat ugly.

  const char* wrapper[2] = {
    "(function (a, b, c) { function wwwwrap(exports,require, module) {",
    " }; wwwwrap(a, b, c); });" };

This double wrapping is because single wrapping results in bug with losing captured variables. This is probably bug on eval functionality of jerry.

Implement process.exit()

Implement process.exit(), process.exitCode and event: uncaughtException

Currently, raised an uncaught exception, the program abort. This should be treated in uncaughtException handler and if no handler for it, program exit with corresponding exitcode.

related #78, #36

Complete HTTP module

  • http.METHODS
  • http.STATUS_CODES
  • http.createServer([requestListener])
  • Class: http.Server
    • Event: 'request'
    • Event: 'connection'
    • Event: 'close'
    • server.listen(port[, hostname][, backlog][, callback])
    • server.close([callback])
    • server.setTimeout(msecs, callback)
    • server.timeout
  • Class: http.ServerResponse
    • Event: 'close'
    • Event: 'finish'
    • response.writeHead(statusCode[, statusMessage][, headers])
    • response.setTimeout(msecs, callback)
    • response.statusCode
    • response.statusMessage
    • response.setHeader(name, value)
    • response.headersSent
    • response.getHeader(name)
    • response.removeHeader(name)
    • response.write(chunk[, encoding][, callback])
    • response.end([data][, encoding][, callback])
  • http.request(options[, callback])
  • http.get(options[, callback])
  • Class: http.ClientRequest
    • Event: 'response'
    • Event: 'socket'
    • request.write(chunk[, encoding][, callback])
    • request.end([data][, encoding][, callback])
    • request.setTimeout(timeout[, callback])
  • http.IncomingMessage
    • Event: 'close'
    • message.headers
    • message.setTimeout(msecs, callback)
    • message.method
    • message.url
    • message.statusCode
    • message.statusMessage
    • message.socket

Complete Timers module

Implement Timers methods

Required Items:

  • setTimeout()
  • clearTime()
  • setInterval()
  • clearInterval

Complete net module

https://github.com/Samsung/iotjs/wiki/IoT.js-API:-Net

net

  • createServer()
  • connect(options, connectListener)
  • connect(port, host, connectListener)
  • createConnection(opitions, connectListener)
  • createConnection(port, host, connectListener)

net.Server

  • listen(options, callback)
  • listen(port, host, callback)
  • close()
  • event: listening
  • event: connection
  • event: close
  • event: error

net.Socket

  • new Socket(options)
  • connect(port, host, connectListener)
  • write(data, callback)
  • end(data)
  • destroy()
  • resume()
  • pause()
  • setTimeout()
  • setKeepAlive()
  • event: lookup
  • event: connect
  • event: data
  • event: drain
  • event: end
  • event: timeout
  • event: close
  • event: error

Hardware control APIs

As of today, nodejs is on the discuss to support hardware and libuv is ready with uv_device_t PR.
For IoT.js, how are we going to support hardware control and manage devices?
First PR #105 needs some more adjustments and we need to discuss how to provide the API and manage H/W boards and devices. GPIO-control-ideas is prepared to draw everyones sketch.
Please add comments and write down to WiKi page.

Prepare module package description

We need to

  • describe what package.json should contain for the module
  • how it is registered to registry server
  • how it is downloaded to the device
  • how it is used in the program

Change `print` to `console`

Lots of test file use print to print out text to screen.
But print is not offered by our API, instead we can use console.

Remove "unused variable" warnings on release build.

Many warnings are reported during release build which are not appear in debug build.
The pattern of this problem is below form:

int a = <expr>;
assert(a);

assert eats its argument expression and ends in empty expression on release build, resulting the a unused.
Let's introduce redefinition of assert() like this:

#ifdef NDEBUG
 #define IOTJS_ASSERT(x) ((void)(x))
#else
 #define IOTJS_ASSERT(x) assert(x)
#endif

Process native_sources to native side

process has native_sources property with text source that will consume JerryScript heap.
I think it's better remove this and related implementation to native side to save the JavaScript heap.

ReadableStream flowing mode

Readable stream has two mode: flowing and paused.
Currently IoT.js only implemented paused mode. But many use cases run in flowing mode so we need to implement flowing mode before start implementing other modules like fs, net, etc.

Determine module search path order

Nodejs search for a module in the order of
(1) ./node_modules
(2) $NODE_PATH/node_modules
(3) $HOME/node_modules
(4) $HOME/node_libraries
(5) (node execpath)/node/lib

We need to determine the search order w.r.t. multiple plaforms since enviroment or cwd is not available in small devices.

Debug message to console

Need debug message logging like in JerryScript

+#ifdef JERRY_ENABLE_LOG
+#define JERRY_LOG(lvl, ...) \
+  do \
+  { \
+    if (lvl <= jerry_debug_level && jerry_log_file) \
+    { \
+      fprintf (jerry_log_file, __VA_ARGS__); \
+    } \
+  } \
+  while (0)
+
+#define JERRY_DLOG(...) JERRY_LOG (1, __VA_ARGS__)
+#define JERRY_DDLOG(...) JERRY_LOG (2, __VA_ARGS__)
+#define JERRY_DDDLOG(...) JERRY_LOG (3, __VA_ARGS__)
+#else /* !JERRY_ENABLE_LOG */
+#define JERRY_DLOG(...) \
+  do \
+  { \
+    if (false) \
+    { \
+      jerry_ref_unused_variables (0, __VA_ARGS__); \
+    } \
+  } while (0)
+#define JERRY_DDLOG(...) JERRY_DLOG (__VA_ARGS__)
+#define JERRY_DDDLOG(...) JERRY_DLOG (__VA_ARGS__)
+#endif /* !JERRY_ENABLE_LOG */

Show correct source position when assert failure

current message for assert failure is always same position

src/iotjs_binding.cpp:329: iotjs::JObject iotjs::JObject::Call(iotjs::JObject&, iotjs::JArgList&): Assertion `is_ok' failed.
Aborted (core dumped)

need to fix this to show real position.

Complete document: API References

Embedding packages in iotjs

As described in https://github.com/Samsung/iotjs/wiki/IoT.js-Package page, we may need to embed downloaded packages inside iotjs. It can be done such as

  1. download packages to some specific folder
  2. give option to build script to enable embedding with the specific folder
  3. convert package scripts to C code
  4. require() finds packages in embed area

Application script should exist at the root of the specific folder.

Complete assert module

  • assert
    • assert.fail
    • assert.equal
    • assert.notEqual
    • assert.strictEqual
    • assert.notStrictEqual
    • assert.throws
    • assert.doesNotThrows

Documentation build test.

Now we have automatic build test feature.
The build test is mainly done by "tools/check_test.py" script.

Document it, expected contents are:

  • build check process
  • kind of test suite
    • run pass
    • run fail
  • how to write test suite
  • test suite attributes

Wrapper for Javascript native function binding.

Currently IoT.js binds its native javascipt function using external handler API of Jerry Engine. The prototype of the handler is defined as:

typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj_p,
                                          const jerry_api_value_t *this_p,
                                          jerry_api_value_t *ret_val_p,
                                          const jerry_api_value_t args_p [],
                                          const uint16_t args_count);

And each module should implement handlers like:

static bool ToString(const jerry_api_object_t *function_obj_p,
                     const jerry_api_value_t *this_p,
                     jerry_api_value_t *ret_val_p,
                     const jerry_api_value_t args_p [],
                     const uint16_t args_cnt) {
  assert(args_cnt == 0);

  JObject buffer_obj(this_p, false);
  char* buffer = reinterpret_cast<char*>(buffer_obj.GetNative());
  assert(buffer != NULL);

  JObject jstring(buffer);
  jstring.Ref();
  *ret_val_p = jstring.val();

  return true;
}

In spite of JObject wrapper for object type, there is no wrapping layer for external handlers. I think we should introduce a layer that wrap external handler in consistent way with JObject wrapper so that developers who does not know about jerry also could work with it more easily.

next tick not working correctly.

Running test_next_tick.js should end with five lines of output but it is printing only 2 lines before finish.

Main loop should remain as long as there are requests to be handled.

Merge & Build automation

RFC: Merge & Build Automation.

Summary

Introduce a automated build system for continuous integration. There are several well-known build systems such as buildbot, jenkins, hudson, and etc. By using automated build system, we can not only reduce our merge or integration cost but also eliminate human mistakes.

Motive

The process of source integrating is a work of routine. But it requires for people delicate work from start to end to finish without making any mistake. Unfortunately we human being make mistakes even more when the work is a kind of routine. And also it takes a time to be done.
By using automated build system, we are free from such matters. The most of the steps in a process of source integration - except an important step, reviewing - are programmable.

What can be done by automated build system

Automated build system may conduct following routines.

  • Daily building and reporting result.
  • Daily testing including benchmark and reporting result.
  • Build by trigger.
  • Test by trigger.

It also can do followings in conjunction with github web hook API.

  • If there is a new issue registered, report it.
  • If there is a new pull request, report it.
  • If there is a reviewed pull request, build it.
    • If the build and test finished successfully, merge it to master.

Automate Jerry external magic string registration.

From #90, IoT.js registers commonly used string literal as external magic string of jerry engine.
Unfortunately we need to periodically maintain list of magic string by hand.

I think we can automate this by running a script at build process like "iotjs_js.h" file gereration.

Complete fs module

Complete implementation of fs module.

Required Items:

  • fs.access()
  • fs.accessSync()
  • fs.exist() (deprecated)
  • fs.existSync() (deprecated)
  • fs.stat()
  • fs.statSync()
  • fs.chmod()
  • fs.chmodSync()
  • fs.chown()
  • fs.chownSync()
  • fs.rename()
  • fs.renameSync()
  • fs.close()
  • fs.closeSync()
  • fs.open()
  • fs.openSync()
  • fs.read()
  • fs.readSync()
  • fs.readFile()
  • fs.readFileSync()
  • fs.write()
  • fs.writeSync()
  • fs.writeFile()
  • fs.writeFileSync()
  • fs.appendFile()
  • fs.appendFileSync()
  • fs.truncate()
  • fs.truncateSync()
  • fs.mkdir()
  • fs.mkdirSync()
  • fs.rmdir()
  • fs.rmdirSync()
  • fs.readdir()
  • fs.readdirSync()
  • fs.unlink()
  • fs.unlinkSync()

Size of script code buffer

Hello.

Code buffer size argument of jerry_api_eval in JHANDLER_FUNCTION(Compile, handler) and JHANDLER_FUNCTION(CompileNativePtr, handler) is calculated incorrectly : sizeof (code) equals to size of pointer, not buffer size.

Maybe, this could be fixed with the following:

diff --git a/src/iotjs_module_process.cpp b/src/iotjs_module_process.cpp
index 282bc09..bd73a3f 100644
--- a/src/iotjs_module_process.cpp
+++ b/src/iotjs_module_process.cpp
@@ -87,7 +87,7 @@ JHANDLER_FUNCTION(Compile, handler){

   char* code = handler.GetArg(0)->GetCString();
   JRawValueType ret_val;
-  jerry_api_eval(code,sizeof(code),true,false,&ret_val);
+  jerry_api_eval(code,strlen(code),true,false,&ret_val);
   JObject::ReleaseCString(code);

   JObject ret(&ret_val);
@@ -116,7 +116,7 @@ JHANDLER_FUNCTION(CompileNativePtr, handler){
   strcat(code,wrapper[1]);

   JRawValueType ret_val;
-  jerry_api_eval(code,sizeof(code),true,false,&ret_val);
+  jerry_api_eval(code,len,true,false,&ret_val);
   JObject::ReleaseCString(code);

   JObject ret(&ret_val);

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.