Monday, October 12, 2009

Some clarification

In this blog I share some knowledge on programming and electronic matter. It is just I love to share with others on my so limited knowledge. I am in no way an expert in what I'm sharing about.The knowledge which is shared in this blog can be beneficial for some people and can be "rubbish" for some other people.

I have received a a lot of questions in some post here. Some question can be very basic, some questions cannot be answered by me myself. Regardless of the questions level, I am in no way obligated to answer any of the questions.

The commenting system used here is for discussion purpose.

Thank You!

Friday, March 27, 2009

Building Data Structure : An experience

I'm not from IT/Computer Science background but from Electrical background,(to be precise Mechatronic) , my knowledge on high level programming language is not very strong. Especially on data structure.

Thursday, March 12, 2009

Converting algorithm into coding [Random Thought]

One of the challenge in programming, is to translate an algorithm into a coding. from my observation algorithm can be divided into three categories:

  1. Logical
  2. Mathematical
  3. Combination of mathematical and logical.

Wednesday, February 11, 2009

AWK Programming Language [revisit]

I'm now revisiting AWK language for trace file processing. Awk has been widely used for trace file processing, since (I believe) it is easy to do column filtering.

The column can be represented using $1 for column 1, $2 for column 2 etc.. , using other language like Tcl requires list manipulation which is not as straight as using AWK.

However, of course, the syntax of AWK is a little bit different than Tcl and C.

I will be "reusing" AWK to calculate throughput , loss , jitter etc. There are quite a few AWK codes available in the net for this purpose, however I want to make the code as flexible as possible and cater for our group needs.

First, I will be looking back at RFC's and papers on the network performance formula.Then, get available AWKs from the net (to enhance understanding) and modify the code to suit our need.

Our new research assistant maybe can help me working on this??

Performance of AWK?? Hrmm... anybody have experience using AWKs? How is the speed compared to C and Tcl (or MATLAB?)

I will not focus on performance for now , I believe it is acceptable, for now the main factor is whether it make my work easier or not.

"Live life in this modern world is complex enough! Programming Work Shouldn't Be "

Wednesday, February 4, 2009

Random Thought: Flow chart! Write it down!

I have been conducting microcontroller lab for a while as a lab instructor.
Microcontroller consists of both Hardware and Software. A microcontroller application need to read to read data from input , process it and make decision, then send data to the output based on the decision. Seems easy right? This is not what I want to write this time.

In a lab usually students are given a manual where in the manual the first part, the program is given and in the last part, student need to write their own program for certain application.

Believe it or not! Most of them "drawing flowchart in their mind" and getting confused of the program flow. Most of the time is wasted here, some takes about one hour for a program with simple if-else structure. Sometimes I wonder, Is it that hard to hold a pen and sketch it down? Or is it because they have full confidence of their capabilities. At the end what they do is asking the lab instructor to help trouble shooting the code! Some of them (not all - just a few) blaming the computers/compiler or even the microcontroller for not working.

I don't know about others, but me myself, without sketching and flowcharting, I will get lost in the flow, my minds keep being creative to do this and that, and its getting tired easily. I need a flowchart or diagram! if during that time I am tired of looking at the flowchart, I'll write the "story line", I dont want to get lost!

If the path is straight there is no need to go left or to go right, just go forward!

Enough for today, I want to start writing TCL program based on the diagram and result of discussion with taufiq last night.

Wish me luck and success!

Tuesday, February 3, 2009

Random Thought : Programming

Hey you!! do this and do that!

I don't know whether it is correct or not , I'm not a programming expert.

As far as I made to understand, doing programming is all about giving instruction to the target machine to do "this" and "that". The machine will always obey the instruction provided that the command can be understood by the machine?

Machine only understand binary !

The problem is how we are gonna give instruction, "binary" is not our language. Furthermore "Binary language" is differs depends on each machine architecture, the instruction for Motorola and the instruction for Intel , of course will be different.

Tadaaa... Programming Language is here!! Please, use it!! Instruct the machine. Fear not, your instruction will be converted to their "binary language". Just make sure that you know the language well - the format, the instruction and the "grammar".

Please choose a few type of language from lower level language to higher level language, once again worry not , there are assembler, compiler, and interpreter to convert the language into the "binary language".

Ok, there are programming language. The machine will always obeys ( if there are no errors in the language )

It is about the programmer!

The machine will always obey! If the application work, it is me who give instructions to the machine. If my application crash it is my fault and I'm responsible to rephrase it. Simple!

If I'm good the machine will show me the good result! If I'm not good enough, the result will not be good!

I should spent time programming (re-programming?) myself, I wish I can obey my command. 90% is more than enough! Shouldn't I?

Thursday, January 22, 2009

One problem Solved - Deleting item in a TCL list

Last night, I get the solution for deleting tcl list item. Actually this solution can be found in tcl manual. It is my mistake for take things easy and misunderstood the behaviour of lreplace command.

Deleting a list item in a tcl list is actually straight forward. But of course quite confusing.

Originally my procedure to delete list item is like this ( not the right one - of course):

proc ldelete { list item} {

# get the index,ix for item in tcl list
set ix [lsearch -exact $list $item]
#ix is greater then zero if the item is in the lsit
if {$ix>=0} {
# replace the item at index ix until index ix with nothing (aka - delete the item)
lreplace $list $ix $ix
else {
return $list


At around 11.00 pm last night i found out that the error is actually at the command:
"lreplace $list $ix $ix"
The command delete list item at index ix and returns the modified list but without updating it.

So the solution is simply like this.

set list [lreplace $list $ix $ix]

I'm very happy today! More programming !A lot to learn!

BTW, Thanks taufiq for helping me transferring the computers from IP-tech lab to WSN lab.

Wednesday, January 21, 2009

A slow restart

Starting yesterday I start doing serious programming again! But what a very slow restart. Most of my time was spent on looking at my previous coding. And trying to re-understand it!

Its have some bug which I'm trying to solving. Trouble-shooting works take a lot of time. I got a feeling that I can solve it. Let see In this 2, 3 days, can I do it or not!

If given a buggy program which one is your choice?
1. Trouble shoot the program.
2. Get brief idea of what the program intend to do, and write own program.

Make your choice and tell me why.

BTW, TQ sifu taufiq for helping me last night.

Tuesday, January 20, 2009

Start Programming Again!!

My busy schedule hindered me from serious coding for last three months! And now I'm pushing myself to sit in front of my HP Pavilion laptop.

I'm accompanied by:

1. A cup of coffee ( Thanks Abe Su for the 3 in 1 coffee)
2. TCL\TK books - Practical Programming in TCL\TK for my reference
3. Logbook - contains my thought and ideas
4. Used or "conteng-conteng" paper and a pen to layout my thought and ideas
5. My U-Mobile Broadband connection for internet connectivity

Keep looking forward!!