Thursday, April 8, 2010

Set up a multifuction gadget, Epson Stylus Office BX300F

I just bought a new multifunction or All-in-one gadget, Epson Stylus Office BX300F and how I added the device as printer & scanner on Linux is described here.
With this device you can: copy the document, scan the document to a file, send/receive fax and print the document. (Note:This device doesn't come with USB cable.)

Let us do it step by step.

1. After hardware set-up, first of all do not forget to check up the copier and fax.

2. Connect the USB cable from your device to your computer, if you have cups already installed, it will detect your gadget automatically. Or check the connection with

$ sudo lsusb

In my case, I have my printer HP LaserJet 1300 as first printer which I already configured the cups, so the new device was immediately recognized by cups. If you do not have cups install before, please install "cups" packages to allow the printing configuration much easier. After cups installation, you can now add new printer or set your printing configuration by cups by typing the following url at your browser:
http://localhost:631.

Here are the properties of my printer (Click on the Right-most tab to view):

Description: EPSON Stylus Office BX300F
Location:
Driver: Epson Stylus Office BX300F - CUPS+Gutenprint v5.2.4 (color)
Connection: usb://EPSON/Stylus%20Office%20BX300F
Defaults: job-sheets=none, none media=na_letter_8.5x11in


If, for some reasons, "cups" cannot find the driver for your gadget or similar hardware, you probably need to install the printer driver manually. See further step to search for your printer driver.

3. Next step, I installed "xsane" for scanner and started xsane, however I received the message that it could not find the scanner device!
That meant, no proper scanner driver had been installed. Let's visit Avasys, it has all kinds of linux drivers for various gadgets.
(http://avasys.jp/eng/linux_driver/) Select your model listed there and the page will lead you to the driver for your device, here I found drivers for my Epspon printer and scanner.


$ sudo dpkg -i iscan_2.24.0-4_i386.deb
$ sudo dpkg -i pipslite_1.4.0-5_i386.deb

Now let us test the scanner; try "xsane" again!

4. The last step is to configure your xsane. One remarkable point I found was output scanned with 300 dpi for pdf or ps was always too large and document with 150 dpi has poor quality. (I expect some resolution around 200 dpi would be good but there was no option for 200 dpi but 75,150,300,600,1200 and 2400) What I did was saving the document as JPEG and converted JPEG to postscript from Gimp and set the compression scale of JPEG to yield the quality around 80-85% then rescaled image as necessary with Gimp. Saving postscript from JPEG also produces a large file, applying "ps2pdf" to convert file from postscript to pdf generates a very good result. That's it!

Tuesday, February 23, 2010

Qt and Symbian

After Nokia took over Trolltech in 2008, it has been foreseen that Qt would come to be part of mobile phone development very soon. Symbian and Maemo (now also known as MeeGo) developers are moving quickly to Qt for GUI application. Yesterday, I managed to start off my first Qt app before bid farewell to Symbian end of this month and the following info is my quick glance of Qt resources from Symbian developer perspective.

- Qt for the Symbian Platform (Product Overview)
- Using Qt and Symbian C++ Together from developer.symbian.org. This will guide Symbian developer to integrate Symbian to Qt more smoothly. The info in the page conveys the information e.g., Converting Active Objects to Signals & Slots, Converting between QString and Descriptor,Exceptions & Error Handling, et cetera.
- Qt Carbide.c++ IDE. To configure Carbide.c++ for Qt if it is prefered to QtCreator.
- Qt Creator with the Symbian Platform. Its build-in Help is superb.
- qmake Manual. Knowing of qmake to handle the project file (.pro) is mandatory. You need to know few extra specific parameters for Symbian, the manual will help you out.

-----------------------
We only part to meet again. ~John Gay~

Thursday, February 4, 2010

today's interesting blog(s)

A message from experience programmer to programmers:
20/20: Top 20 Programming Lessons I've Learned in 20 Years


Interestingly how the author could think of it from Fibonacci number point of view:Using Fibonacci Numbers to Convert from Miles to Kilometers and Vice Versa

You must read the discussion & comment below the article:12 Bonehead Misconceptions of Computer Science Professors

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