Tuesday, December 23, 2008
Monday, December 22, 2008
..*~'"*..*"`'*..."~`*..Merry Christmas..*~'"*..*"`'*..."~`*..
- A Chirstmas video from BBC breathing places, "Do One Thing" is to encourage us to do some things for nature . It is adapted from "Stop the calvery", a superb song sung by Jona Lewie.
- ----
- Do they know it's christmas, Band Aid.
- What is Christmas about? The explanation from Linus from "The Peanuts".
Thursday, December 18, 2008
Automate graph drawing with Grapviz
The picture shows an example of using Graphviz to draw a graph for Traffic Information module. The arrows depict the objects's communication using Observer Pattern.
digraph TIComponent {
graph [ label = "\nTraffic Infomation's communication",
size = "11",
fontsize = 20,
fontcolor=blue4];
node [ //shape = box,
color = darkslateblue,
style = filled,
fillcolor = deepskyblue1];
edge [ decorate = false ]
rankdir=TB
subgraph cluster_TI {
style=filled;
color=lightblue1; l
abel="TI Kernel";
ranke=source
Tuner;
Receiver;
Cache;
Database; }
subgraph cluster_Device {
//node [shape = box]
style=filled;
color=khaki;
label="HAL";
Device; }
subgraph cluster_App {
style=filled;
color=plum1;
label="Application";
"Client 1";
"Client 2"; }
Tuner->"Client 1" [label="new station", labelfloat=false, color=darkgreen, fontcolor=darkgreen];
Tuner->Receiver [label="status of band scan",color=magenta, fontcolor=magenta];
Receiver->Cache [label="TrafficData", color=firebrick3, fontcolor=firebrick3];
Receiver->Tuner [label="search next station", color=gold2, fontcolor=gold2];
Cache->"Client 2" [label="message update", color=violet, fontcolor=violet];
Cache->"Client 1" [label="message update", color=violet, fontcolor=violet];
Database->Cache [arrowhead="dot", minlen=2];
Device->Receiver [arrowhead="dot", minlen=0];
Device->Tuner [headlabel="new station", labelfloat=true, color=darkgreen, minlen=2, labeldistance=2, fontcolor=darkgreen];
Tuner->Device [label="search next station", labelfloat=true, color=gold2, minlen=1, fontcolor=gold2];
}
Wednesday, December 17, 2008
Must-read Python articles
Tutorials:
Handy & useful links :
- Python 2.5 Quick Reference (Richard Gruet's Python page)
- (the eff-bot guide to) The Standard Python Library to understand Python modules
Tuesday, December 16, 2008
File browser application for S60 developer: "Y Browser"
You can get it directly from Dr.Jukka's website: http://www.drjukka.com/YBrowser.html
Programming fiasco :: "static" initialization
Check out the following topics from C++ FAQ Lite:
- [10.12] What's the "static initialization order fiasco"?
- [10.13] How do I prevent the "static initialization order fiasco"?
- [10.15] How do I prevent the "static initialization order fiasco" for my static data members?
- [10.16] Do I need to worry about the "static initialization order fiasco" for variables of built-in/intrinsic types?
Friday, December 12, 2008
Automate self-extraction file using Rar (WinRar)
Script: To make the self extraction file for DVD installer using Rar.exe (console version of WinRar)
%dirZipNames is the hash which contains the list of input directories and output file names.
$rarPath is the executable "Rar.exe" and its path.
$inputDir is the directory which contains the input directories for packing.
--------------
## Start packing..
for $_ (keys %dirZipNames) {
my $dir = $inputDir . "\\" . $_;
my $zipExe = $inputDir . "\\" . $dirZipNames{$_} . ".exe";
if ( -d $dir && ! -e $zipExe) {
my $dirAll = $dir . "\\*.*";
print "Start packing $dirAll ...proceeding...\n";
print "Or check the progress in make_exe.log...";
system (qq{"$rarPath" a -r -m5 -sfx "$zipExe" "$dirAll" >> "$inputDir\\make_exe.log"});
print "\nOK: $zipExe is done!\n";
}
else {
print "\nError: Directory $dir does not exist \n\tor the $zipExe is already created!\n";
}
}
A sample to employ "epocrc" for automatic resource file creation
> epocrc -I\symbian\epoc32\include\ -u ex.rss -oex.rsc -hex.rsg
What we want to do here is to generate any "oemid" any time when requested without recompiling the whole resources.
In the example, I have default setting of oemid 1000 and I will replace 1000 with any new id for the resource file which passed to the makeResource function, whereas the output has the same name appended with its new id.
sub makeResource {
my $baseRssFile = "oempid_0x2000AAAA";
chdir($rssPath);
my $pid = $_[0];
my $rssFile = $baseRssFile . ".rss";
my $newRssFile = $baseRssFile . "_" . $pid . ".rss";
open(RSSFILE, $rssFile) or die "Error: Cannot open $1 : $!\n";
my @file =
close(RSSFILE);
open(NEWRSSFILE, ">$newRssFile") or die "Error: Cannot open $1 : $!\n";
foreach $_ (@file) {
if ( $_ =~ m/1000/ && $_ =~ /buf/) {
$_ =~ s/1000/$pid/g;
print NEWRSSFILE $_;
}
close(NEWRSSFILE);
my $rscFile = $baseRssFile . "_" . $pid . ".rsc";
system("epocrc -I$symbPath -u $newRssFile -o$rscFile");
system("del $newRssFile");
print "$rscFile is done\n";
}
The following part is to read the arguments which may be passed as range of integer or non range integer seperated each entries by comma.
my @num = split(/,/, $args{i});
foreach $_ (@num) { // Input may look like 1,4,7-10,200
my $pid = "";
if ( $_ =~ /(.+)-(.+)/ ) { //search if the input is in range
foreach( $1 .. $2 ) {
&makeResource( $_ );
}
}
else { // non-range argument
&makeResource( $_ );
}
---------------------------
Thursday, December 11, 2008
Wrap around the text with double quote using sed
Tools: sed
Input: file exported from excel
Output: file with double quotes wraped around the 2nd column text
Format of the file exported from excel with 2 columns separated by tab may look like this:
....
///////////////////////////////////
//Description of this group xxxxxxxxxxxxx
///////////////////////////////////
// String : Message group
// Max length: 256
#define qtn_app_update_message \nUpdateMessage
#define qtn_app_cancel_message Cancel Message
////////////////
...
Here, I would like to wrap the 2nd column with double quote just for the texts which start with #define, but do not insert the quote otherwise.
$ sed -e '/^#/ s/\t/&"/g' -e '/^#/ s/$/"&/' input > output
We try with the combination of two substitions. The first is to insert the double quote after the tab found, the later is to insert
double quote before the line ending. Both substitions are executed only when the lines started with hash.
Obligatory Perforce commands
I found the following p4 commands are obligatory.
To view the current p4 setting, type:
>p4 info
To view it from windows environment:
>set
You can see P4CLIENT and other P4's setting parameters.
To remove p4 client :
>p4 client -d client_name
Otherwise try to create a new one or edit the default one with :
>p4 client
it will give you a temp file to be edited. You can then change to any new client's names
which map to your mapping directories. We usually simply change the "client" and "view" entries where the client can be new name while views are your mappings.
(mind you, take care not to put the new line ending at the end of your views entries otherwise you will get the error message)
Or set it with:
>set P4CLIENT=new_client_name
Now, check if the P4CLIENT is set properly
>echo %P4CLIENT%
Normally, we just need the setting to P4USER (default is automatic set from windows's login account), P4EDITOR (default is notepad for Windows) and P4PORT (it must be manually set). However under Linux, we might need to explicitly export the P4USER in .bashrc if it is not set.
This is my case, I simply added the following lines in my .bashrc:
export P4USER=pattreeya
export P4EDITOR=vim
export P4PORT=scm-srv:1666
To list all p4 environment variables used by Perforce:
>p4 help environment
To diff the local files and the ones in depot, type:
>p4 diff -du20 > diff.txt
The option -du is the unified different and contain 20 lines prior each difference.
To diff between two branches, try:
>p4 diff2 -dub20 -u //work/dev_01/... //work/dev_02/... > diffs.txt
To list the current workspace owned by a user:
>p4 clients -u username
For more detail of p4 commands, type "p4" or "p4 help simple" or "p4 help commands".
Friday, November 28, 2008
Symbian application panic with ucmp 0
Of course, data stream is about data to/from disk. So, I removed the file which previously written to the disk and it solved the problem.
Friday, October 31, 2008
Symbian S60 emulator: ncnlist KERN-EXEC 3
Searched on Nokia forum and I finally got this :
http://wiki.forum.nokia.com/index.php/TSS000651_-_NCNList_KERN-EXEC_3_panic_when_starting_the_S60_3rd_Edition,_FP1_emulator
There is a link to get the patch file to fix this problem.
Yippie!
Thursday, October 30, 2008
Generating resource file for Symbian S60
How many of less-than-a-year Symbian developer really know about generating of resource file but the abld resource command ?
Yesteday evening I was asked to make a sample of 5 resource files for varies oem's id for 5 customers. That means I need to change the rss file by replacing the existing rss with new customer id, save it, then call the abld command, rename it and store it to its place. Afterward I must repeat the same procedures 5 times!! No, no, no. We planed to support 40 customers at the first release! So, I asked Stephane, my colleague who is symbian expert what tool behind the abld, he said rcomp but he never uses it directly.
So I checked the SDK, yeah, it seemed to be what I wanted. But what were the differences of baseinputfile and the sourcefile and what was RPP, how could we get that? Googled, googled, no answer!! There were few people asked for the rcomp but no answer. Ahhh.. not so many entries met my search string either "symbian rcomp" or "symbian rpp". Hmm...no answer also for rpp. Hence I read and read again every detail of rcomp and this rpp from SDK and experiment, experiment. What the rcomp gave back to me was "BANG!! RCOMP Crash!!", again and again and again. More than 1 hour passed, although I had really believed I understood every single parameters required from rcomp. Something came to my mind..or the rcomp was broken under my PC?? Well, if so, how the abld worked then? Hmm.. ok, let's check the perl package called by abld. Any news? ...Bad.....Sh_____! It still gave me with "BANG, Crash!!!",Crash, Crasssssh!!!
Hey, wait a second!! SDK mentioned another command for generating rsc resource file which again it was kind of wrapper of this rcomp! What was it called ? Right, "epocrc". Hey..there was an example at the end of the help, hmm....the sample looked quite simple, no suspicious parameters nor strange unknown params required Let 's give it a try!
anddddd...BINGO!!
The rest (of the story) is just a piece of cake, a simple perl to take any kind of id and replace it in new rss file and pass the file to "epocrc".