Tuesday, December 30, 2014

Sending Messages Between Two nRF24L01 Modules using Arduino

During the holidays I took some 2.4 GHz radio modules from our lab to my home far away from Colombo and tried different interesting things. One of the things I tried is establishing simple communication between nRF24L01 modules to transfer some data. For this purpose I connected two of those radio modules to two Arduino Uno boards and programmed using Arduino IDE and RF24 library. In this article, I'm writing down the steps I followed for my own future reference. I tried it in a machine which runs Ubuntu 12.04 LTS.

(1) Download https://github.com/maniacbug/RF24 library as a ZIP file. Extract it and renamed as 'RF24maniacbug'. Create a directory called 'libraries' in your sketchbook directory inside home directory ('~/sketchbook') only if it wasn't available initially and copy the 'RF24maniacbug' directory into it. I forked the same github project of maniacbug into my account for my future use which is available at https://github.com/asanka-code/RF24.

(2) Wire up the nRF24L01 module with Arduino board according to the pin connection details in the following table. We need two setups like this to be able to send and receive data.
nRF24L01 Pin Arduino Uno Pin
GND GND
VCC 3V3
CE 9
CSN 10
SCK 13
MOSI 11
MISO 12

(3) Plug the two Arduino boards to the computer using two USB cables. Start two instances of Arduino IDE and select the two serial devices separately in two IDE instances. In my machine, one Arduino board was detected as /dev/ttyACM1 and the other as /dev/ttyACM2.

(4) From each Arduino IDE, move in the following menu path and open the GettingStarted example program (sketch). Compile and upload that program into both Arduino boards.

File->Examples->RF24maniacbug->GettingStarted

(5) Open serial monitor in both Arduino IDEs and set the baud rate to 57600. It should show some status information of the nRF24L01 module connectivity to the Arduino board.
Output of serial monitors of sender and receiver
Now, type 'T' on the serial monitor of a one device and then it will start sending messages to the other device. The other device should start sending responses for each message from the first. If we need to change the roles of sender and receiver, type R in the current sender and it will switch to the listening mode. Then type T in the initial receivers serial monitor to make it the sender.

References:
[1] http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/
[2] https://github.com/maniacbug/RF24
[3] I forked maniacbug's RF24 repository for my future use which is available at
https://github.com/asanka-code/RF24

Saturday, December 27, 2014

Zigbee Communication Between Two Arduino Boards

In this post, I'm writing down the steps I followed to exchange some simple wireless messages between two Arduino boards which are attached with Xbee wireless modules. For this purpose, I used two Arduino Uno boards, two Xbee shields which are the model of Seeed Studio XBee Shield v2.0 and two XBee modules from Digi XBee S2 module type.

Initially I searched through the web and found out that I have to configure XBee modules to create a Zigbee network by setting PAN IDs and some other stuff. For that there are two methods available as I read in the web. I attempted to try the first method which is using X-CTU tool from Digi international to configure XBee S2 modules. However, my efforts went in vain due to some reason which I still didn't figured out. The second method of configuring XBee S2 modules is using some tool such as PuTTy to communicate with the module from our PC. However I didn't try that second method yet. So, that means I didn't configure the XBee S2 modules at all.

Without making any configurations, we can simply transmit some data from an XBee S2 module which can be received by another XBee S2 module. That is what finally I did and write in this article about. For that purpose we just need two little programs (sketches) for Arduino boards. I will list down the steps I followed one by one.

(1) First of all, take an XBee shield and connect it to the Arduino Uno board. Then attach an XBee S2 module to the shield. Do the same to another set of Arduino board, XBee Shield and XBee S2 module so that we have to setups.

Assembled units

(2) Then, we need to program the Arduino boards. For this purpose, we should remove the two jumpers on Seeed Studio XBee shields. That's is to prevent Arduino IDE from sending programming data into the XBee S2 module while programming the Atmega MCU of the Arduino  Uno board. After removing the jumpers, we are ready to program them. From the two programs shown below, put the sender program (sketch) to one Arduino board and put the receiver program (sketch) to the other Arduino board.

Sender program

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("H"); //turn on the LED
  delay(2000);
  Serial.println("L");//turn off the LED
  delay(2000);
}

Receiver program

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
char msg = ' '; //contains the message from arduino sender
const int led = 13; //led at pin 13

void setup() {
  Serial.begin(9600);//Remember that the baud must be the same on both arduinos
  pinMode(led,OUTPUT);
}

void loop() {
  while(Serial.available() > 0) {
    msg=Serial.read();
    if(msg=='H') {
      digitalWrite(led,HIGH);
    }
    if(msg=='L') {
      digitalWrite(led,LOW);
    }
    msg = ' ';
    delay(1000);
  }
}

(3) After putting two programs into the two separate Arduino boards, we should disconnect them from the USB cables from PC. To connect the XBee S2 modules TX and Rx pins with the correct Rx and TX pins of the Arduino board, place the two jumpers in correct place of the XBee shield. Following picture shows the two jumpers in correct position.
Jumpers placed on XBee shield
(4) Connect the receiver device first into the PC using USB cables to power it up. You will notice that its on-board LED connected to Arduino pin 13 is not blinking yet. It need the command messages from the sender device to blink it according to our program. Then connect the sender device to the PC using USB cable to power it. After a short while you will notice that now receiver device is blinking its on-board LED in pin 13 giving the proof of wireless message exchange.

Our two modules powered up :)
Cheers!

Saturday, December 20, 2014

Using RPL in Contiki

When working on a sensor network application or an evaluation of a research work, sometimes we need to have a network setup which runs RPL routing protocol on sensor nodes. If we are working on Contiki OS platform, we are lucky to have not only the implementation of RPL protocol but also some sample applications which use RPL. To understand it, the best example would be simple-udp-rpl which resides in the path contiki-2.7/examples/ipv6/simple-udp-rpl of contiki source code. There are two source files inside this directory which draw our attention. First one is unicast-receiver.c file which is the receiver of unicast messages in the RPL routing tree and therefore behaves as the root node. The second file is unicast-sender.c which implements a unicast sending functionality to the root node of the RPL routing tree.

The best way to easily try out RPL on Contiki is to use Cooja simulator. First, we need to start Cooja simulator by moving into the contiki-2.7/tools/cooja directory from a linux terminal and issuing the command ant run. It will start Cooja simulation window and then we need to start a new simulation as usual. When adding motes, first we should add a Sky mote and browse and select unicast-receiver.c file as the program code to run on this mote. This will be our root node of the RPL tree. Then again add few other Sky motes but this time, use the file unicast-sender.c as the application code allowing them to be sender nodes in the RPL tree. To witness how packets from sender nodes traverse through the RPL tree over multiple hops to the root node, it would be better to keep some nodes out of the radio range of root node so that they are only accessible through some other forwarder nodes in the tree. The first figure depicts my node setup in the simulation.

After setting up the simulation with nodes with relevant applications, we can start simulation  by clicking on the Start button of Cooja simulator. After a while all the nodes started up with Contiki OS, we will start to see that every sender node periodically transmits a packet which travel through the RPL tree to the root node. Both sender and receiver nodes prints a string about these events which can be evident from the mote output window of Cooja simulator. Second figure in this article depicts some excerpt from the mote output window with sender and receiver message logs. Even though the RPL implementation of Contiki OS is a bit complicated to understand easily, these two simple sender and receiver applications would be helpful if we need to setup a scenario where we need our nodes to simply communicate using RPL without too much troubles.

~******~

Wednesday, December 17, 2014

Prof. Margot and Ravihansa from QUT, Australia.

Ravihansa and Prof. Margot
Last week was a so much busy time. In ICTer 2014 conference, I had been assigned various duties and therefore I had to run here and there to organize different things for about a week. Mainly I was assigned to facilitate a workshop conducted by the Zone24x7 company on 13th December and also a session in 12th December. However, I involved in many other works and lot of those things were really interesting. Besides all the things, I decided to write today about two interesting workshops I attended and a keynote speech in ICTer conference.

Ravihansa Rajapakse was once a student at University of Colombo School of Computing (UCSC) and was a one year senior to me. After he finished his bachelors degree, he worked in our junior academic staff. Now he is in Queensland University of Technology (QUT), Australia studying for his PhD. He came to Sri Lanka for the ICter conference not alone but with his supervisor who is a very nice lady. She is Prof. Margot Brereton from QUT. Ravihansa conducted a very interesting workshop in 10th December and then Prof. Margot delivered her keynote speech at ICTer conference in 11th. She did another nice workshop in 13th December. I was lucky to attend all these events while managing my time for various official duties.

Our prototype :D
First of all, I have to write about Mr. Ravihansa's workshop which was so interesting than I ever thought. I knew him for several years as he was a senior to me in my undergraduate degree. However, this is the first time I got a chance to be in the audience of a lecture or a workshop conducted by him. His workshop title was "Build First Plan Later: The Voice of DIY Approach in Today's Design". The whole point he tried to convince us from this workshop as I understood was, sometimes it's better to build things with the user instead of designing and building something separately and then applying it to the user context. He brought various things such as fruits, stationaries, clay, etc and in addition to that, he had brought few kits called Makey Makey. Mr. Dulan Wathugala who was once a great teacher and a mentor to us also attended to this workshop which made me so happy. We had a chat during the tea break of the workshop about various new technological trends.

Among different activities we did, the main task was to organize as a group and then select one person as a client who has a special requirement. This requirement is having some loved one in a long distance so that this group member has a need to be connected with the loved one. The task of the group is to talk with her and identify a method which provides a connectedness between her and the loved one. We formed a group where we had me, Chathura Suduwella and three members from software development unit (SDU) of UCSC. Actually I didn't know those three before this workshop and while performing the group work I made a friendship with them too. One girl in our group is selected as the client whose parents are living out of Colombo while she lives in Colombo. Our goal is to make a connection between she and her parents in some way other than standard communication mechanisms such as telephone calls, text messages, etc. After having interviews with our group member who is the client and also after a long brainstorming among the group members, finally Chathura came up with a great idea which everybody liked.

Makey Makey
Our idea was to create a small pot with a plant which has some automated functionalities. It has a small water container with an electric valve. A control signal can water the plant. Additionally, there will be some UV lights around the plant which can be turned on and off when necessary. We will put this automated plant in the living room of our clients parents house. We will put sensors in the house of our client girl so that we can track whether she has left home in the morning in a predefined time and also return home in the evening within a predefined time. Perhaps we can get this information from the sensor fixed onto a door of her living place in Colombo. Additionally, we can connect some sensor to track weather she used her plate for meals providing us the valuable information about her eating times. All these information is transferred from her living place in Colombo to her parents house where the automated plant resides. Our idea is to make the system to water the plant and provide light conditions when she leave home in the morning, return back in the evening and eat within a predefined time. Our hope is that the condition of the plant will reflect the good living condition in our clients life to her parents.

After this first workshop next day I attended to the keynote speech of Prof. Margot Brereton where she talked about different ways people have introduced ICT solutions for problems in the communities around the world and how they have succeeded and failed. Her keynote speech reflects a similar idea to Ravihansa's workshop where the importance of designing solutions with the user instead of for the user is highlighted. After her keynote speech, I took a picture of Prof. Margot and Ravihansa for the purpose of including in this article. Finally in last Saturday, there was another little workshop conducted by Prof. Margot where she helped us to visualize a problem by drawing with a paper and some color pens. Each participant was given a chance to select some problem with which they are dealing these days and then draw the connections of people and every other thing that relates to the problem. This method helps to identify the important parts of the problem and what are the things that should be considered when thinking about the solution.

As always, I enjoy meeting new people and getting to know various new things that broaden my understanding and improve my thinking about the world around me. Among various things I saw and people I met during the ICTer 2014 conference days, Professor Margot and Ravihansa are very important people and the knowledge and experiences they brought to me from Australia is awesome.

~********~

Saturday, December 6, 2014

Capturing WiFi Packets in Monitor Mode With Wireshark

I've used Wireshark for looking at different network packets and their contents. However recently I wanted to observe WiFi networks around me using Wireshark without actually connecting to any of those networks. For this purpose we have to run our wireless card in monitor mode which allows us to eavesdrop WiFi packets in wireless networks around us passively. I searched in the web to learn how to do it in my Asus laptop which runs Ubuntu 12.04 LTS. So, I'm writing down how I did it in my platform. There's an important thing to keep in mind that not all the wireless cards support monitor mode. If your wireless card doesn't support it, you are in trouble.

Steps to follow in a terminal:

// setting wlan0 to monitor mode
sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor
iwconfig wlan0
sudo ifconfig wlan0 up

// install wireshark if you haven't yet
sudo apt-get install wireshark

// run wireshark with root priviledges
sudo wireshark

Now Wireshark GUI window will open up and then you can select your wlan0 interface to start capturing packets. Following screenshot shows my Wireshark window with various WiFi packets.

Wireshark window with captured WiFi packets


References:





Friday, November 28, 2014

A new home for the SCoRe group

My new station
After staying in the same place for around 8 years, sustainable computing research (SCoRe) group, which is previously known as Wireless Ad-hoc Sensor Network (WASN) research group is moving. For all these years, we've been staying in a small room located in a hidden corner of the UCSC building. That place was home for many successful researchers and many successful research projects conducted by the group. With the refurbishments of UCSC building, various new parts were added including an extra floor which is the 4th floor. New lab room for the SCoRe group is allocated from this all new 4th floor.

A nice view from our window
I got to know about WASN research group around early 2010, after having a short chat with Dr. Chamath and Dr. Kasun at their office. Initially, I started contributing to their projects by doing small supportive work, little by little, learning their subject domains. In my 3rd year, I did my internship at the WASN lab with the research group and learned how to live in a research environment. Even during my 4th year of the undergraduate education, I spent most of my time at the WASN lab working in research project works. Finally after my 4th year, I got the chance to work as a research assistant (RA) for few years before I go abroad. When I return to the lab after more than a year of new life experiences, WASN lab was facing various significant changes such as people and the role of the lab.

Currently the situation in our WASN lab location is a bit complicated. Instead of being a place dedicated for research and development works, some other roles are emerging in that place. Some undergraduate course works which are operated by a lecturer is based on the lab and therefore always, many undergraduates are vising the place. Sometimes, undergraduate students stay in the lab with their laptops to do their own works without any specific relation to the lab research or course work. I've faced many situations, where the lab was too noisy and hard to focus on my work due to the behavior of undergraduate students. Additionally, there are some requirements such as the lecturer who is handling the undergraduate courses is in need of transforming it into an undergraduate lab.

Under all these conditions, I think, receiving a new place for the SCoRe research group is a positive movement. Our new place is very peaceful and has less distractions compared to the old place. I personally like this new room since it has a nice view from the window. I can see the UCSC ground and far away places inside the university premises from this place. Our neighborhood is some other research labs with other researchers. I hope that having a green view will help me to recover from hard times in lab work.


Thursday, November 20, 2014

Setting Up an SVN Repository Server

More than 4 years ago, I wrote a blog post about setting up an SVN (subversion) client in an Ubuntu system because I had to use the version control  system maintained by the lab for research project works. After such a long time period, finally a week ago I had to install an SVN server in a newly settled server for the lab. Keeping  the tradition, I'm writing down the steps of this installation for the benefit of me in the future and also for the rest of the world.

First of all, we should login to the sever where we need to configure SVN server using SSH. Then we can follow the command sequence given below.

# installing svn application
apt-get install subversion

# template for a project repository directory structure
mkdir /var/svn/
mkdir /var/svn/tmpproject
mkdir /var/svn/tmpproject/branches
mkdir /var/svn/tmpproject/tags
mkdir /var/svn/tmpproject/trunk

# creating a real project repository and copy the template content into it
svnadmin create /var/svn/myproject --fs-type fsfs
svn import /var/svn/tmpproject file:///var/svn/myproject -m "initial import"

# add new users to the system to be a client of the repository
adduser asanka
adduser chamath


# starting svnserve deamen. Not necessary if users access with SSH I think.
svnserve -d

Now we are done at the server side. We should logout from the server and now check whether we can access the repository from the client side. There are various  ways of providing user access to an SVN repository but in my configuration, I'm only allowing the users who have a  user account in the server to access the repository. Follow the  given command sequence to access the SVN repository in the server.
 
svn co svn+ssh://chamath@192.248.xxx.xxx/var/svn/temproject/
svn add some_file.txt
svn commit trunk/ --message "My initial messsage"

In this way, we can start using our newly initialized SVN repository server. I'm not sure whether  I missed any important step because I compiled these steps after trying various other ways. In case I have missed something, please be kind to point out :-)

Tuesday, November 11, 2014

Removing shortcuts from GNOME Classic launcher

This may sound stupid but for a long time, I was not able to remove shortcuts from the launcher in GLOME Classic. Therefore I was afraid of adding things to the launcher. I just has put Firefox, Terminal, Gedit and a green screen shot  capturing app. Today, I accidentally added some other shortcuts into the launcher and faced a situation of removing them somehow. Then only I bothered to search google about it and found the solution.

The key combination  Super(= Windows key) + Alt + Right-Click on the launcher icon provided me the option "Remove From Panel". Thats what exactly we wanted. Just right-clicking on a launcher icon does not provide this option. I found this solution from this forum discussion.


Monday, November 3, 2014

Drawing Gantt Charts using Latex

While preparing some document in last week, I wanted to draw a Gantt chart to visualize a time line of a project. I tried different GUI based tools but I didn't like  them. At the end, I decided to find out whether there's any Latex package available to get my task done. Luckily, I found it. For this purpose, first of all, we need to have a style file called gantt.sty which you can download from here. Then we need to compose our gantt  chart definition in a .tex file. Following is such an example gantt chart definition which I saved with the file name my_gantt_chart.tex in the same directory as the style file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
\documentclass{article}

\usepackage[pdftex,active,tightpage]{preview} \setlength\PreviewBorder{2mm}
\usepackage{gantt}

\begin{document}
\begin{preview}

\begin{gantt}{7}{12}
    \begin{ganttitle}
      \titleelement{\textbf{Year 2015}}{12}
    \end{ganttitle}
    \begin{ganttitle}
      \titleelement{\textbf{Jan}}{1}
      \titleelement{\textbf{Feb}}{1}
      \titleelement{\textbf{Mar}}{1}
      \titleelement{\textbf{Apr}}{1}
      \titleelement{\textbf{May}}{1}
      \titleelement{\textbf{Jun}}{1}
      \titleelement{\textbf{Jul}}{1}
      \titleelement{\textbf{Aug}}{1}
      \titleelement{\textbf{Sep}}{1}
      \titleelement{\textbf{Oct}}{1}
      \titleelement{\textbf{Nov}}{1}
      \titleelement{\textbf{Dec}}{1}
    \end{ganttitle}
    \ganttbar[color=green]{\textbf{Phase-1: Design and prototype implementation}}{0}{3}
    \ganttbarcon[color=blue]{\textbf{Phase-2: Pilot deployment and field trials}}{3}{6}
    \ganttbarcon[color=red]{\textbf{Phase-3: Full scale deployment and evaluations}}{9}{3}
  \end{gantt}
\end{preview}
\end{document}

Now we can generate the PDF file by issuing  the  following command in the terminal.

pdflatex my_gantt_chart.tex

Following is a screenshot of the output PDF I received.

Even though the output doesn't look fancy as the output of many other tools, I'm happy with this because it allows  me to prepare it using Latex, my favorite document processing tool.

References:




Monday, October 20, 2014

Messing up with the Java installation on Ubuntu

I started using a laptop used by a previous member of them which has 64-bit Ubuntu 12.04  and it seemed fine. Since I'm OK with the existing operating system version and stuff, I decided not to format the hard drive instead  keep working on the existing system. However, after a while, I wanted to run some Java program and then realized  that the Java versions in this laptop has some issue. Now I can't exactly remember the problem, however I remember  the stupid solution I did to remove those existing Java versions. I went into /usr/lib/jvm directory and deleted everything inside it using the rm command. Then I tried to install Java from the beginning but started to receive weired errors.

At the end, I realized that deleting the content inside that directory have messed  up everything to a level where its hard to fix everything. Since I was busy, I decided to put it aside and use a VMWare guest instance of Ubuntu on top of my host Ubuntu system to run the  required Java programs. Finally today I received an opportunity to search the web with a fresh mind to find a solution. I found a working solution which I followed blindly to get my system fixed however I think its worth writing down the steps I followed. The person who had given that answer is Eric Carvalho in AskUbuntu  forum. This is the link to that forum question where he  had answered.

Following are the steps to remove the messed up Java related packages from my system as I got to know from the above forum. Honestly, I don't understand the functionality of most of those commands  but they worked somehow.

sudo apt-get update

apt-cache search java | awk '{print($1)}' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e 'java-common' | xargs sudo apt-get -y remove

sudo apt-get -y autoremove

dpkg -l | grep ^rc | awk '{print($2)}' | xargs sudo apt-get -y purge

sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf

sudo rm -rf /usr/lib/jvm/*

for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done

sudo updatedb

sudo locate -b '\pack200'
 
Finally, I installed Java in my system using the following command and everything worked fine ever after.

sudo apt-get install openjdk-7-jdk

I realized how big the mess I had made by simply deleting the content of my /usr/lib/jvm/ directory which I will never do again. :-)

Wednesday, October 15, 2014

MatPlotLib for plottiing data in technical documents

Around two months ago, I came across an awesome tool which we can use to visualize data graphically using various plots. That is a python library called MatPlotLib. Until then, I was relying on GnuPlot for drawing graphs in technical documents which has it's own syntax. However I found MatPlotLib more useful because of the language it comes with. As a Python fan, this is what I was waiting for. Moreover, I think different graphs we draw using MatPlotLib are much more beautiful and attractive than the graphs in GnuPlot.

We can easily install MatPlotLib on Ubuntu using the following command.

sudo apt-get install python-matplotlib

After the installation, we can start plotting data straightaway. Following two
sample python scripts are for drawing a graph and a pie chart. Open your favorite text editor and put the following contents in two files. Save those two files with two names as graph.py and pie_chart.py since they are python scripts. Now, just run those python scripts and it will come up with graphs in a new window. We can save those graphs into different file formats using the save button in this new window.

graph.py file


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
plt.plot(x, x, linestyle="dashed", marker="o")
plt.plot(x, 2 * x, linestyle="dashed", marker="o")
plt.plot(x, 3 * x, linestyle="dashed", marker="o")
plt.plot(x, 4 * x, linestyle="dashed", marker="o")

plt.legend(['y = x', 'y = 2x', 'y = 3x', 'y = 4x'], loc='upper left')

#labels
plt.xlabel("this is X")
plt.ylabel("this is Y")

#title
plt.title("Simple plot")

plt.show()


pie_chart.py file


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import matplotlib.pyplot as plt

# The slices will be ordered and plotted counter-clockwise.
labels = ['Frogs', 'Hogs', 'Dogs', 'Logs']
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')

plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True)

# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')

plt.show()



Here is an excellent gallery with so many examples. Happy plotting! :)

Wednesday, October 1, 2014

Three visitors to WASN lab

Thiemo, Venkat and Kasun, in UoC ground
Two weeks ago, we had three visitors to our lab from Sweden. Two of them are not completely strangers to me while the other one was a new face. The three visitors were Thiemo Voigt, Venkat Iyer and Kasun Hewage. Among them, Kasun Hewage was a student of our university and played a major role in our WASN lab few years back as a researcher. Now he is a graduate student, doing his Ph.D with Thiemo at Uppsala University. Venkat is a post-doctoral researcher working with Thiemo at the same university.

First slide of Thiemo's presentation
We had lot of important works during their stay since they are working in collaboration with us on some project works. Among different interesting things happened, I would like to highlight few events here. Thiemo conducted a nice talk about the recent research works they have done in Uppsala University and also in Swedish Institute of Computer Science (SICS). Among various works they have done, I noticed the recent trend of moving into the resource rich device based sensing paradigm from the very resource constrained sensing paradigm which we've been talking for more than a decade in WSN community. It seems mobile smartphone based IoT applications and platforms have become a hot topic.

Z1 mote connected to my laptop
Another important event occurred during that week is the two day Contiki application programming workshop conducted by them. I was lucky to attend for the first day of the workshop before I get busy in some other work on the second day. They had brought Z1 sensor motes for the workshop which was a new WSN hardware to me. Since Z1 motes contain a microUSB port on board which can be used to directly connect the mote to a PC for programming. That's very convenient and looks familiar to Sky motes. Unlike MicaZ and ScatterWeb MSB430 type motes where we need different programmer boards and special connector cables to program the motes, Z1 is very user friendly from a WSN programmer perspective.

Venkat at Contiki programming workshop
As the final event we did with them, our lab members visited Udawalawa national park with the three visitors and stayed a night there. Besides the joy of this journey, everybody had another research oriented objective during their one night stay inside a national park about which I can talk someday later with details. However, I couldn't join with them for this exciting journey due to some other work I had to do at the lab during those two days. Since our three visitors were supposed to leave right after the day they returned from Udawalawa national park, I had to say good bye to them the day before they leave for the Udawalawa journey.

During their short stay in Sri Lanka, I had few opportunities to talk with them regarding different subject related matters specially with Venkat and Kasun. I was curious to know what are the tools they use in paper works such as drawing technical diagram and so on. They were so happy to talk about different things they do and were always open for discussions. I'm so glad for the opportunity I received to talk with them during those few days and I learned a lot.

~~********~~

Wednesday, September 24, 2014

No enough space in /boot partition in Ubuntu 12.04 64bit

This morning I faced a trouble when I turned my Ubuntu 12.04 computer on. Update manager showed up with some updates however  when I go ahead to install them, it says I don't have enough space in my /boot partition. After getting crazy for a while and searching in google, I found that I should either resize my /boot partition to provide enough space or remove some unnecessary stuff from the existing /boot partition. Since the stuff in that partition are critical things such as older kernel, I was afraid about removing them. I thought the best solution would be resizing the partition but for that I need to boot the computer with a Ubuntu live CD.

Fortunately or unfortunately, I couldn't find  a Ubuntu CD for this purpose at that moment. Therefore, I left my fear behind and decided to try the /boot clearing option. I issued following long command in the terminal which ran for a while printing various outputs and finally ended. At the end, I installed the updates and it worked fine thankfully. The good open source community saved my life :)

The command to remove older kernal files from /boot partition.

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')

References:

[1] http://askubuntu.com/questions/2793/how-do-i-remove-or-hide-old-kernel-versions-to-clean-up-the-boot-menu

[2] http://askubuntu.com/questions/280211/how-do-i-resize-my-boot-partition


Saturday, September 20, 2014

A visit to CGR workshop at Rathmalana

Few weeks ago, I got a chance to visit Rathmalana railway workshop. This is where almost all the railway engines and other equipment are repaired. This workshop is dispersed over so many acres of land with different factory buildings. I went their with Dr. Kasun and few other members of the lab. In this journey, we were lucky to get into a Class S9 locomotive engine. Following are few highlights from the journey.

A factory building inside the workshop which repair railway engines.

Inside the factory.

An engine frame completely rebuilding. Perhaps it's got destroyed from an accident.

The Class S9 engine to which I got into.

Drivers view from inside the Class S9 engine.
This is something unforgettable and a rare chance. Therefore I think I will never forget about this visit.

Thursday, September 11, 2014

The lack of good pdf editor availability for linux

While having so many good free software for Linux, still I run into trouble when I have to edit some PDF document such as filling a form provided as a PDF. Due to the unavailability of a good PDF editor, I had to use an on-line PDF editor called PDFescape in this morning to fill a form. It was the first search result I got from a Google search and it did the job well. Since it is a free tool, I paid some gratitude by clicking on some advertisements.

It seems more on-line PDF editors available which I didn't try yet. However, when next time I run into trouble with editing PDF documents, I should not forget this on-line tool I discovered this morning.

Sunday, September 7, 2014

Eclipse crash while exporting APK with Android ADT plugin

When I try to export an Android app as an APK, eclipse suddenly crashes without any clear error message.  I experienced this issue with Android ADT plug-in in Eclipse sometime back and found the solution that time. Today, with a new version of the Android ADT plug-in, I faced the same issue and took a long time to find the solution by googling. It was my mistake that I didn't write down the solution in the first time. Today, I'm doing it. The solution was so simple. We have to disable automatic building functionality of Eclipse before we export the APK. 

From the menu bar in Eclipse, goto Project->[]Build Automatically and remove the tick. Now we can proceed to export the APK without any issue. After exporting, I can put the tick again.

Saturday, September 6, 2014

Brainstorming with LEGO mindstorms

Recently a fleet of LEGO mindstorm EV3 kits arrived to our lab. They are supposed to serve as some learning aid for the students who are studying Cognitive Robotics course. From the first day of the reception of these kits, I was waiting for a free time to put my hands on them. Finally, I spared some time for it. Among different sample robot designs, the one which took my attention and also the easiest one to build was TRACK3R robot since it looked like a mars rover to me.

One thing I realized while playing with the the LEGO kit is, there is a huge impact on our creativity while we are interacting with physical objects and models rather than brainstorming only with the mind. While assembling the components of the TRACK3R robot, so many beautiful ideas came into my mind about different things we can do with small robotic vehicles. Some people thinks that working with the LEGO kit is kids stuff and expressed such comments while I was working with the LEGO kit. However, I know the value of this. Therefore I don't bother about the time I spend on playing with LEGO kits.

After putting the batteries and powering up the control brick of the LEGO robot, I found a familiar friend inside it. This brick runs a version of Linux kernel. Well, that's a good news.

Friday, August 29, 2014

Recovering files from a formatted hard drive in Linux

Recently I received a request to recover some outlook email files in PST file format in a formatted hard drive. The hard drive was in a laptop which ran Microsoft Windows 7 operating system. By some mistake, the owner has formatted the hard drive and reinstalled the operating system. The requirement is to recover the Outlook emails saved in PST format.

First thing I did was booting the laptop with a 64-bit version of Ubuntu 12.04 live CD. I configured the network setup for the live booted operating system to access Internet through the Ethernet cable. Then I needed to install some tool. For that, I opened the "Update Manager" application and clicked on the Settings button which opened the "Software Sources" window. There, I should remove the check of the "Installable from CD-ROM/DVD" option and then put check on "(universe)" repository.  Now, open a terminal and give the following commands to install the required tool.

sudo apt-get update
sudo apt-get install testdisk

Once the installation gets completed, we can start our data recovery adventure. Since these PST files are so huge, we need a good external storage to hold the recovered files. Therefore I plugged-in a large enough USB drive. Run the command "sudo photorec" in the terminal to start. This tool came with that "testdisk" tool which we installed. When this tool open in the terminal, there are many options you can do. Since it's hard to explain everything, I will just mention the most important things.

Once we open the photorec tool, it will show our hard disk in the laptop. Select the "Proceed" option which will take us to show the partitions inside the hard disk. In this new window, you will see four options and among them what is important is "[File opt]" option where we can select the types of files which we want to recover. Since I wanted only .pst files I just kept the check for that file type and removed the rest. Finally, select a particular partition and take the "[ Search ]" option to start searching for the specified file type in that partition. A destination directory should also specified where the recovered files will be saved. I chose my USB drive as that destination.

The recovery will take a long time depending on the size of each partition. Once the recovery is completed I got the recovered .pst files in the destination directory. These files should be importable into Microsoft Outlook. In case we need to convert the recovered .pst files into some other format, for example for exporting into Gmail or Thunderbird, we need some conversion tool. One such a good tool is "readpst" which we can install from the following command even though I haven't used it for some serious work.

sudo apt-get install readpst

I hope all these tools will help someone to recover their lost data.

Wednesday, August 27, 2014

Preparing letters with Latex

A lot of Latex stuff these days. Today I had to prepare an official letter for a purpose in our lab. I used Latex for it and for that, I had to search in Google and find out the relevant Latex tags. Here is the basic structure of a Letter prepared in Latex.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
\documentclass{letter}
\usepackage{hyperref}

\signature{Asanka Sayakkara}
\address{University of Colombo \\ Schoool of Computing (UCSC), \\ Reid Avenue, \\ Colombo 7, Sri Lanka.}
\longindentation=0pt %for keeping the signature at left side

\begin{document}

\begin{letter}{Dr. Carl Sagan \\ Cornell University, \\ USA..}

\opening{Dear Sir,}

\bigskip
\centerline{\textbf{The title of my formal letter}}

\bigskip\noindent

First paragraph of this letter..

Second paragraph of my letter.

Thank you for your time and consideration.

\closing{Yours Faithfully,}

\ps

\end{letter}
\end{document}

Even though in the first time we need some effort to have a basic structured file as the above one, later we just have to edit the content according to our requirement. Therefore  using Latex for even this kind of simple requirements is a very good idea.

Friday, August 22, 2014

Making Presentations with Latex

When preparing documents such as  research papers, reports, thesis works and even for preparing my CV, I use Latex. However until recently, I didn't use Latex for preparing presentations. I was relying on open source presentation programs such as OpenOffice and LibreOffice when preparing some slides. Finally, I got a chance to explore presentation slide preparation using Latex.

What we need first of all is complete package of Latex for GNU/Linux. I'm using Ubuntu 12.04 and I installed Latex complete package using the following command.

sudo apt-get install texlive-full

It may take a long time to complete the installation since there will be lot of packages installing with huge sizes. After the installation completed, we can move onto try some Latex script. Create a directory called 'Presentation' and save the following content inside that directory as 'slides.tex'. It just contain the minimum things we need in presentation slides. You will note that we are using a document class called beamer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
\documentclass{beamer}
\usepackage[latin1]{inputenc}

\usetheme{Warsaw}
\title{This is the title of the paper}
\subtitle{here is the subtitle}
\author{Author Name}
\institute{Institutions Name, Address.}
\date{August 22, 2014}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}{First Slide}
A sample page
\end{frame}

\begin{frame}{Second Slide}
Here is a list of some items.
\begin{itemize}
\item my first list item
\item this is the second item
\item we can have many more
\end{itemize}
\end{frame}

\end{document}

From the terminal, move into this newly created directory and issue the following command sequence, one after the other, to generate our slides in PDF format and view it.

latex slides.tex

dvipdf slides.dvi

evince slides.pdf &

We can extend this basic structure of the latex presentation into any type of complex presentation using tables figure and many other things just like we make them in other Latex documents.