Nodejs Appliances On EmbeddedLinux
Nodejs Appliances On EmbeddedLinux
JS Appliances on
Embedded Linux Devices
Mehmet Fatih Karagöz & Cevahir Turgut
1
Outline
Introduction to Node.js
Cross-compiling Node.js and Node Package Manager(NPM)
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
2
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
3
Introduction to Node.js
What is Node.js?
Node.js is a platform built on Chrome's JavaScript runtime
(V8) for easily building fast, scalable network applications.
Event-Driven
Non-Blocking I/O
Lightweight
Efficient HW Usage
4
Introduction to Node.js
Advantages Disadvantages
5
Introduction to Node.js
What is learning curve?
You can get started with building very basic application in less
than one hour (that includes installation time!)
6
Introduction to Node.js
NPM (Node Packaged Modules)
7
Introduction to Node.js
Popular Modules
Express
Request
Async
Grunt
socket.io
Mocha
Underscore
Mongoose
Redis
Connect
8
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
9
Cross-compiling Node.js and NPM
Where is Node.js?
Download
http://nodejs.org/download
Git
git clone git://github.com/joyent/node.git
cd node
git checkout v0.10
10
Cross-compiling Node.js and NPM
Configuration Options
Usage: configure [options]
Options:
--without-npm Don't install the bundled npm package manager
--without-ssl Build without SSL
--without-snapshot Build without snapshotting V8 libraries. You
might want to set this for cross-compiling.
--dest-cpu=DEST_CPU CPU architecture to build for.Valid values
are: arm, ia32, x64
--dest-os=DEST_OS Operating system to build for.Valid values are:
win, mac, solaris, freebsd, openbsd, linux, android
11
Cross-compiling Node.js and NPM
How to make and install
export AR=arm-linux-gnueabihf-ar
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export LINK=arm-linux-gnueabihf-g++
12
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
13
Development Environment
Suitable Editors
Vim
Gedit
Webstorm
Eclipse / Nodeclipse Plugin
Cloud9 (Cloud based editor)
14
Development Environment
“node debug myscript.js”
Debugging Options
cont, c - Continue execution
next, n - Step next
step, s - Step in
out, o - Step out
pause - Pause running code (like pause button in Developer Tools)
15
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
16
Scripting Samples in Embedded Devices
GPIO/LED on/off
17
Scripting Samples in Embedded Devices
CPU / Memory Usage
var os = require(‘os’);
18
Scripting Samples in Embedded Devices
Timers
19
Scripting Samples in Embedded Devices
Ini Parser
config.ini:
;sample config ini file
name = Iniparser Demo
version = 0.1
20
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
21
Development Story of a Surveillance
Application - Overview
Main Purpose
Demonstrate usage scenario of Node.js in real world app
Give more information about network classes of Node.js
Run complete Node.js app in embedded platform
22
Development Story of a Surveillance
Application - Overview
Deployment Model of Example System
23
Development Story of a Surveillance
Application - Overview
Used Components
IGEPv2 Boards
DM3730 Texas Instruments processor
ARM Cortex A8 1GHz
Camera ISP
512 Megabytes RAM / 512 Megabytes FLASH
Ethernet 10/100 MB BaseT
And more (C64+ DSP 800MHz, 3D Accelerator SGX530 @ 200 MHz,
...)
Kernel
2.6.37
Compiler:
GCC version 4.6.3
24
Development Story of a Surveillance
Application - Overview
Component Diagram
25
Development Story of a Surveillance
Application - Overview
Component Diagram (with messages)
26
Development Story of a Surveillance
Application - Overview
Deployment Model of Example System
27
Development Story of a Surveillance
Application - Video App
Video App
Fake Applicaton to simulate motion detection
Written using Boost CPP Libraries
Connected to Camera System App with TCP
Produces periodic alarm messages
Receives configuration messages
28
Development Story of a Surveillance
Application - Video App
29
Development Story of a Surveillance
Application - Camera SystemMgr App
Camera SystemMgr App
Written using Node.js
Manages other software elements running on camera through
IPC
Store configurations
Connection interface of camera to server
Includes 2 TCP servers and 1 UDP client
1 TCP Server for IPC with VideoApp
1 TCP Server
to get configuration messages from Server
to send alarm messages to Server
1 UDP broadcaster to send heartbeat
30
Camera SystemMgr App
31
Camera SystemMgr App
32
Camera SystemMgr App
33
Development Story of a Surveillance
Application - Server App
Server App
Connection with online cameras
Camera discovery by listening Broadcast/UDP heartbeat messages
Connecting TCP port of cameras
Configuring cameras
Collects alarms from cameras
Serve all information to web interface
Static Content Serving
Express and Socket.io modules of Node.js
Handles user inputs from web interface
Management of all cameras
Handling multi-client/multi-camera systems
34
Server App
35
Server App
36
Server App
37
Server App
38
Server App
39
Development Story of a Surveillance
Application - Web Interface
Web Interface
HTML5/Javascript
Web Sockets
Socket.io
Angular.js
Ajax Based
No need to refresh
Browser Compatibility
IE9, Firefox, Chrome tested
40
Web Interface
WebSocket Code Samples
From “http://socket.io/#how-to-use”
41
Web Interface
WebSocket Code Samples
42
Web Interface
WebSocket Code Samples
43
Outline
Introduction to Node.js
Cross-compiling Node.js and NPM
Development environment
Scripting samples in embedded devices
Development story of a surveillance application
Demo
Questions
44
Questions
Demo Codes
github.com/mfkaragoz/elce2013demo
Thank You!
Cevahir TURGUT
[email protected]
45