Thursday, May 23, 2013

Perl display time and date

To display time and date in perl use:

use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";

Note: you might need to install date time module.  sudo apt-get install libdatetime-perl 

Wednesday, May 22, 2013

Best way to debug in TinyOS

Today I realized one thing in TinyOS. The best way to debug something in TinyOS is "LEDS". I was trying to setPower() on transmitter and then tried to receive node's power using getPower() - it did not give me the same value. Instead it gave me "0". I banged my head for so much of time and later (still not 100% sure) realized that, CC2420Packet.getPower() does not return the same value as CC2420Packet.setPower().

Another problem I faced was with using "printf". I couldn't find much help on "printf". So, I finally gave up , started debugging my code by comparing value and if condition is true than blink LED else turn off LED.

So, my advice to all newbees would be to use "LEDS" to debug instead of depending on something else.