Thursday, November 12, 2009

HookLogger - Symbian debugger tool

Do you have memory leak or leave problem? Let's try this tool, HookLogger!

References:
http://developer.symbian.com/main/tools_and_sdks/developer_tools/supported/hook_logger/index.jsp

Wednesday, November 4, 2009

Setup Symbian environment

Symbian C++
1. Perl (e.g.ActiveState Perl 5.x)
2. Symbian SDK (S60 3rd Edition, S60 5th Edition)
3. OpenC/C++ plugin (for S60)
4. Carbide (Carbide.c++ v2.02) IDE for Symbian platform development.

Note
- The SDK and your source files must be located at the same drive
PyS60
References
http://wiki.opensource.nokia.com/projects/Installing_PyS60
http://developer.symbian.org/wiki/index.php/Python_Technical_Overview#Table1

Thursday, October 8, 2009

Gps Tracking on Google Maps/Goole Earth from Navigon


Navigon is probably the best navigation brand on-date. Several new products launched since 2008 are most known for several outstanding features such as Reality View, Terrain View, 3D City View, pedestrian navigation and multiple alternative routes. Recently, it was also added a new GPS Tracking features which allows the user to view the route on Google Earth and Google Maps using kml format. A feature which I would like my navigation to have which was known to be suported by Garmin navigation.
Open GpsTracking using Goolge Earth, simply click "File -> Open" on Google Earth to import the kml file. To use it on Google Map, you need to upload the file to internet, and copy the URL to the Search Box.

Friday, October 2, 2009

Variadic Macros

I ran into a problem of variadic macro __VA_ARGS__, the code porting from Windows when compling in Symbian. It issued the error "badly punctuated parameter list in `#define'" and caused "cpp.EXE" to stop with failure.

Google a bit and the solution was found under NewLC:
http://www.newlc.com/forum/variadic-macro-problem

An information about variadic macro for GCC was to be found here:
http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

Friday, September 18, 2009

Problem in compliation on GCCE & CW

I encountered a compilation problem when trying to build a huge library which require many other APIs. It happened on both CodeWarrior and GCCE! What could it be?
Carbide.C++ for CW seemed to compile all cpp files but could not complete the complilation at the end then hang over. (No compilation error had been reported) Whereas GCCE was even worse,
Internal compiler error in dwarf2out_finish dwarf2out.c 13110!!

was yield after several cpp files built. Although commenting out these reported error file, the error was still moved to the other files! It should not be the error from source code anyway.

Solution:
Adding OPTION CW -w off in your mmp file sounded to solve the problem on CW! (At least in my case, there were too much warning that's why the compiler couldn't end the compilation beautifully!)
And now what about GCCE ? I did the same with OPTION GCCE -w to suppress the default "-Wall -Wno-ctor-dtor-privacy -Wno-unknown-pragmas" in GCCE.mk.
Checking the GCC document, I then decided to change the debug option from "dwarf" to "stabs" but this did not help either. (-gdwarf-2 and g3 are the default GCC setting, so I override this setting in the project file, my mmp.)
Hmm...let's try other setting. This time with with OPTION GCCE -g -g1 -ggdb ...and it worked!! Done!

Monday, August 17, 2009

Simple Symbian Makefile

Symbian requires makefile for gcce build.
Here is the sample of my makefile, let's call it myproject.mk


# myproject.mk
#
TARGETDIR=.
CERTDIR=../../../../Certificates
TARGETSISFILE=$(TARGETDIR)/myproject.sis
TARGETSISXFILE=$(TARGETDIR)/myprojects.sisx
TARGETPKGFILE=$(TARGETDIR)/myprojects.target.pkg
SOURCEPKGFILE=$(TARGETDIR)/myprojects.pkg

SOURCECERFILE=$(CERTDIR)/dev.cer
SOURCEKEYFILE=$(CERTDIR)/dev.key
PASSWORD=mypassword

BLD : do_nothing

CLEAN : do_nothing

LIB : do_nothing

ifeq (GCCE,$(findstring GCCE, $(PLATFORM)))
FINAL :

$(SOURCECERFILE)
@echo EPOCROOT=$(EPOCROOT)
@echo $(PLATFORM)
#Delete existing sis file
@echo del $(TARGETSISFILE)
@echo del $(TARGETSISXFILE)
# we use command here, please note that we need the double quotes here
del "$(TARGETSISFILE)"
del "$(TARGETSISXFILE)"

#Pass the PKG through the CPP precompiler
# @echo cpp -P $(SOURCEPKGFILE) $(TARGETPKGFILE)
# cpp -P $(SOURCEPKGFILE) $(TARGETPKGFILE)
@echo perl -e "print `makesis -d%EPOCROOT% $(SOURCEPKGFILE) $(TARGETSISFILE)`"
# we can execute this with perl as well
perl -e "print `makesis -d%EPOCROOT% $(SOURCEPKGFILE) $(TARGETSISFILE)`"
#Sign the SIS file
@echo signsis -v -s $(TARGETSISFILE) $(TARGETSISXFILE) $(SOURCECERFILE) $(SOURCEKEYFILE) $(PASSWORD)
signsis -v -s $(TARGETSISFILE) $(TARGETSISXFILE) $(SOURCECERFILE) $(SOURCEKEYFILE) $(PASSWORD)
else
FINAL : do_nothing
endif


Now, if we want to execute the makefile without calling "abld" command, you need firstly set $PLATFORM=GCCE at your shell. Next we can call the make from here:

c:\...sis\>make -f myproject.mk


If anything goes wrong, you can try with "make -d" to debug.

Some pitfalls from make:

- *** missing separator *** => You use the "space" instead of "tab"
- Invalid switch when trying to execute the command from (dos) shell => you missing double quote around the argument passing to the command.

Friday, July 24, 2009

Create Symbian Installation File


1. Edit pkg file in your sis directory. Carbide.C++ will generate default pkg file when you comply the source code with it. The format of pkg file can be found : http://mobile.actionscript.it/Lib/Doc/44/how%20to%20create%20a%20sis%20file.pdf
2. Create sis file and sign file
Either using Carbide.C++ or calling the makesis and signsis from command prompt.

2.1 Using Carbide.C++. Go to "Project"->"Properties"->"Carbide.C++"->"Build Configuration". Select the "Configuration" you want, in "SIS Builder" click "add".
SIS Properties will pop-up. Now, what we need here is only "PKG File", Using "Self sign sis file" would be enough if you don't use any capability. Then when you build the GCCE configuration, the sisx file will be automatic generated.

2.2 Calling makesis and signsis from the command prompt:

c:\sis>makesis myproject.pkg
c:\sis>signsis -?
c:\sis>signsis myproject.sis myproject.sisx ..\cer\mysymbian.cer ..\cer\mysymbian.key myphasepass


3. If you get any error when trying to install your sis file on the device, check out the error from "Interpreting Platform Security Error Messages in S60 3rd Edition" or Forum Nokia.com's "S60 SW Installer Troubleshooting" or from Symbian Foundation's Troubleshooting Installation Errors.

Thursday, July 9, 2009

Rename a bunch of files with a finger tip!

Some cameras have functions to set the name of photos taken, some don't. Some softwares, e.g.Digikam, offer the function to rename the files during import images from camera to a PC.
What about if your camera does not have the function to set the name of the photos or you, for whatever reason, want to rename your collection of files later?

Let's write a simple Bash script to do this job!

First, let us check if the parameters required are less than 3. I always add the usage and help here because this becomes handy whenever you want to know the script syntax.

$# is the argument count.
${0##*/} is the base name of $0 which is the script name to make the output short.
$1,$2 are the first and second arguments.

Next, let us make this change directly inside the directory.

for f in *.[jJ][pP][gG] means for each file matches .jpg or .JPG or .jPg or similar.
old_name=${f##*/} is to get the basename of the file.
new_name=${old_name//$old_string/$new_string} is to replace old string or search string with new string where the old string found in old_name or original file name, then give back the result to the new name.

That's it! A piece of cake, isn't it?





#!/bin/bash

if [[ $# -ne 3 ]]; then
echo "To rename jpg files in directory"
echo "usage: ${0##*/} new_string old_string directory"
echo "example: ${0##*/} Graz _MG ~/Pictures/Graz/web"
exit 1
fi

old_string=$2
new_string=$1

cd $3

for f in *.[jJ][pP][gG]
do
old_name=${f##*/} #base filename
new_name=${old_name//$old_string/$new_string} #replace string
if [ ! -w $f ]; then
echo "warning ...$f is not writable "
else
mv $f $new_name
echo "renaming ... $old_name -> $new_name"
fi
done
################END OF FILE##################

Thursday, June 18, 2009

Known issues Qt for S60 4.5 (Garden)

Quite disappointed with Qt 4.5 for S60 am I.
Here are the known issues and it seems I need to wait for another while until most important issues fixed.

http://labs.trolltech.com/page/QtforS60KnownIssues

Most annoying things for me are the GCCE and memory leak issue. This memory leak issue happens to all QtDemo & QtExample apps.

---------------
"Testers exists only if bug exists, bug exists only if developers exists. Don’t worry ‘Testers’ we are always ready to help you." Post by Hari in "101 More Great Computer Quotes"

Wednesday, April 29, 2009

VC debugger with better data display

As a programmer, I have come across several compilers and although I am not a MS's fan but perhaps VC is the best compiler I ever used.

Now, let us customize autoexp.dat to make a better data display. The file can be found under VS's debugger, eg.:

C:\Programme\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat

The tutorials can be found here:

- Customize autoexp.dat with own types in VS2005
- Writing custom visualizers for Visual Studio 2005, the best reference about customizing autoexp.dat I found so far.
- Visual C++ 2005 IDE Enhancements Part 5: Variable Display

---------------
"premature optimization is the root of all evil." Donald Knuth

Friday, April 17, 2009

Template Specialization and GCCE compiler

An interesting point about template specialization on Symbian.
GCCE does not follow §13.5.1 rule of C++ standard, the order of specializations.

Look at the follow code:

template< class T > class MyComplex { T i, j; };

template< class T > T MySqrt( T );
template< class T > MyComplex< T > MySqrt( MyComplex< T > );
double MySqrt( double );

template< class T > void MySimpleFoo ( T& );
template< class T > void MySimpleFoo ( const T& );

template< class T1, class T > void MyFoo2 ( T1 t1, T& );
template< class T1, class T > void MyFoo2 ( T1 t1, const T& );

// The problem is lying at the following 2 templates
template< class T1, class T > T1 MyFoo ( T& );
template< class T1, class T > T1 MyFoo ( const T& );

void f ( MyComplex< double > z )
{

int i = 0;
const int ci = 3;

MySqrt( 2 );
MySqrt( 2.0 );
MySqrt( z );

MySimpleFoo( 2 );
MySimpleFoo( i );
MySimpleFoo( ci );

char ch;

MyFoo2( ch, 2 );
MyFoo2( ch, i );
MyFoo2( ch, ci );

MyFoo2< char >( ch, 2 );
MyFoo2< char >( ch, i );
MyFoo2< char >( ch, ci ); // MyFoo2(..) does not alert the compiler
// for ambiguious. Now look at MyFoo(..)

MyFoo< char >( 2 );
MyFoo< char >( i );
MyFoo< char,int >( ci ); // This is ok.
// But the call below will not work

// MyFoo< char >( ci ); // doesn't work with Symbian GCCE
// the compiler will complain that the functions ambiguious,
// it cannot decide whether it should take MyFoo ( T& ) or
// MyFoo ( const T& )
}


---------------
"Trying to outsmart a compiler defeats much of the purpose of using one." Kernighan & Plauger, The Elements of Programming Style

Thursday, April 9, 2009

"We 're linux"

Genial & informative video clips organized by The Linux Foundation, get into the world of Linux developers around the glob.

http://video.linuxfoundation.org


---------------
"Be Linux"

Friday, April 3, 2009

Problem in wchar.h in Open C (Symbian)

The following errors encountered in OpenC:

/EPOC32/include/stdapis/wchar.h:92: error: `__mbstate_t' does not name a type
/EPOC32/include/stdapis/wchar.h:97: error: `__size_t' does not name a type
...


Googled and I found similar problem posted in forum.nokia.com (http://discussion.forum.nokia.com/forum/showthread.php?t=137500) but no relevant answer how to solve the problem. How I solved it is posted in comment#6.


---------------
"Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter" Eric Raymond

Wednesday, April 1, 2009

find & grep command to search string (Cygwin version)

There are few limitations with Windows search, e.g.
-You cannot preview the search results.
-The regular expression in Windows is not unified with other regular expression formats. The Windows search for phase or word do not recognize the syntax like

\(.*\)BEGIN_DECLS

Then, let's use grep to do the work. If you do not have cygwin, install it!
Now, I want to search for the places in .h files where it contains the text "typedef" at the start of the line and may follow with some other strings but must have "_mbstate_t".


$find ../ -iname \*.h -exec grep -B 3 -i "^typedef\(.*\)_mbstate_t" '{}' \; -print


Basically, find command needs the path and the file name you need to search.
Here, I tell the find to search the one directory upward for any files which have .h" or .H at the end of files. -iname option is for case-insensitive.
Remarkably, in Cygwin, you need to have the escape for * like \*.h but you don't need to do this on native *nix. The examples shown here are only tested under Cygwin.

Next, -exec option is to follow with a command where it takes the arguments from find and execute it. We want to grep any lines starting with "typedef" (^typedef) and follow with some string (.*) and _mbstate_t in any files which passed from find command.
"^typedef\(.*\)_mbstate_t" is normal regular expression for this job.
^typedef is to have typedef at the start of the line.
\(.*\)_mbstate_t is to match _mbstate_t which contains any strings or spaces before the search string. The backslash is the escape character to group (.*)
(For more information about regular expression, google regular expression)
-i is for case-insensitive.
-B 3 is to display 3 lines before the matching line.


If we want to search for both .cpp and .h files, we can group the search within (..) as well.

$find ../ \( -iname \*.h -o -iname \*.cpp \)

However, if you often need to repeat this search, you may put it into the shell script instead.



#!/bin/bash
#
# File: fcpp.sh - Simplify find & grep for source & header file
#
if [ $# -lt 2 ]
then
echo ""
echo "Usage: $0 [-i] search_path search_what"
echo "-i for non case-sensitive, default is case-sensitive"
exit 0
fi

case "$1" in
-i)
shift
find $1 \( -name \*.cpp -o -name \*.h \) -exec grep -i $2 "{}" \; -print
;;
*)
find $1 \( -name \*.cpp -o -name \*.h \) -exec grep $2 "{}" \; -print
;;
esac

exit 0


Beyond the example here, in my opinion find command is one of the most often used commands, therefore please don't forget to have a quick look at the find man page.

See also:
- http://content.hccfl.edu/pollock/Unix/FindCmd.htm

---------------
"The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." Donald E. Knuth

Tuesday, March 3, 2009

Nokia phone Tips & Tricks

- 5800
- N95
- Misc Nokia phone

---------------
"We have to stop optimizing for programmers and start optimizing for users" Jeff Atwood

Unexpected crash on target platform on S60 phone

Everything seemed to work fine under my emulator with new S60 FP1 SDK. But when I tried a build on release target platform, it worked until the application try to start another process, it stopped dead. Here, I use the gcce build target from the command line.
A solution is "comment out" REL_OPTIMISATION=-O2 -fno-unit-at-a-time in S60_3rd_FP1\Epoc32\tools\compilation_config\gcce.mk. This is a default setting from the SDK but it does not fit for my application.

---------------
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." Stephen Hawking

Tuesday, February 24, 2009

BASH 4.0 is out.

It has been announced on slashdot today. Visit:
- BASH main page
- What's new can be found here.

Other useful links for BASH user (from my bookmark):
- Advanced Bash-Scripting Guide from Mendel Cooper. The tutorial covers the detail from ground up. In the appendix, the author also introduced the "sed" and "awk" usages.
- BASH String Manipulations on Linuxgazette. It focuses on string handling with BASH.
- Bash Shell and Beyond (Stack and Queue, Array, Sort, XML parser expat).


---------------
"Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest." Isaac Asimov

Friday, February 13, 2009

Virus on Linux ?

This blog is hot! : )
- How to write a Linux virus in 5 easy steps

---------------
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." Edsger W. Dijkstra

Tuesday, January 27, 2009

Carbide.c++ 2.0 and P4 synchronization

Carbide.c++ 2.0 has been launched on NewLC for quite a while since around December and with new license. It is now available for free for OEM, Developer and Professional edition! Recently, I read stories about Nokia 5800 XpressMusic which based on S60 5th edition for Touch UI. (I think, touch screen becomes trendy since iPhone...everyone goes touch screen now. However, I personally enjoy using the softkey doing things. Perhaps, because my first experience with touch screen for mobile phone, Sony Ericsson P800 - based on UIQ, was not so good.) This new XpressMusic looks very promising, it is thiner than N95. (One thing I dislike about N95 8GB - the phone's thickness.) My idea is just try to build my S60 based on 3rd Edition application to 5th Edition in the future. Although I don't have any 5th Edition in hand...but make the application running with emulator is also fun.

Perhaps, this is a good time to prepare new development environment for our project.

1. Install Carbide.c++ 2.0.
Grasp Carbide.c++ 2.0 from here.

2. Install SCM Plugin for Carbide.
After finishing with Carbide installation, we need P4WSAD, the Perforce Plug-in for Eclipse.
- Go to Help -> Software Updates -> Find and Install
- Enter http://www.perforce.com/downloads/http/p4-wsad/install/ as a new site. Follow the instruction.
- After the installation ready, you can see 2 jar files: com.perforce.p4api_xxxx.jar and com.perforce.team.core_xxxx.jar in plugins directory under your carbide installation directory.

3. Synchronize Carbide.c++ with our SCM.
- Go to Project Explorer, right click at the project and select Team->Share Project.
- From the repository list, you can see list of available repositories, select Perforce.
- Perforce setting parameters can be taken from your P4 client.

Now, we have our environment ready. (I rebuilt my project with Carbide.c++ 2.0 with my old S60 3rd Edition, there was no problem).

4. Install S60 5th Edition SDK
- Here is the link to Nokia's forum to download the 5th Edition SDK

5. Install the SDK plugin.
- Right now, I still have not found any plugin for 5th Edition of S60.

You need to edit your Carbide's project to have a configuration for 5th Edition and the rest depends on your application.


Lately, I have been so busy in the office. Therefore, I have no time to continue on my package updating story but I will try to finish the second part as soon as I can.


---------------
"I spend almost as much time figuring out what's wrong with my computer as I do actually using it." Clifford Stoll, Silicon Snake Oil

Thursday, January 15, 2009

A story of package updating...#1

Today is not a busy day. The work has been done soon enough. I have plenty of time left ... after finishing several newspapers, I decided to continue upgrading my old Linux PC at work. It is an AMD Athlon 1.0 GHz with 512MB RAM. I took it over a few years ago before the IT guys would put it in the cellar. It has proved to be a good companion over time. Its only one defect is the on-board clock is unreliable. My clock tick is shorter than the normal clock. That meant, after setting it correctly with date, after one hour, it will run faster than the reference system for around 20 minutes. As long as I don't need to synchronize my work to the network, it is still acceptable (Although this is really annoy) I ever tried to synchronize it using NTP server but it did not help, so I gave it up.

After left it untouched for more than a year, I decided to update the system.
I started off from connecting my Linux from my Windows via XDMCP from cygwin with

$XWin -query linux-pc -screen 0 1280x1024

where 0 from screen option is the screen number and 1280x1024 is the geometry I want it to be. Or use the following command:

$XWin -query linux-pc :2

:2 is to tell the X server of the display number, the default is 0. You need to tell the X server of which display you have if you have multiple X accesses to the X server. The X server will assign a unique display number for each connection. Nevertheless, to enable network establishment between X client and server, you need to allow for X forwarding in your X configuration and keep in mind that this connection is insecure. It is therefore recommended only for home network.

One alternative to connect to Linux from Windows is to use VNC, although it has several advantages but using X via VNC is slower than using XDMCP.

---------------
"What Every Computer Consultant Needs to Know:
1) In case of doubt, make it sound convincing.
2) Do not believe in miracles. Rely on them."
Murphy's Computer Laws (Finagle's Rules)

Tuesday, January 13, 2009

Python 3.0 Release

Python 3.0 was first released on 3rd of December 2009. Let's see what is new!

---------------
"All programmers are playwrights and all computers are lousy actors." Anonymous

Thursday, January 8, 2009

Fonts and the FreeType Project

Now, version 2.x. The following paragraph is excerpted from FreeType Project; "FreeType 2 is a software font engine that is designed to be small, efficient, highly customizable, and portable while capable of producing high-quality output (glyph images). It can be used in graphics libraries, display servers, font conversion tools, text image generation tools, and many other products as well."

What makes it popular and I need to state it here, you may question? Probably, because it can be used in any proprietary or non-proprietary projects. That means you can write your application equipped with this library and sell it.(See FreeType license)

---------------

"Life is pleasant. Death is peaceful. It's the transition that's troublesome." Isaac Asimov

Monday, January 5, 2009

To conflicts in this world...

"I am not an Athenian or a Greek, but a citizen of the world."

Socrates, from Plutarch, Of Banishment
---------------

"An eye for eye only ends up making the whole world blind." M.K. Gandhi

Sunday, January 4, 2009

Reset old root passwd with chroot

For at least 2 years, I did not need to transform myself to become superuser, root. Sudo is fit for everyday admin's works and Linux is very stable. (As you know it) Hence, I hardly need to configure anything new. New year has come and I wants to update and clean up things. And the most graceful amenity way to do things is to become the superuser. However, at that moment, I found out that I forgot the root passwd! 1..2..3.....10.....15 tries, ahh..without sucess. Enough is enough. Let's reset the old passwd!

Rebooting the system with a bootable CD. (Here, I did not know where I did keep my Debian CD, I didn't use it for ages. I searched around and ahh..I still have KNOPPIX CD.)


After rebooting the system, at the command prompt, let's create temporary directory mount point.
#mkdir /mnt/hda3

Mount the partition, in my case it locates at /dev/hda3.
#mount -t reiserfs /dev/hda3 /mnt/hda3

Here comes the chroot in action:
#chroot /mnt/hda3

You may be able to see your root shell path changed. Ok, we now call the "passwd" command, the shell will not ask for old passwd but allow us to enter new passwd straightaway. Reboot and remove your bootable CD. Done.

-----------------

"With Great Power, Comes Great Responsibility." Uncle Ben to Peter Parker in Spider-Man. I came upon this quote the first time when I first tried "sudo".

Thursday, January 1, 2009

Essential Design Pattern Websites

I just wanted to check out Active Object Pattern from Douglas C.Schmidt which I have not finished reading yet. I happened to explore some links on his websites and finally found the following:


---------------

"To build may have to be the slow and laborious task of years.
To destroy can be the thoughtless act of a single day."
Sir Winston Churchill