From the window of my house to Masjid AlAqsa

I live near a certain Masjid Al-Farooq, as has been shown in the map below. Hint: I live somewhere to the right. Thats it! No more Hints..




If maybe I make a tower large enough, and with a telescope that defies the normal laws of 'light travels in a straight line', I can see Masjid Al-Aqsa right above the Masjid Al-Farooq, Hyderpora.

Maybe!

Maybe.

Or I could just see Iron Man.








Ok Bye!



comments

Stories about Internet of Things, Kashmir and Weather. #IoT

Through some snooping around on the Internet, I managed to locate a SYNOP code being generated somewhere from Srinagar, Kashmir.


Its interesting to be able to visualize all the data that is available publicly. thingful.net is one such promising interface for the Internet of Things (IoT). Currently, its mostly based on xively and some other general feeds, but pretty impressive nevertheless.

So I was scanning around, and zoomed into Kashmir, India. I saw a feed being generated from Sringar. A SYNOP feed to be exact.

After some snooping around without even bothering to look what SYNOP meant, I found the source of the data at this location:


Fig 1: Too close to home (Click to Zoom)

A picture taken by a certain Mr. D. B. Malhotra gives a clearer picture:

Fig 2: The meteorological complex. All the heavy honking near that place could be presented because of technical reasons. (Click to Zoom)

Every three hours it senses, and generates data like this:


42027 31595 50000 10072 21015 38393 48481 70510 83420
      333 59009=

where 42027 is the World Meteorological Organisation (WMO) number of our beloved, local Kashmiri station. It contains 420, just like the rest of us Kashmiris do. (Refer to: Chaar Sou Bees - Four Hundred Twenty). 420 is a magic number in India. It is an urban slang word to refer to dishonesty. You definitely would want to read this article on Wikipedia for more about the origin and the movies.

For the geeky people, you can check the weather from the feed generated at this website. Just enter our magic number 42027 there. Go wild, make some Android apps.

Alex Smart questions : "Why so many URLs bro?"
I answer: "That's what research does to you."
comments

Perlc usage | In an aim to make an object file of a perl script.

http://marginalhacks.com/bin/perlc
I was searching for something like a Perl executable to make an object file so that compilation is not necessary. Found that some tools do exist, such as perl2exe, perlapp and an outdated perllcc tool.

I just thought of writing this article to show the usage of the tool, as some beginners (like me) may end up confused.

So imagine you have a script to copy some stuff from one place to another, and you have named it as 'perlcp' and saved it with the extension of '.pl'.

So imagine you were searching online for a script that would help you make an executable of your perl script or try to make a '.c' file for whatever reasons you have. You copy this code and save it in a perlc.pl.

And you have already installed perl before, and have already thought of leaving your job and becoming a monk.

Eventually to output a perlcp.c file, this is what you need to enter at the prompt:

perl perlc.pl -d perlcp.pl


and to make an exe:




perl perlc.pl -exe pearl perlcp.pl



This is the same approach used in this xkcd cominc





No wonder beginners get confused.








comments

Getting the battery consumption in a COOJA simualtion


The end of the year is coming near, and the different project and researches are wrapping up. That also means unnoticed problems, occasional headaches, and tummy upsets for some staff. Luckily I am not so stressed, and I have nothing to wrap up (per se). Right now I am experimenting with XBee on an Arduino.

I made this small application. I kept an XBee Arduino setup with me, and gave another one to few of my colleagues (read as friends) who are working in another lab. They can press a button on their setup and metres away I will be notified that they are looking for me.

Apprantly they started calling me to close their door, to throw the trash, and the occasional itch.

Could they be punished each time they call me?

I installed a shrill speaker thing on theirs, which beeps a few times whenever they click the button, whereas I hear a nice square wave based music tone.

Nope! Didnt stop them.

Then I gave them the condition that they can only call me 3 times a day, and I will maintain a log of it. (Programming and debugging does mess up a mind)

They called me 3 times in a minutes. I went there. They said it was by mistake the first time, the thing fell down the second time, and third time they lifted it up and put it back.

Now, I have just unplugged my side of the thing.


In other news, COOJA gives me the same set of battery voltage values for some (undisclosed) code:





I don't really know why, and I haven't had the motivation to search for it online.

Now is the time to test it on real Z1 nodes. Now is the time to get the hands dirty (umm pants dusty)

comments

Big Hiccup while renewing the domain

So its that time of the year when Google starts asking me for money.

Google has been a pretty good service provider ever since 2006 when I first started my adventures in the realm of domains.

This time it wasn't such a breeze.

My bank wasn't allowing Google to add my Credit Card details. I have to write them a letter too.

Finally, the domains are paid off. And I can enjoy the rest of this year without much worries.

The 'Kashmiri Songs Sections' has had a major facelift. The new look can be accessed at downloads.qazimamoon.com whereas the classic look is now archived at kashmirisongs.qazimamoon.com

In other news, my IIUM convocation is going to take place on the 18th of November.

Few things I observed about the robe.

1. It gets really hot when you put it on.
2. It really really gets really hot.
3. (Takes off robe)

I was planning to suit up in a nice tuxedo. Bad idea.



OLD LOOK:


NEW LOOK:




Hope the new look is better.

comments

ThinkPad T440 HASWELL is here

Got an email from Lenovo. The Lenovo Thinkpad T440 is available for purchase in the US of A.

Ah! The beauty..

http://shop.lenovo.com/us/en/laptops/thinkpad/t-series/t440/

Waiting for it and E440 to hit the Malaysian markets.
comments

Rest in Peace Mattoo Uncle.

A disciplined teacher, a loving uncle. Dear Mattoo Uncle. May Allah grant you with eternal Jannah.

I remember learning some of my first few things from Mattoo uncle about science. When all others were learning how to multiply, I was writing H20 and O2 with chalk; and taking care to mention that one was water and another one was oxygen. I was fascinated with chalk, which I found in their attic. I was fascinated with science because of chalk. I wanted to write something smart with chalk, like my scientist uncle. So what my chemistry-aware-father didnt teach me, my uncle did.

May Allah bless him and his family and give strength to Masi, and the twin girls and the son.




comments

Storage Space Running Out With WiFi on Android | Solution

One of the readers posted this following question in one of my earlier posts on a similar problem faced by users:

"Thanks for your valuable support.Only One quarry is that i delete log folder them my memory come back but when i on Wi-Fi continuously then automatic my free space of internal memory leaps from 10.0 Gb towards 0 MB .Pls Give solution i m really afraid that what happen whith my Samsung Note-2 phone."

Rewriting the problem in my style:

"Whenever I keep Wifi on, my free memory always gone!"

So the problem could be a lot of logs being created either when the wifi is getting initialised or due to some debug statement getting executed repeatedly. If updating firmware, or other workarounds did not work, then try this desperate workaround:

1. Root your phone. For a general idea or a step-by-step method for S2 I9100G (which is my phone) refer here.
2. Download the Root Browser app fro here:
 https://play.google.com/store/apps/details?id=com.jrummy.root.browserfree&hl=en
3. Reboot
4. Open the newly installed Root Browser app, a pop up will come stating if you want to give the app root permission. Grant it.
5. Navigate to /system/bin and look for the file named: "dumpstate"
6. Touch the file for a few seconds (Right Click???) to get the options for the file, and select "Permissions".
7. Untick/Uncheck all the marks under the "Execute" Permissions column.
8. Navigate to /data/ and delete the folder "log".
9. See the magic :)

I don’t guarantee that you will fix the problem but it’s a good start nonetheless.


comments

Rowan Atkinson Converts to Islam | Or not?


So I was doing my daily surfing of the Internet, and somewhere I read that Mr. Bean or Rowan Atkinson had converted to Islam. 

I did a quick search to see what came up. Here is a screenshot:


So is Wikipedia a good source for information?

Yes it is!

But not today..

I am sure this rumour must have started somewhere in Pakistan, because its most of the websites ending in .pk which are posting this.

For those of you still confused, he hasn't converted. So stop being all giggly giggly.. There is no legitimate source of this news.

Alex Smart Said: : "Mr. Bean has now converted to Islam and renamed himself as Mubeen"
comments

ThinkPad E440 release date

The new model in the Lenovo lineup of ThinkPads appears to be a beauty. The ThinkPad E440 is the Haswell version for the famous E430 and E431 lineup of the ThinkPad EDGE series.

I am waiting eagerly for this marvel to be  released. Read somewhere that it will be around middle of November.

It will have intrinsic support for the ThinkPad OneLink Dock which is like your I/O on steriods. It features a touch screen, which might not be particularly useful for me, but then its cool to have one. Just hoping the resolution increases a bit as a standard for all the models. Hello its 2013 already.

Ahhh I can't wait for it.  Even the E431 is so delicious. While my mind tells me to wait for a few more months, my heart wants it right away.



Coming Soon at http://shop.lenovo.com/us/en/laptops/thinkpad/edge-series/e440-touch/


Aah, the beauty..
comments

IIUM Convocation 2013 Fiesta coming soon

Wheee.. The time is flying fast. Next month would be the robe collection, and then would start a series of photo taking and sweaty eyebrows.

The days from 16th November till 18th November are going to fly. Festive mood, families from everywhere.. Ahhh my turn at last..


comments

SOLVED | VirtualBoX | Guest OS Inaccesible


 So I want to work with Instant Contiki, and do some more coding when I get the shock of my life.

Instant Contiki Inaccessible.

All my work inaccessible.


The screen shot of the potential-heart-attack situation is attached: (Click to view a larger version)


Basically the following error was generated:

Runtime error opening 'C:\Users\Mamoon\VirtualBox VMs\Instant Contiki\Instant Contiki.vbox' for for reading: -102 (File not found.).

D:\tinderbox\win-4.2\src\VBox\Main\src-server\MachineImpl.cpp[724] (long __thiscall Machine::registeredInit(void)).

Result Code: E_FAIL (0x80004005)
Component: Machine
Interface: IMachine {22781af3-1c96-4126-9edf-67a020e0e858}

 Luckily I found this solution here:


"Look in the folder that has the guest and see if there is a *.vbox-prev file. If so (make a backup of it) and rename it to remove the -prev."


Renamed the thing, backuped the file and ran VirtualBox. Folder looks like this now.



There, good as new.. Better to back up these files somewhere on the Cloud before I lose months of work, thanks to a silly shutdown issue.



comments

Packet Delivery Ratio Formula

The total packets received at the receiver divided by the total packets originally sent.
comments

Storage Space Running out on Android | Solution

Samsung S2 delete system log
Android delete system log

My Internal Storage was full, and I had no idea what was eating all the memory. I deleted all my apps (including Candy Crush :( Sigh ) in an attempt to increase the memory. None of my apps were getting updated, and the phone was laggy.

And the solution was pretty simple..


The files in "Internal Storage" cannot be browsed using a normal file browser because inherently Android states that files in this storage be 'private'.

I figured there must be something inside that is roughly the size of 10GB..

1. Root your phone. For a general idea or a step-by-step method for S2 I9100G (which is my phone) refer here.
2. Download the Root Browser app fro here:
 https://play.google.com/store/apps/details?id=com.jrummy.root.browserfree&hl=en
3. Reboot
4. Open the newly installed Root Browser app, a pop up will come stating if you want to give the app root permission. Grant it.
5. Navigate to /data/ and delete the folder "log"
6. See the magic :)


The log folder in my case was full of trash since 6 months. The screenshot below shows the contents of the 'log' folder.

Each entry is around 600 KB in length. Every day around 7-10 of such entries were created by my phone. Every day!!!

Every day since Feb 5 2013.. and today is August 14.



And then I deleted the 'log' folder. Volia:



Unfortunately, I didnt take the screenshots earlier as I had no intention to blog about it. But just imagine the blue bar all the way to the right, stating only 150+ MB of free space instead of 1.5 GB.



Happy Happy :D What a simple solution to the irritating problem of the internal storage space running out constantly. Hurray
comments

How to root the Samsung Galaxy S2 I9100G on Android 4.1.2 Jelly Bean | Easiest Way

Rooted on 14 August 2013.

This is the easiest way to root your Samsung S2 phone. It just requires one download, and you don't root it via the USB connection technically.

This works for S2 I9100G only and may not work for other Samsung s2 variants.
Other warnings regarding rooting a phone apply here as well, such as related to warranty, bricking your phone. These steps worked for me, but may not work for you. So don't blame me if you make a mistake somewhere.


Check list
1) Install the appropriate USB Driver for Samsung GalaxyS2 on the computer. Basically if you can connect your phone to your computer to browser the files, then you are done.
2) Ensure that USB Debugging Mode is enabled. [Press Menu>> Settings>> Applications. From there navigate and click on Development option and ensure the USB Debugging Mode is turned on.]   
3) Create back-up for all the data of the phone.  This is important. You don't want all your contacts to disappear. Use the program Samsung Kies to automate the backup/restore procedures.


Procedure to root the Samsung Galaxy S2 I9100G working on Android 4.1.2 Jelly Bean

1) Download Rooting package [File name: SU-BB-Installer.Zip] for Galaxy S2 I9100G to the computer. Let me know if the file is no longer there.
2) Connect the phone to the computer using USB cable and copy the downloaded zip file to the external SD card of the phone. It may come up as "Card" in your device under "Computer".
3) Unplug the USB cable from the Galaxy S2 and turn it off
4) Boot the phone into Recovery Mode. Press and hold Volume Up + Home + Power buttons together. Release the Home button first then the Volume Up until the Samsung logo appears. Now release the Power button.. Try other combinations of releasing and pressing if this doesnt work.
5) Using the Volume buttons scroll down to 'apply update from external storage,' select it by pressing the Power button. Then locate the SU-BB-Installer.zip file which is saved on the SD card. Select it using the Power button and confirm installation. The process took about a minute for me.
6) Once the installation is completed, return to the recovery menu and reboot the phone by selecting 'reboot system now'



Actual Source: http://www.ibtimes.co.uk/articles/445625/20130313/galaxys2-i9100g-root-android412-jellybean-install-clockworkmod.htm
comments

Sample Template for EIT report at IIUM



Do you want to have a skeleton structure to work on for your Engineering Industrial Training Report. I have removed some sections so that I dont divulge all information about the company or my work there. But you need a sample dont you.


Part One:

https://dl.dropboxusercontent.com/u/82944466/QM_PartOne%20.docx


Part Two:

https://dl.dropboxusercontent.com/u/82944466/QM_PartTwo.doc
comments

29th IIUM Convocation 2013 POSTPONED

According to the new schedule released by IIUM, the convocation will not be on 26-28 October 2013 but instead from 16th November 2013 until 18th November 2013.There will be a total of six sessions.

The official website can be visited at http://www.iium.edu.my/convo

The official facebook page by the committee can be visited at https://www.facebook.com/convest13




comments

Air Pollutant Index- API Malaysia/KL is less than 150 ppmv

June 24 2013- 5 pm

Four of the index's pollutant components (i.e., carbon monoxide, ozone, nitrogen dioxide and sulfur dioxide) are reported in ppmv but PM10 particulate matter is reported in μg/m3.

Right now its less than 150 for KL.. But unless it rains, the levels are going up.



Indera Mahkota, Pahang:
< 150 ppmv
Batu Muda, Wilayah Persekutuan:
< 150 ppmv
Kemaman, Terengganu:
< 200 ppmv
Balok Baru, Kuantan, Pahang
< 200 ppmv
Petaling Jaya, Selangor:
< 200 ppmv
Port Dickson, Negeri Sembilan
< 300 ppmv
Bandaraya Melaka, Melaka :
< 400 ppmv
Muar, Johor:
< 550 ppmv

Caution: People are coming up with these anti-virus air purifiers.. These will do nothing to affect the suphur or carbon oxides.. Best way is to steam your room, and then use air-conditioner to condense it back.. The steam will absorb much of the gases present.


Source: NEWS
comments

Basic Tutorial for using the PowerTrace Tool in Cooja and Graphing the Output. #Contiki #IoT



We will be using a tool called PowerTrace. This tool is believed to be 94% accurate to determine the power consumption for many functions such as during cpu usage, radio transmission, radio listening etc.

First we import the matplotlib to enable functionality for creating a nice graph using Python. I am assuming Python is present in your system:

sudo apt-get install python-matplotlib

To include the functionality of PowerTrace in your code. Simply add the following line after "PROCESS_BEGIN()" for your code.

powertrace_start(CLOCK_SECOND * 2); 

Dont forget to include the header file:

#include "powertrace.h"


Next, go to file called "Makefile" in your working folder, and add the following line (near the top would be good)

APPS+=powertrace

After running the simulation, it generate a lot of powertrace data on the mote output window (roughly every two seconds) outputting a wide variety of number as shown.


These values are actually:

str, clock_time(), P ( rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1] ), seqno, all_cpu, all_lpm, all_transmit, all_listen, all_idle_transmit, all_idle_listen, cpu, lpm, transmit, listen, idle_transmit, idle_listen, followed by some mathematical numbers..

Check Line 116 here for other details.

We save this data to a text file "loglistener.txt" on the Desktop (Check the File menu for the mote output window.)

Run the following python script on the Desktop to plot CPU vs Time (as an example):

#!/usr/bin/python
#!/usr/bin/env python

import csv
import matplotlib.pyplot as plt

# for P lines
#0-> str,
#1 -> clock_time(),2-> P, 3->rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1], 4-> seqno,
#5 -> all_cpu,6-> all_lpm,7-> all_transmit,8-> all_listen,9-> all_idle_transmit,10-> all_idle_listen,
#11->cpu,12-> lpm,13-> transmit,14-> listen, 15 ->idle_transmit, 16 -> idle_listen, [RADIO STATISTICS...]


from collections import defaultdict
cpuOverTime =  defaultdict(list)

with open('loglistener.txt', 'rb') as f:
    reader = csv.reader(f,delimiter=' ')
    for row in reader:
        if row[2] is 'P':
            cpuOverTime[row[3]].append(row[11])

for i in cpuOverTime:
    plt.plot(cpuOverTime[i])
plt.show()
########## 
 

If everything goes well, a nice looking graph should come up.





comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 7

Part 1 in this series can be found here.
Part 2 can be found here.
Part 3 can be found here.
Part 4 can be found here.
Part 5 can be found here.
Part 6 can be found here.



This post will discuss how to pass a variable from one process to another. This is also the method how to unblock another process from one process. We need this code to invoke that:

process_post(&process_2, the_event_signaller_thing, &any_variable_we_want_to_pass);


"the_event_signaller_thing"will have to be declared as type: static process_event_t and later allocated from process_alloc_event();

Here is a fully functional code for you to copy paste and play around:


#include "contiki.h"
#include < stdio.h >

static process_event_t ourEventIsReady;
/*This will be used to signal the event*/

PROCESS(process_1, "This will pass the variable and post an event");
PROCESS(process_2, "This will receive the variable and wake up");
AUTOSTART_PROCESSES(&process_1,&process_2);

//***********************************************************
PROCESS_THREAD(process_1, ev, data)
{
PROCESS_BEGIN();
static int ourVariable = 99;
/*Make sure this is static or you will get a value
of 0 each time you compile. Luckily it took me no more
than 2 minutes to figure my error*/

ourEventIsReady = process_alloc_event(); 
//Allocate the event

process_post(&process_2, ourEventIsReady, &ourVariable);
//And then send it to process_2..

PROCESS_END();
}
//***********************************************************
/*Process_2 will be blocked until ourEventIsReady is passed to 'ev'*/
PROCESS_THREAD(process_2, ev, data)
{
PROCESS_BEGIN();
PROCESS_WAIT_EVENT_UNTIL(ev == ourEventIsReady);
printf("Variable is %d \n", (*(int*)data));
/*
(*(int*)) is necesaary to convert 'data' into a proper integer.
Argument 'data' type is actually a process_type_t, so 
it will give a warning and display the pointer
if we dont include the *(int*) thing first.
*/

PROCESS_END();
}
/*
As can be seen I didnt use any while() loop.
*/


The output looks like this:





comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 6


Part 1 in this series can be found here.
Part 2 can be found here.
Part 3 can be found here.
Part 4 can be found here.
Part 5 can be found here.


I want to focus on power consumption on this post before I go into the details for networking. It is important to know how your algorithm does on the power consumption side.

Contiki has a software-based power-profiler which can be used for this. Few lines of code have to be added in your program to enable that. But there is also another way.

We will be using MSPSim's power-profiler.

This method wont work on all the mote types, because the tool 'Msp CLI' works for only MSP430 microprocessor series [Reference]

We will be using the Sky Mote Type for this. I used this code for generating a "Multiplication Table of 5" in the Sky Mote for this example.

Now..

Right Click on the Mote in the 'Network' window and then 'Mote Tools' & 'Msp CLI'. A Msp CLI dialog box should open.

Type:

>duty 1 "MSP430 Core.active" CC2420

Press Enter.

The output for my case was:




After reading this and bit of a guess leads me to:

The first column is the percentage of CPU activity. This is generated because of the "MSP430 Core.active" argument.

The second column is the percentage of time for radio power down.
The third column is the percentage of time for radio power up without transmission. (If I am not mistaken)
The fourth column is the percentage of time for radio transmit.
The fifth column is always 0.0 no matter what code I run, so I dont know what that does.


Notice the last 4 should add up to 100.

Here is another example (Source: ...contiki2.6/examples/sky/radio-test.c):



It shows the CPU is active 18.93% of the time.
Radio is off 87.72% of the time.
Radio is on 2.98% without activity
Radio is transmitting 9.3%
Radio shows 0.0 (always; even with a bit of reception).



So how to calculate the power consumption??

Multiply the total simulation time with the % above to get total time for a certain activity.

Then multiply with the standard power consumption which can be obtained from some data sheet.

e.g Data Sheet of Tmote Sky states:

e.g for Radio Transmission

Total_Energy = 19.5 * 3 V * (Activity_Time_in_seconds)
(Remember Power= Voltage x Current)

I dont know why they divide specifically by 4096..They describe it as each second containing 4096 ticks of cycles only. I am still uneducated why, as a Tmote Sky is not 4KHz speed device. May they are just referring to the CC2420 radio. Sigh! Only if things were nicely documented. Not everyone understands English in the same way.

Laters in PART 7

comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 5


Part 1 in this series can be found here.
Part 2 can be found here.
Part 3 can be found here.
Part 4 can be found here.






Let see how to use a timer to display a multiplication table of 5 on the serial port.
#include "contiki.h"
#include < stdio.h >
PROCESS(hello, "Table of 5");
AUTOSTART_PROCESSES(&hello);
PROCESS_THREAD(hello, ev, data)
{
static struct etimer  timer;
static int i;
PROCESS_BEGIN();
while(1)
{
etimer_set(&timer, CLOCK_CONF_SECOND);
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER);
for(i=1; i < 11; i++)
printf("5 x %d   =  %d\n", i, i*5);
}
PROCESS_END();
}


I deliberately didn't include any comments here. This is where you should stop and write your own comments based on what you understood. If you think the code above doesn't make sense, then I believe you went too fast. Upon successful compilation, the output should continuously scroll. Something similar to this should be displayed:
comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 4

Part 1 in this series can be found here.
Part 2 can be found here.
Part 3 can be found here.



Now we have got our 'Hello World' process running nicely on a mote. Now we are ready to make things more interesting. Let's now focus on the stuff that comes between  PROCESS_BEGIN() and  PROCESS_END().

Presented next is a modified snippet of the source code I took from this website. This is another example of a 'Hello World' process, but it introduces some new concepts related to process blocking and then unblocking via a timer (I am trying to reduce the technical jargon so do excuse me if it may not sound correct).

PROCESS_THREAD(hello_world_process, ev, data)
{
/* variables are declared static to ensure their values are kept
each time the kernel switches back to this process */
static struct etimer timer;  //Code to declare a timer. MEMORIZE
static int count = 0; //Just a counter

PROCESS_BEGIN();


/*Set the length of the timer to one second
In Contiki  (CLOCK_CONF_SECOND is equal to 1 second. */
etimer_set(&timer, CLOCK_CONF_SECOND);



while (1)
{
// This will block the process until a kind of event happens
PROCESS_WAIT_EVENT();

// This specifies the event that we are waiting for to be a timer
if(ev == PROCESS_EVENT_TIMER)
{
// do the process work
printf("Hello, world #%i\n", count);
count ++;

/*By adding 'etimer_reset(&timer);' in the end of the functional code
the process will runs again and again. This will reset the timer.
This is done to loop the event generation mechanism. As can be seen, the
while() loop is just for the event listener.*/
etimer_reset(&timer);

}
} //keep doing this

PROCESS_END();
 
}

An alternative way to reset the timer is just include the initialisation of the timer variable inside the while() loop.
This way we dont have to worry about putting etimer_reset(&timer) at the end of the code. This way the while() loop will take care of both the event listener and the event generator.

while (1)
{
etimer_set(&timer, CLOCK_CONF_SECOND);

PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
/* The above statement is able to replace the two earlier statements of:
PROCESS_WAIT_EVENT();
if(ev == PROCESS_EVENT_TIMER)
{}
So consider it an alternative. I got confused when I first learnt this so
I hope this makes it easier for the readers.
*/


Sorry I dont indent my code properly. Maybe next time. :)


PART 5
comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 3

Part 1 in this series can be found here.
Part 2 can be found here.


The next question that arises is that can we include additional processes in a file. The answer is Yes! But these processes will be concurrent. This means that they can be executed in parallel.

/*We declare two processes*/
PROCESS(process_1, "The first process");
PROCESS(process_2, "The second process");

/*The next step is to use AUTOSTART_PROCESSES. Luckily we can 
specify both of our processes in a single function call. */
AUTOSTART_PROCESSES(&process_1, &process_2);

/*The process definition for the first one*/
PROCESS_THREAD(process_1, ev, data)
{    
PROCESS_BEGIN();
/* Some Code*/
PROCESS_END();
}

/*The process definition for the second one*/
PROCESS_THREAD(process_2, ev, data)
{
PROCESS_BEGIN();
/* Some Code*/
PROCESS_END();
}


So far so good. But we still haven’t done anything useful. Let's start with a basic hello world being printed. Being printed where? On the serial port. Under Cooja, you can go to Tools> Mote Interface Viewer > (Select your mote) > (In the drop menu) Serial Port.

You can also see it in the 'Mote Output' dialog box.

#include "contiki.h"
#include < stdio .h >
/*Notice I have include the standard I/O file header. This
is for enabling printf functionality */


PROCESS(process2, "Our first Hello World"); //Declare

AUTOSTART_PROCESSES(&process2); //Start


PROCESS_THREAD(process2, ev, data) //Definition
{
PROCESS_BEGIN(); //Here we go

printf("Hello World \n"); //A simple printf 
            
PROCESS_END();

}

After simulating this code, the output looks happy:




See you later in Part 4.

comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 2

The first part goes here


Now that I have understood the concept of threads, I will move on to something called ProtoThreads. Here is the basic code.



//To use protothreads (PT)
//first are foremost you need the header file, 

#include "pt.h"

//Now we have to initialize a PT, which is simply:

struct pt pt; 


//-------------------------------------------------------
//-------------------------------------------------------

//Last time we used PROCESS_THREAD(basic, ev, data) 
//but now we change to PT_THREAD
//'Example' is the name of process being declared
PT_THREAD(example(struct pt *pt)) 
{
PT_BEGIN(pt);
    
    /*
    Have to include code here what we want to do
    This portion lets the protothread wait for events indefinitely.
    It uses an infinite loop
    */

PT_END(pt);
}


/*
In memory constrained systems, traditional multi-threading may 
have a too large memory overhead. Each thread requires its own 
stack that may use large parts of the available memory. 
*/


/*That is where the ProtoThread solution proposed by the creator of Contiki is helpful. ProtoThreads 
 do not require their own stack. 
Each protothread takes two bytes of memory.
One thing to be careful is to limit use of local variables here.
And do not use SWITCH() statement ever.
*/




What I did was save this code as a .c file and dumped it in the Z1 examples folder and tried to compile it on a z1 mote. An error came up:

(Output truncated)
obj_z1/contiki-z1-main.o: In function `print_processes':
/home/user/contiki-2.6/examples/z1/../../platform/z1/./contiki-z1-main.c:169: undefined reference to `autostart_processes'
obj_z1/contiki-z1-main.o: In function `main':
/home/user/contiki-2.6/examples/z1/../../platform/z1/./contiki-z1-main.c:415: undefined reference to `autostart_processes'
collect2: ld returned 1 exit status
rm obj_z1/contiki-z1-main.o basicTemplate_ProtoThreads.co
Process returned error code 2
make: *** [basicTemplate_ProtoThreads.z1] Error 1


I dont know (yet) the working of the internals of Contiki, but I got the code working (compiling incorrectly but still ).

I just added this towards the end

AUTOSTART_PROCESSES(&basic);  

And it worked.. I need to research more why this happens, or if there is a suitable function for protoThreads that can be used to replace, or if I am just missing something in the big picture.


Will update it here once I find out.



Part Three can be found here.
comments

Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 1

During my undergrad I took a course on Operating Systems. It was pretty fascinating to know how operating systems have developed over time and how they worked. Nevertheless, I didn't find much to try to devote to this subject. I was a computer engineering major not in ICT, so my subjects varied all the way from VLSI design to Multimedia technology.

But now I have this great opportunity to learn.

For someone with limited programming experience learning to adapt to programming at this level is not easy. Here I will try to post whatever I am learning for comments, and future notes. Hope I get this all correct. I wont be using advanced technical jargon here, but just enough to make some sense. I will try to keep the description as layman as possible.

Let me start with the basic structure of any code. This code will be run on any individual node, and will have to be downloaded (installed/ported) to a node. This can be done in a simulation and then on a proper hardware device. The easiest way to get started is to download Instant Contiki and run it as a virtual machine. I used Oracle's Virtual Box myself for the virtualisation.


//First are foremost you need this header file

#include "contiki.h"

//Then just like we initialise functions, we need to
//initialize a process

PROCESS(basic, "This is just a basic template");
//The word "basic" is the name of your process which you will 
//be using in later functions. Basically
//it is the declaration of the process
//The text in "" is for a short description


AUTOSTART_PROCESSES(&basic);  //Start the process

PROCESS_THREAD(basic, ev, data) //Here goes the definition of the 
//process

{
PROCESS_BEGIN();
//Always try to put any code after this.


//Can initialise stuff using static keyword. 
//Will tell you why in the next block of comments.

/*
Have to include code here what we actually want to do
This code in this portion lets the process wait for events indefinitely
by compulsorily including code for an infinite loop
This is something called as a blocking macro.
Actually, here the process returns to the kernel (to enable 
the kernel to call others) 
and process enters a blocked state. 
When an event is posted, the kernel will 
call back this process which will jump right
after it returned before. 
This may sometimes change the values of the local variables, 
that’s why we are supposed to define them as static. 
*/

PROCESS_END();
//End the process. Notice no arguments.

}


The structure of the blocking macro will be roughly like this:


while(1)

{

//Wait for some external event
//Or wait for a timer to finish
//Or wait for some internal event

//And then do something..

} 

Now the most important question is how to use this code.. If you save the above code on your desktop, and try to simulate it on Cooja on lets say a 'Z1 mote', you will get this error:


make basicTemplate_Threads.z1 TARGET=z1
make: *** No rule to make target `basicTemplate_Threads.z1'.  Stop.
Process returned error code 2



So to get your code working, just copy the source file to the Z1 folder located at
Home/contiki-2.6/examples/z1 and then use that to compile on your simulated z1 mote.

For other mote types, just copy to the corresponding folders. This is the easiest way to get it working.


Part 2 of this series can be found here.
comments

Zarum Na Durer Khuda Gawah Chum


Download the famous song "Zarum Na Doorer Khuda Gawah Chum" by clicking the link below:

http://downloads.qazimamoon.com/home/Zarumnadoorear.mp3?attredirects=0&d=1


Thats all :) Hope it helps.
comments

IIUM Convocation 2013



According to the schedule released by IIUM, the convocation will be 26-28 October 2013. And some people are saying that  this year's Ummatic Week will be organised together with the convo.




Looking forward for this 29th IIUM Convocation. After all, this is finally my chance to put on the robe and walk down the stage on CAC.


comments

Dinner at Mali's Corner | Dana Kota

So feel like eating at that place tonight.

Here is the fantastic Char Kuey Teow they serve.

Doesn't it look delicious :D

Btw: These are rice noodles cooked with prawns..




comments

Random Edit to Blog

There is now a goat on the top right..


No specific purpose.. Might make a few people interested in this dying blog.



comments

Some of my interests are



So my LinkedIn profile states that:

Interests: Information Security, Network Security, Networking, Social Engineering, NMAP, C, Web Technologies, Internet, Linux/UNIX


 These are my interests true, but professional interests. I would like to see myself as a person having quite a handy bit of knowledge on one, or many of them. 

I really want to include stuff like

1) Cooking
I would love to create something and relish it.. Yumm

2) Piano Playing Like An Expert
I can key a few seconds of "Fur Elise", "Turkish March", and millions ob bollywood hits. But I would like to be able to play on real big big big piano when everyone is looking and people go like "Wooow Wooow"

3) Kashmiri Songs
Something I set up a website for. This goes in direct relation with my interest #3. So I sing Kashmiri songs while playing my paino (instrument) on a violinishhhhh tone... AaaaaaaAAaaaaAaa

4) Robotics and stuff
Watching a robot jump around is cool.. Yaay or nay?

5) ART
Best for the last. I love to sketch, and draw stuff.. I am good at copying stuff, as in see something in front of me, and then try to sketch it. I am bad if it requires guess work. Maximum I will come up with are abstract shapes and few trees..


 
comments

Ixnay on the oggieday

I just came to know there is a language game called as "Pig Latin" in English. 

Here is how my name sounds in it:

Aziqay Amoonmay Shrafay..

Which is kind of cool.


amscray , amscray, amscray, amscray
comments

Somethings are better left unsaid



I am walking around in one of the buildings of Kulliyah Of Engineering. I passed by one guy who used to be my tutor few years back for "Differential Calculus". Without a second thought, I presented a smile and gave Salaam. Then I asked him a question that should be never asked.

Brother, have you finished with your PhD?

His smile shook, and his eyebrows twitched. He replied, " Umm, in the middle of it."

I realized I wasn't supposed to ask that question. I was better off asking him about his pay or if he was a girl; his birthday or phone number.


Lesson Learnt.. Master is going to be fun.. :S
comments

My first class after Bachelors



My first class at IIUM as a masters student.

So these are my fellow students. They look pretty normal.

One of them has been my lab demonstrator few years ago for 'Digital Logic Design'.  I remember her as the person who wanted to find a good boy for her sister. (She thought I was social, knew many) I remember that day as the start of a long phase of having to avoid her.

One of them kept interrupting the Professor. Too proud eay? I have never witnessed this kind of audience. He just wanted to interrupt everything. Well, maybe its normal at this level. All I know is that we used to be silent lambs during our bachelors. Counting the seconds till the end of the misery.

One thing I couldnt fail to notice was the abundance of foreigners. During these last few years in my computer major classes, I have seen none in my class. I am the only guided (misguided) guy to have the courage to chose this major. Everyone else was Malay. All assignments with them, all presentation, all group projects with them. I had learnt to appreciate their uniqueness (Unlike other foreigners here who find them weird). Now they are all non-Malaysians. I feel alone.


I was the only one wearing blue jeans.



comments

Issue of shrines from logic perspective.

Issue of shrines from logic perspective. (My status on facebook today)
 
Let A= People who support worshipping shrines, 
B= People who oppose shrines 
C=People who go to shrines just to read Quran, and dont bow/worship..


Situation A: Shrines are places of salvation, Group A is right Group B is wrong:


In this case, the group A are clearly the winners. All the effort they put in Urs and Dargahs has paid off.. The saints have helped them achieve salvation.. All groups A, B and C go to heaven, with group A having more Thwaaab..

Situation B: Shrines are places of kufr, Group B is right Group A is wrong:


Group B and Group C go to heaven anyway.. Group A goes to Hell for shirk..

Are we prepared to take that risk? 
 
 
(QM,2013)
comments