Wednesday 29 July 2015

Running Wetty.js in MIPS platform


The objective of this post is to explain the step-by-step procedure on bringing up wetty node-module in a linux OS based on MIPS architecture.


About Wetty


Wetty is a web based tty. It allows us to open a tty (text terminal) session in a web browser to access the remote machine. Normally we use a standard tty client such as putty or Xshell to access the remote machine. Wetty gives us the flexibility of accessing remote machine from a browser without the need of any other software.

Wetty is a node.js module and it runs on top of node.js


Prerequisites:

  1. Download node.js source code (https://nodejs.org/download/); v0.12.7 is the current version during the time of writing
  2. Clone wetty (https://github.com/krishnasrinivas/wetty)
  3. Host Linux (virtual) machine for cross compiling
  4. MIPS toolchain
I prefer to run a virtual machine in vagrant environment, it is so easy to configure and bring up a VM in vagrant. And file sharing between virtual machine and host is also so simple.

Cross compiling Node.js


|> Download node.js source code and prepare the build folder

# mkdir -p /usr/venkateshm/source/nodejs
# cd /usr/venkateshm/source/nodejs
# curl -O https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
# tar xvf node-v0.12.7.tar.gz
# cd node-v0.12.7

|> Set the necessary terminal variables

# export TC_PATH=/usr/venkateshm/toolchain/stbgcc-4.5.3-2.4/bin
# export CC=$TC_PATH/mipsel-linux-gcc
# export AR=$TC_PATH/mipsel-linux-ar
# export CXX=$TC_PATH/mipsel-linux-g++
# export LINK=$TC_PATH/mipsel-linux-g++

|> Configure the make; the configuration for node.js is written is python so python 2.5 or 2.6 is required before running the below command

# ./configure --dest-cpu=mipsel --dest-os=linux --prefix=/usr/local/nodejs --without-snapshot
# vi config.gypi

|> Add following entry under variables 

'mips_arch_variant': 'mips32r1'

|> Make

# make
# make install



copy out/Release/node and put it in /usr/local/bin folder of MIPS machine


Installing wetty in MIPS



Most of the nodejs modules are platform independent as they will be written in javascript. But few modules like websocket are dependent on platform as they use platform specific implementation. 

Wetty is platform independent but its dependencies modules websocket and pts.js are platform dependent. 

Node.js ships with a utility called node.gyp to handle the cases like machine dependent node-module, this utility builds the node-module and generates .node file.

The easy approach is to install wetty first in host virtual machine

# git clone https://github.com/krishnasrinivas/wetty.git
# cd wetty
# npm install

Now all the dependencies of wetty are successful downloaded and can be found inside node_modules folder.

Now download the source of websocket and pty.js node-module

# git clone https://github.com/theturtle32/WebSocket-Node.git
# cd WebSocket-Node
# npm install nan
# /usr/venkateshm/source/nodejs/node-v0.12.7/deps/npm/bin/node-gyp-bin/node-gyp --arch mipsel configure build


If the build is successful, copy the generated build folder and replace it in wetty/node_modules/websocket/build

Similarly steps for pty.js

# git clone https://github.com/chjj/pty.js.git
# cd pty.js
# npm install nan
# /usr/venkateshm/source/nodejs/node-v0.12.7/deps/npm/bin/node-gyp-bin/node-gyp --arch mipsel configure build

Friday 10 July 2015

DIY : Pizza Dosa

Dosa is a staple food in southern region of India. The first step of dosa preparation is its batter; the batter is prepared from urad dal (white lentils) and rice. Once the batter is ready, it will be poured on a hot pan. 

As it is boredom to have same dosa everyday, people came up with onion dosa, masala dosa, podi dosa and much more varieties like that. One such variety that recently started up among younger generation is 'Pizza Dosa'; this after the mania on Pizza.

I use to make this pizza dosa on a relaxed Saturday afternoon for a delicious & drooling lunch. The main ingredients is a set of favorite vegetables. One of my friend told me the secrete of cooking is on how we cut vegetables; for each dish the type of cutting differs and it plays important role is taste & easiness in eating.

Main ingredients are as follows

  1. Dosa batter
  2. Set of vegetables
  3. Cheese
  4. Ghee
  5. Chili flakes 
  6. Oregano flakes
  7. Dry fruits (Optional)



Cut Vegetables
 As I mentioned earlier; the shape of cut matters for best taste of vegetables and easiness in eating. I sliced the onion, did round cut the tomato & horizontal cut for capsicum.


TIP: Watch Youtube videos on cutting different vegetables if very new to cooking.

While making pizza dosa, keep the flame low, this is because it need more time bake the upper part of dosa. In hot pan, pour one or two ladle of batter (depending on the size of pizza we want), spread the cut vegetables on top of it, Lay cheese on top it and pour ghee on the sides. Sprinkle oregano & chili flakes and close it with lid. Open it after couple of minutes, we can feel the smell of oregano. 

Ready to eat Pizza Dosa

Closer look

Now the vegetables would have cooked properly and it will cut easily when we bite. Enjoy & indulge into the taste of freshly prepared Pizza Dosa.