I’m a big fan of the fortune command in linux.I wanted to save these wisecracks on my mobile as an SMS so that i can forward them to friends …So here’s a quick how-to.I assume you already have the fortune cookies installed (in /usr/bin/fortune) and that your phone has bluetooth capabilities.

1.Install the gammu package from the sources or using your package manager.Gammu is a fantastic tool to communicate with your gsm phone/modem.

2.Pair your mobile phone with your computer via bluetooth (searching for the device, entering the  PIN number and all that stuff).

3.Note down your phone’s bluetooth device ID and name.You will need it in the next step.You can run the hcitool scan command to find the device ID/name.Don’t forget keep the bluetooth  of the computer/phone tunrned on!!

4.Now for the gammu commands to work , you need to create a .gammurc file in your home(~) directory. You can use the gammu-config command to do it,but it’s easier to create it using a text editor.The main parameters are the phone’s  id and name found in step 3.Here’s my .gammurc file created in /home/ravi. I paired a sony-erricson to my laptop.


[gammu]
 port=00:1B:59:1F:25:D6
 connection=blueat
 name=Sony Ericsson W700i/W700c
 model=

The device id and name are assigned to the ‘port’ and ‘name’ parameters respectively.The ‘connection’ is mostly blueat, except for some nokia phones where it is bluephonet.Leave the ‘model’ as such.

4.OK.Its time to have some fun!Run the following command to pipe the output of fortune to your mobile


fortune|gammu --saveSMS TEXT -folder 3 -unread -len 400

The command is self explanatory.The folder number (3=inbox) specifies where the sms gets stored, viz inbox ,drafts etc.To get the list of folders for your phone, run the gammu –getsmsfolders command

Put the command in a shell script and run it whenever you want :) You might not get an audible notification for the sms, but check your inbox anyway.

After some self-deliberation on whether is should write this or not, i finally decided that i am going to.WTH!,my blog is called entitled opinions.So whats the fuss all about,you ask.It’s the noise that comes out of mobile phone speakers.Most of the mid range phones that support music playback today have an inbuilt speaker.And the folks who own it seem to think that public broadcast is their birth right.They are everywhere- on the bus, in the road,in the hotel…They think that they are doing a favour by playing songs on their speaker. Little do they realize that others people actually give a damn.In fact the sound is so annoying that at any distance more than a foot away from the phone, all one hears is a cacophony of vessels clanging and glass breaking.For heaven’s sake,use the damn headphones, people.If you think that you are ‘cool’ blasting noise off your cheap phone, think again!If you are like me and come across one of these subnormally intelligent people,i strongly urge you to ask them to stop the inconvenience immediately.It might not work the first time, but i’m sure if they constantly hear the complaint, they might gradually stop it.

Do it folks!Tolerating nonsense is not a virtue.

Came across Jamie Matthews’ cool gmail notifier. Just the kind of thing i wanted to run on the ARM7 board that i’m trying out right now. Not much of a challenge for the ARM MCU’s processing power but it was fun making it work. I used the on-board seven-segment LED to display the mail count (it was a single display so the mail count is limited to 9).

gmailscreenshot

LPC 2129 Evaluation Board

LPC 2129 Evaluation Board

The python script was slightly modified:

1) In windows, just change the com port address to COMx where x is the port number as seen in the Device Manager

2)I sent the mail count (assumed to be less than 9) instead of the Y/N string.

To run the script periodically, i used  Andreas Baumann’s free Z-cron to schedule it once every five minutes. But the annoying thing was the command prompt that kept popping up when the script ran. I’m sure it could have been run as a windows service in the background but did not have the patience to look it up.

The setup

The python script:


import urllib2, re, serial, sys

 #Settings - Change these to match your account details
USERNAME="yourID@gmail.com"
PASSWORD="your password"

PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom"

SERIALPORT = "COM5" # Change this to your serial port!

# Set up serial port
try:
        ser = serial.Serial(SERIALPORT, 9600)
        #print ser.portstr #For Debug:Check if port name is correct !
except serial.SerialException:
        sys.exit()

# Get Gmail Atom feed
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, SERVER, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
page = urllib2.urlopen(PROTO + SERVER + PATH)

# Find the mail count line
for line in page:
        count = line.find("fullcount")
        if count > 0: break

# Extract the mail count as an integer
newmails = int(re.search('\d+', line).group())

# Output data to serial port
if newmails > 0:
                ser.write(str(newmails))
                #print "No.of mails=%d" %newmails
else: ser.write(str(0))

# Close serial port
ser.close()

The C program on the LPC 2129:


/*Tested on the ARM starter kit (http://www.emblitz.com/Embedded_ARM_Starter_kit.html)*/

 #include <LPC21xx.H>
 /*The 7 segment pattern for  digits 0 through 9*/
 const unsigned char bitMask8[] = {
   0x80,  // binary 10000000
   0x40,  // binary 01000000
   0x20,  // binary 00100000
   0x10,  // binary 00010000
   0x08,  // binary 00001000
   0x04,  // binary 00000100
   0x02,  // binary 00000010
   0x01   // binary 00000001
};

 void ser_init(void); //initialize serial port
 void send_8bit_serial_data(unsigned char); //display data on the 7 segment

 int main(void)
  {  char no_of_mails[10]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};
     char data;
      //mapping of pins to serial in parallel out shift register
		/*P1.16-->(~QH)--port dir= i/p
	              P1.17-->SRCLK--port dir= o/p
	              P1.18-->RCLK--port dir= o/p
	              P1.19-->SD1--port dir= o/p
	           */
     IODIR1=0x000E0000;//set port P1 direction to reflect the pin connections detailed above
     ser_init();
	 send_8bit_serial_data(~(no_of_mails[0])); //Reset LED
   	 while(1)
   		{   while(!(U1LSR & 0x01)); //wait till data arrives
	     	data=U1RBR-48; //convert ascii back to integer
			send_8bit_serial_data(~(no_of_mails[data]));
    	}	

      return 0;  //this is never reached
  }

void ser_init(void)
{
  PINSEL0 = 0x00050000;                  /* Enable RxD1 and TxD1              */
  U1LCR = 0x83;                          /* 8 bits, no Parity, 1 Stop bit     */
  U1DLL = 97;                            /* 9600 Baud Rate @ 15MHz VPB Clock  */
  U1LCR = 0x03;                          /* DLAB = 0                          */
}

void send_8bit_serial_data(unsigned char data)
{ /*The 7 segment is driven  bit-banging  style using  SN74HC595D, */
    int x;
 	IOCLR1=0xffffffff;
   // Loop through all the bits, 7...0
   for(x = 7; x >=0; x--)
   {
       if(data & bitMask8[x])
       {
           IOSET1=0x00080000;      // we have a bit, make P1.19 high
		   IOSET1=0x000a0000; 		//make p1.17=SRCLK aslo hign
		   IOCLR1=0x00020000;		//toggle back p1.17
       }
       else
       {
           IOCLR1=0x000F0000;        // no bit, make P1.19 low
		   IOSET1=0x00020000;
		   IOCLR1=0x00020000;
       }

   }

   IOCLR1=0x000F0000; //TOGGLE P1.18=RCLK
   IOSET1=0x00040000;
   IOCLR1=0x000F0000;
}

If you wanna take this further, check out this page for an  amazing  LCD based notifier.

Thanks to my friends, i came to know that the ‘possibly related blogs’ of my previous post linked to certain graphic/explicit blogs that had no possible relations to my write-up at all! A quick  search on how to remove the feature revealed this. But unfortunately i had a lot of difficulty in finding it because of the WordPress 2.7 upgrade which tucks it away deep inside.After 15 minutes of frustrated search, i finally figured it. So here it is for the benefit of other fellow WP bloggers:

1.Go to  ‘My Dashboard’

2.Click on the ‘change theme‘ button in the Right Now section :

untitled4

3.In  the Manage Themes screen that follows, click on Extras

untitled21

4. There you have it. Just check the relevant option in the screen that follows and click Update Extras

untitled31

5. Mission Accomplished ! Now start blogging peacefully.

Its been quite some time since my last blog.Not that I’ve been busy but I was kinda lazy to write.

Finally,another year of the Gregorian calendar comes to an end as i March [or is it January :-) ] into the future.2008 has been a mixed experience for me.Some musings:

1.An entire year of work (read ’studies’) without pay (boy, do i miss my salary).
2.Non stellar performance at subjects like DSP,DSD,OS (don’t bother finding if you don’t know what they stand for).
3.Commendable summer-sem performance in Marketing and Technical communication(No, i still don’t want to do an MBA).
4.Completed Prince of Persia-Sands of Time on my lappy(Ok,old game but hey, i finished the game without using a mouse!).
5.Was Tested On my English skills as a Foreign Language (7000 INR->108/120->zero calls.Now do the math).
6.Never watched TV (but compensated by on-demand Internet and downloads).
7.Got in touch with some of my good school friends after a LONG time (Social Networks do have advantages i guess).
8.Wrote two longest term papers of my life (At 3200+ words each,i will put ‘em here depending on my instructor’s feedback).
9.Discovered there exists a DJ Armin Van Burren (His techno is amazing.I personally feel his music is better than Paul Van Dyk).
10.Got an internship offer in the domain that i so longed to switch to(Determined to make the most of it).

Eager to find out what 2009 has in store for me…….

Wishing you all a great new year ahead. Rock on folks.

Do you want a job that’s stable, well paying, growth oriented ? Look no further…..

God's view of heaven

Air Tourism

Interested ? Leave your comments and email id. We wll get in touch with you…

I have a ThinkPad R60 which was given to all students  by the college.Though i knew that ThinkPads are known for their robustness, i hadn’t given much thought to it.That was until the fateful day of 8th September, when the laptop bag fell from my lap while i was travelling in a bus.It was a Volvo and i was sitting on the seat near the door.So thats about a meter and quarter high from the floor of the bus.The driver applied the brakes suddenly and wham ! My bag did a couple of rather gymnastic somersaults before landing on the floor.I was pretty sure that the bag’s contents would have depreciated in value to some peanuts’ worth of garage junk.I reached hostel and examined it. Okay, the LCD casing was split. All the display electronics was jutting out.I tried to fix the display as much as i can and pressed the power button.The thing booted immediately.The OS loaded, the keys were fine and the wi-fi (whose antenna is embedded on the LCD panel)  worked too.All was ok, phew.! But the lid was not closing properly as the interlocks were misaligned.Called up customer care and the guy came and fixed them too.(Thanks Ranjith !)

My lappy is now back to normal, except for a small hole in the corner of the LCD where the plastic had chipped off.This incident has really made me appreciate the robustness of a Thinkpad. I’m sure a Mac or a Viao or a Dell wouldn’t have survived the fall. Alteast the hard disk might have concked off if not the entire system.I am a ThinkPad fan for life now and have decided that my next upgrage is going to be a ThinkPad and a ThinkPad only.

Well, I downloaded Google Chrome today. I dare say even though i haven’t read the full Chrome story , i don’t really find it any better than Firefox, atleast from a user perspective.My take at some of the ‘features’ listed in the Chrome welcome page:

1)The ‘one box for evething’ :This works in Firefox as well.Infact the google search engine is used to display the search results if the keyword is not the url of an already visited page /stored in your bookmark.

2)New Tabe page: Duh !Tabbed browsing has been there since ages in Firefox.Moreover, Firefox is sensible enough to not add a ‘close’ button on the tab if there is only one tab.I was downloading something on Chrome and i closed all the tabs and you know what? All my downloads got cancelled ! In other words, the application terminates if you close all tabs.

Application shortcuts : These are just shortcuts,people ! Instead of cluttering your desktop/quick start with links, you might as well save them as bookmarks.You need to open the browser anyway to view the apps.Another Duh !

3)Dynamic tabs and Crash control: I must say these are really cool.I liked the flexibility provided by Chrome in tabs management.

4)Incognito: Again, there are plugins for firefox which provide similar functionality.

5)Safe browsing : Firefox has it too :

Security Certificate

Security Certificate

6)Instant bookmark:Ditto as above.

7)Simpler downloads: Well,like i said above, DO NOT close all your tabs when downloading something or risk losing it.This does not happen in Firefox, where the download window continues even if the brower is closed. (If you close that window too for the sake of Chrome like ‘unobtrusiveness’, then the download stops, but you can resume it later of the dowload url supports it.)

Performance:This might seem a naive approach, but i could not find any improvement when i looked at the  memory cosumed by Firefox and Chrome.Here’s the screenshot :

Firefox vs Chrome

Firefox vs Chrome:Firefox=29,232KB;Chrome=49,332KB

The bottom line: With all the extra addons and customizations possible, i think Firefox gets you a better deal.But Chrome is still in beta (That all google produts are beta-forever is another philosophy altogether) and one can only wait and watch what happens.

By the way,in case you want to save the Chrome installation executable for reinstalling or whatever, you can find it in the
C:\Documents and Settings\<YOUR_LOGIN_NAME>\Local Settings\Application Data\Google\Chrome\Application.2.149.27\Installer folder.