Thursday, May 19, 2005



"Maktub," the merchant said finally.

"What does that mean?"

"You would have to have been born an Arab to understand," he answered. "But, in your language it would be something like 'It is written…' "

-- The Alchemist, Paulo Coelho

I Never thought a delay of 2 days can twist someone's life...!!!! Maktub...

posted by Logu Krishnan : 6:22 AM

Wednesday, May 11, 2005

A Lexical Analyzer Generator – CsLex

Secondly, I decided to scrap my old GPS Parser and try some alternatives. Did a bit of research on the Lex & Yacc stuff, Lex helps write programs whose control flow is directed by instances of regular expressions in the input stream. It is well suited for editor-script type transformations and for segmenting input in preparation for a parsing routine. At the end of research I found this interesting Cs-Lex written by Brad Merrill of Microsoft @ http://www.cybercom.net/~zbrad/DotNet/Lex/Lex.htm which is a C# porting of JLex.
CsLex is Quite simple and clean than others (including antlr)

Generated a small simple test file and generated code for a simple input (to identify Commented lines in the text block)

/* comment1 */
/* This is a comment*/

and it parsed as follows

And here is some interesting LEX code generated

internal class Yylex
private const int YY_BUFFER_SIZE = 512;
private const int YY_F = -1;
private const int YY_NO_STATE = -1;
private const int YY_NOT_ACCEPT = 0;
private const int YY_START = 1;
private const int YY_END = 2;
private const int YY_NO_ANCHOR = 4;
delegate Yytoken AcceptMethod();
AcceptMethod[] accept_dispatch;
private const int YY_BOL = 128;
private const int YY_EOF = 129;
private System.IO.TextReader yy_reader;
private int yy_buffer_index;
private int yy_buffer_read;
private int yy_buffer_start;
private int yy_buffer_end;
private char[] yy_buffer;
private int yychar;
private int yyline;
private bool yy_at_bol;
private int yy_lexical_state;

internal Yylex(System.IO.TextReader reader) : this()
if (null == reader)
throw new System.ApplicationException("Error: Bad input stream initializer.");
yy_reader = reader;
private static int[] yy_cmap = new int[]
6, 6, 6, 6, 6, 6, 6, 6,
3, 3, 2, 6, 6, 1, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
3, 6, 6, 6, 7, 6, 6, 6,
6, 6, 4, 6, 6, 6, 6, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
0, 0
private static int[] yy_rmap = new int[]
0, 1, 2, 2, 1, 3, 1, 1,
4, 1, 1, 5, 1, 6, 7, 8,
9, 10, 11, 12
private static int[,] yy_nxt = new int[,]
{ 1, 11, 2, 3, 4, 5, 6, 6 },
{ -1, -1, -1, -1, -1, -1, -1, -1 },
{ -1, -1, 3, 3, -1, -1, -1, -1 },
{ -1, -1, -1, -1, 7, -1, -1, -1 },
{ 1, 13, 13, 13, 14, 16, 13, -1 },
{ -1, -1, 12, -1, -1, -1, -1, -1 },
{ -1, 13, 13, 13, 18, 19, 13, -1 },
{ -1, 13, 13, 13, 15, 9, 13, -1 },
{ -1, 13, 13, 13, 15, 19, 13, -1 },
{ -1, 13, 13, 13, 10, 17, 13, -1 },
{ -1, 13, 13, 13, 18, 17, 13, -1 },
{ -1, 13, 13, 13, 15, -1, 13, -1 },
{ -1, 13, 13, 13, -1, 17, 13, -1 }
public Yytoken yylex()
char yy_lookahead;
int yy_anchor = YY_NO_ANCHOR;
int yy_state = yy_state_dtrans[yy_lexical_state];
int yy_next_state = YY_NO_STATE;
int yy_last_accept_state = YY_NO_STATE;
bool yy_initial = true;
int yy_this_accept;

yy_this_accept = yy_acpt[yy_state];
if (YY_NOT_ACCEPT != yy_this_accept)
yy_last_accept_state = yy_state;

However, still evaluating alternatives for writing my parser… if you any ideas/suggestions do post here…

posted by Logu Krishnan : 10:25 PM

Serial.IO.Ports.SerialPort.WorksJustWow with my GPS Receiver

Recently I decided to dust[!] out my old GPSLibrary stuff, and give some new light to the lib. So I decided to scrap the current architecture and re-architect it with all the new modern frills available, so that it works for my smartphone as well.

First thing, I decided to scrap out was my own custom written Serial Port Wrapper, I had a tough time with those Virtual COM Ports. This time, I decided to use the Serial Port Class, which is newly added to the .NET 2.0 IO Libraries.

First skeptical issue was those Virtual COM Ports, but I was pleasantly delighted with this SerialPort class. This SerialPort class behaved and worked absolutely to my requirements without making fuss. And all I had written is a very few lines of code. In My previous COM + PInvoke a.k.a Interop wrapper thingy, I had to write loads of code for this, which is obviously un-optimized and had performance hits… Serial.IO.Ports is Just Wow.

Here are some snippets….

private void OpenPort()

Console.WriteLine("\nAvailable Ports : ");
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)

private SerialPort port = new SerialPort("COM6", 4800, Parity.None, 8,StopBits.One);

Console.Write("\nConnected to - " + port.PortName);
Console.Write(" @ BaudRate " + port.BaudRate.ToString());
Console.WriteLine(" communincating with " + port.DataBits.ToString() + " Databits \n\n");
Console.WriteLine("Buffer Size : " + port.WriteBufferSize.ToString());
Console.WriteLine(">> Data from GPS Receiver : \n");

port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);



void port_DataReceived(object sender, SerialDataReceivedEventArgs e)

And here is the output from my GPS Receiver (Pharos – GPS 360)

What you see in the picture is the list of available ports in my machine, My GPS Receiver is connected to COM 6, and the Data from GPS Receiver is in NMEA Protocol Format. To Know more about NMEA Protocol read my previous blog here @ http://loguk.blogspot.com/2004/11/more-on-nmea-0183-nmea-0183-is-ascii.html and to know more about GPS Read my previous blog here @ http://loguk.blogspot.com/2004/10/question-on-gps-recently-there-was.html

Also Writing data to a COM port is made a lot more easy… here is a simple snippet to write data to a COM Port

private void WriteData()
port.Write("Ah! GPS… Hack It…dude");
port.Write(new byte[] { 0x0A, 0x0B, 0x0C }, 0, 3);

Okay, you cannot use these code straight to the production code… I need to do Rico Mariani thingy’s :) and take care of thread safety et al… whatever… This Serialport Class is just WOW.

posted by Logu Krishnan : 10:12 PM

Monday, May 09, 2005

Model-View-Presenter [MVP] Pattern

Ever worried about what UI Pattern should you consider for your application?
Ever worried what pattern should be used to support alternate views?
Ever worried how to do UI Testing?
Ever worried about UI Class becoming more complex, as project grows ?
Ever worried about complex UI Screens with multiple nesting levels and interdependencies?
Here is a pattern for you.

Patterns are impressive, a Simple twist in pattern, gives amazing capabilities. Twist MVC Pattern a bit, you’ll get MVP Pattern, along with an array of flexibility. So, What’s MVP Pattern ? MVP is an acronym for Model-View-Presenter. In simple words, MVP Pattern separates the presentation functionality from the view while allowing the view to receive the user events.

Fine, but isn’t MVC already doing these? The answer is that MVC is bit old fashioned and the view handles all the user events. But in MVP, view still handles the user events, but instantly delegates the job to the presenter, and presenter does the real job of deciding what to do with the user events after due consideration of the Model.

So What are the Advantages?
-> Firstly, it helps to abstract the Rich, Fat and Thin clients
-> You can use Multiple Views with Different UI Controls on any of the above client forms, but a consistent behavior can be implemented.
-> Testing becomes breeze, as the functionality can be tested without the UI
-> You can create a Triads of MVP Horizontally a.k.a. hMVP, so that you can make complex UI Screens more manageable
-> Presenter becomes the true controller and more concentration is given to the behavior.

So How to implement a MVP Pattern, all you need to do is a simple change to the MVC Pattern.

1. Create a interface which is totally independent of the controls
2. Inherit the interface on view
3. Move all the behavioral code of view to a separate class called presenter
4. The interface, has now broken the dependency between view and presenter
(Hint: some of you might have done this in your existing applications already, but without understanding the full advantages of this pattern)

Here is a simple diagram to depict MVP Pattern

posted by Logu Krishnan : 7:36 AM

Wednesday, May 04, 2005

I'm Back ‘La… from Singapore‘La

[The Time is around 2 AM – It’s Sunday morning now, and I’m doing Baby-sitting @ coimbatore for my sister’s new born baby,he is now sleeping @ the incubator, he requires 24/7 support of a doctor and a person for emergency help. Now, I need to be awake for next 4 hours, So I thought I shall write a long blog on everything that i remember in my recent trip to Singapore.I know its bit long, so I’ve splitted with sub-headers for your reading pleasure :)]

I was at Singapore last week for Microsoft’s Asia MVP Summit 2005. Singapore... the abode of the fairies, a locus of strong and impressive business powers, and an uncomplicated, child-like world.



The summit was Fantastic and had a right proportion of Technology + Fun, got some chances to peek into the early preview on stuff like SQL Integration Services, Speech Recognition @ Longhorn et al

Day 1, was filled with Executive Talks, Shu-Fen Cally Ko, Regional Director of Technical Community Activities @ MSFT gave an enthusiastic welcome speech, followed by Sean O’Driscoll, Sr.Global Director for Technical Community, he was hyper active on the stage and made his session very interesting, followed by other executive speeches. Day 2 & 3 was filled with Technical sessions on various tracks.

With Cally Ko

People @ Summit

The summit gave real good opportunities to interact with interesting and intelligent minds across the Asia pacific regions. MVP’s from India, Australia, Malaysia, China, Vietnam, Korea, Taiwan, Singapore participated in the summit. My objective for the summit was to interact with other Asian MVP’s, and it started right when I entered airport, I met Hyderabad MVP’s Arun and Raghu Boddhu, later joined by Geetesh Bajaj @ chennai and Sudhakar Sadasivuni @ Singapore. Also, when I landed @ the Singapore Airport. Met with John-McKay, MS Office MVP from 1992 [I was in my high-school that year :-) ] and Pierre Connan, Security specialist from MSFT, AU. At the day 0 “Get Connected” Party, Pierre shared some insights and security initiatives at MSFT.

Same day night, we popped up to Orchard Road, and entered the Borders Book Store, as Geetesh wanted to buy some books. Arun, was looking for technology books, and found his own book on the rack, and asked the salesman near by all the statistical questions about the book, and frequency of sale of the book et al, the salesman got bit irritated by his question and asked who are you, arun replied, I’m the author of this book. All of the sudden the scene changed and arun was given a royal respect, and finally he autographed a book, which was framed and kept in the front display with the title, “autographed copy” :) He did a promotion for his book.

On Day 1 I met with the new Indian MVP’s[we have more than 40 Indian MVP’s now, you can find the list of Indian MVP’s here]. One notable new MVP is Yashwant Kanetkar[Yeah, u read it right, the same author of those legendary c/c++ books. I’ve read most of his books, and his books were hot cakes @ libraries and book stores in the mid 90’s. Anybody who have learnt C in those days, would have definitely read his books, I’m sure still they do] He was quite an impressive personality. Had a good relaxing lunch and chat with him. These days he is running his own business DCube Technologies @ Nagpur. But, I was surprised to see his modesty. Looking at fellas who make lousy noises after learning the simple cripple wares of technology, this man was quite content and amazingly modest for the knowledge he posses. A True Professional.With Kanetkar
Also met Sanjay Vyas the same day. It was good to see people faces whom I know only thro’ mails and photos.

Also, During the 1st day Lunch I met up with “Julian Ray”, Microsoft’s Community Manager for EMEA at Paris. She was an impressive lady and was capable to discuss about everything, right from technology to life :) we debated over Microsoft, Technology, India, France, US, Politics, Kerala, Pelicans, Shrimps, Life et al.

With Julian

We were joined by “Lori Brownell”, Microsoft General Manager for Windows Platform – Longhorn, and other MVP’s from Singapore and Taiwan. Singapore MVP’s has an awe on Indian technology companies.

My 2nd day lunch partner was again “Julian Ray”, this time we catched some Vietnam MVP’s.
Vietnam had only 4 MVP’s, but all 4 were working on wonderful technologies like NLP’s, Lisp and were building stuff for robotics and aeronautics. And these guys loved their country a lot :) [and complained about china a bit, much like indian’s complaining about Pakistanis :)] Some names, worth mentioning are “Ha Than” CEO of LAC VIET computing Corp [frankly, it was difficult to read his business card, it was a cryptic English] and “Do Huy Hoang” PSS Manager of Microsoft.

3rd day was bit cool, the MVP’s were grouped based on their specialization. So Myself, yashwant kanetkar, sanjay vyas, Saurabh Nandhu & Kashi met up at the C# Table, soon joined by Malaysian and china C# MVP’s. Met a intelligent girl named “Serena Yeoh”, she was full of confidence in her voice. And discussion turned to the Object Persistance Framework she is developing.

And Saurabh shared his interesting learnings. And the topic switched to C# vs. C++, Serena questioned me how do you tackle these fights. According to me, all these languages are just evolutionary in nature, and none of them are revolutionary. It will evolve till the world exists. Every language has their own reason, C# is a wonderful language for enterprise development where C++ is the king of system app development. Personally I feel, it’s usually amateurs/students/kiddoos fight on these issues. In the real world, it’s the business scenario that matters, the objective of a software developer should be to build a good software that suites the requirements with the best of the available technology. If a developer is biased on technology his solution will also be biased. Frankly, in my previous experience I’ve adviced certain projects to be developed using Java or C++, as they are the best languages to build those systems. Though she agreed with this, she said she always hates when VC++ Guys say,


:-) interesting observation, and it’s quite obvious fact :-D finally Anand M, joined and ignited the discussion on VB.NET vs C#.

Later, the same day I met Kamal Hathi – MS SQL Server – Program Manager, and caught Glen Millar, Powerpoint MVP from Australia @ Starbucks Coffee. I was highly surprised when Glen stated “Singapore is very clean than AU – Singapore is beautiful than AU - People are polite – Singapore had good transportation mechanisms…. Et al”… Huh… I Just want to pop up and say… “Hey, I should crib about these comparing with India, and not a guy from Australia” :-)

Also, had brief chat with Sean ‘O Driscoll, Ben Stiller, Manish Sinha, Kunal Sikka and other Chinese MVP’s

Till the end I had a question, for which I really did not get a satisfied answer “How do we identify Asian Faces i.e. how do you identify between a Chinese, Korean, Japanese, Vietnamese, Malaysian… et al” :-D last time, when Cally Ko, was at Chennai she gave me a hint that you can identify them with their hair style… but that does not seem to work  anybody who has a answer do post a comment here :)

Technology @ Summit

Most of the sessions discussed pre-release NDA Information, so I cannot share many of them. But I can write a bit about SQL Integration services [got a verbal permission from Kamal Hathi :)]

Session: MS SQL Integration Services
I was eagerly awaiting for this session by Kamal Hathi, as I’m now associated with the team that’s building IBM Websphere Data Integration Suite, Which is a competitor product for MS SQL Server’s Integration Services :) Surprisingly, Data Integration is one of the Multi-million dollar Market segment, which Microsoft has not concentrated till date, and this market segment is ruled by handful vendors who mint in money. And here… MSFT makes a daring entry with their new interesting breakthrough architecture, which is almost totally different from the existing vendor’s architecture.
Integration Services has an Intelligent & a Adaptive GUI (MSFT Always scores at this), Various Data Adapters, Data Lookup’s which includes a intelligent Fuzzy lookup & Data-DeDuplication Lookup and Data Mining features. Also, IS has one pipeline for Text Mining, Custom Src, Data Mining, Data Cleansing or any standard source. And they are immedietly available for clients like Analysis Services or Mobile World or Corporate Reports World.

Integration Services does not do any staging, but works on workflow and pipeline concepts (most of the major vendors in the market has the staging as their centerpiece of their product). Microsoft instead defines Data Extentions, and intelligently leverages Analysis Services and Reporting Services. i.e. Integration Service becomes datasource for Reporting Services, and IS feeds data to the Analysis services. All in all AS + IS + RS combined with the .NET Framework makes a very powerful combination.

Data Visualization concept really enthralled me. A Good Value addition to the Integration Services. Also, IS brings all the goodness of .net framework and C# language.

IS is 64 bit enabled, and hosts Hi-Performance components which leads to NEW High performance Data warehouse Architectures

Kamal Hathi, also said they are working aggressively on the profiling portions of the integration services as well… Some comments on Kamal Hathi by AU MVP’s was… “What a Guy…” :-) Truly he was way too cool in handling the session and answering the queries.

Yes, there are question like How stable this is when compared to the industry leaders who are in the market for nearly 10 Years.

What does this mean to the world,
-> All the small vendors/companies involved in building BI softwares [including my previous company :)], should realign and rethink their architecture to take advantages of IS. It’s definitely a boon to these vendors.
-> IBM, Hyperion, Cognos now have 1 more competitor…. Okay… a giant competitor :-) Should be a very interesting competition, in the end it all ends in the goodness for the world :)

What does it mean to me
-> Clearly thrilled to learn how 2 big giants architect and build same software. both has a totally different architecture… I cannot write more on these as I’m governed by NDA’s on both ends  so let me stop this here….

Session: WMI
Still I have the same ole’ questions, which nobody answers me :)
1. When will SCSI Devices would be supported
2. Performance Implications, I always turn to Win32 whenever I have this issue
3. Is there a possibility for WMI for CF?
If Anybody has any clues do post it here… I would love to hear…

Other sessions, strictly on NDA so cannot write anything on them. But all I can say is next 2 years has lot’s of excitement with various releases from Microsoft for both Developer and IT Professional world.

Gear Up Guys :-)

Finally, I got my xphone repaired @ Singapore, none of the O2 authorized xphone repair center’s in India were able to repair the phone, I got a standard reply – they don’t have technology experts capable to repair xphones [beware, if you are buying xphone in India] , but it was different story in Singapore… initially the lady @ service center said it would take 2 weeks, after a bit of charming and negotiation she agreed to give it back in a weeks time, I got it back fully repaired and a free software upgrade.

Fun @ Summit

Had a blast @ summit with Singapore Traditional Dances, Belly Dances, Fire Dances, Fairy Dances et al :)

Singapore – The Place

I Should say Singapore has a civilization that is highly cultured and a good standard of living. Also, I think they have planned every single square feet of Singapore, and also a very safe place to live. You can fully trust the taxi drivers and they are very friendly, all you have to do is initiate the talk, they would feed you with all the informations around the city.

Me, Sudhakar and Geetesh went for a relaxing stroll @ 2 AM from our hotel to the beach, no glitches at all. And we could see women doing shopping at those wee hours. It was absolutely safe.
Most of the places I visited, I was speaking Tamil. Tamil being the official language there, it was predominant right from airport to malls to local markets :) BTW If you are unaware, Singapore’s current president is from Tamil Origin i.e. South Indian… Interesting Huh!

Also, I did not see even a single cop till the last date of my stay at the Singapore, yet the law & order and traffic was smooth.

There are lot’s of attractions, some not-to-be-missed items are Night Safari @ Singapore Zoo, Jurong Bird’s Park, Sentosa Island – Underworld Aquarium, Musical Fountain (I loved this) et al. I missed the reverse Bungee jump @ Clarke Quay, did not find time, but would have been very adventurous.

The Last day, we had a party @ the Riverside Point, a place which was supposedly to be a romantic place, was turned into big time party spot that night, filled with full of fun and colorful dancers.

If you are planning to shop for computer accessories, and if you are from Chennai, better check the rates @ Ritchie Street. I felt rates are less @ Ritchie street :)

End Credits

In the End, it was a fantastic and fulfilling trip. Thanks to Cally Ko - I can realize your efforts on this events and I would call it a grand success. Also thanks to Abhishek and Subhashini for making this happen by arranging on all the logistics issues and everything else.
The event was Just awesome, and you had made me to have new friends across the continents.
Thanks Microsoft :)

If you are intrigued with that ‘La suffix at the title, its “Sing-lish” i.e. a unique language spoken by the locals of Singapore (I picked up this from the taxi drivers) combining their local language with English, Singpore+English = Singlish. They add ‘la at the end of each sentence. (For More info on singlish, contact Geetesh Bajaj, he bought a small reference book for singlish :) )

Leave your comments & queries below…

posted by Logu Krishnan : 12:23 AM

This page is powered by Blogger. Isn't yours?