Friday, August 10, 2012

Nexus 7 (Refunded)

I just got my Nexus 7 last week. It is one great looking device, plus it is much lighter compare to 10" tablets. Android Jellybean offers big improvement over Honeycomb. I owned 10" Galaxy Tab, I almost never used it for anything, since it is really bad. The browser is bad, and the tablet can become very slow over time.

Nexus 7 comes to the rescue. However, I got some issue with the LCD. It seems that ASUS has pretty bad QA. The LCD is not properly attached to the body. It is lifted by tiny bit, and I can feel it by gently touching the glass. I have contacted Google. They have confirmed that these issues are common. It just convinced me even more that ASUS has really bad QA. I will try to avoid their products in the future. I have had one bad experience with their laptop about 10 years ago. I thought they have changed.

The replacement tablet is on its way, and I hope it doesn't posses similar problem to my current one.

UPDATED: The replacement Nexus 7 still had the screen separation issue, it's even worse than my original. I decided to refund the item, because the screen separation issue was such a deal breaker for me.

Nexus 7

Tuesday, June 12, 2012

Cross Compile PHP for Arm

I just want to share some techniques to cross compile PHP for Arm using CodeSourcery Toolchain. Most of the resources I found out there do not show me how to include mysql client library as well as SimpleXML parser. These two libraries are needed for my case. Following are the how to Download PHP Source Code

I am using PHP 5.4.2. You can download it from php site.

Download libxml

I am using libxml2-2.8. TOOLCHAIN_DIR is the directory pointing to your toolchain library, in my case, it's /opt/toolchain/arm-2009q3/arm-none-linux-gnueabi/libc.

./configure --host=arm-linux-gnu --target=arm-linux CC=arm-none-linux-gnueabi-gcc
AR=arm-none-linux-gnueabi-ar LD=arm-none-linux-gnueabi-ld RANLIB=arm-none-linux-gnueabi-ranlib --prefix=[TOOLCHAIN_DIR]

Then issue

make install

Configure mysql config file

When compiling with MySQL support, I kept encountered following error:

mysqlnd/mysqlnd_portability.h:40:36: error: ./php_mysqlnd_config.h: No such file or directory

I got help from this site. Following is what you need to do to fix the missing file problem:
  1. Goto your php source folder, and navigate to ext/mysqlnd
  2. Then issue 
mv config9.m4 config.m4
sed -ie "s{ext/mysqlnd/php_mysqlnd_config.h{config.h{" mysqlnd_portability.h

Build PHP

Please note that I need to specify explicit location to libxml directory in order to compile successfully, please change the path to the location of your libxml library.

export CC=arm-none-linux-gnueabi-gcc
./configure --host=arm-linux --without-pear  --enable-libxml --with-libxml-dir=/opt/toolchain/arm-2009q3/arm-none-linux-gnueabi/libc --enable-simplexml --enable-mbregex --enable-sockets  --enable-soap --enable-pdo --with-pdo-sqlite --with-sqlite3 --with-openssl --enable-calendar --enable-mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --disable-all
make -j 12

Afterward, you can find the binary, php-cgi, inside sapi/cgi folder. Hope this tip could be useful.

Wednesday, May 23, 2012

GSOAP Unicode

It has been a while since my last post. I have been busy doing low level C stuff related to Bluetooth and WiFi in the last two years. There are couple of findings that I want to share during these years. I hope they could be useful to others as well.

Let's get down to the topic. We have been using GSOAP C++ to handle our web service call. We could tweak GSOAP to support unicode on Windows by modifying the typemap.dat file:

xsd__string   = | wchar_t* | wchar_t*

(note: some might wonder why we don't use std:string or std:wstring, one of the requirement given to us was to use primitive data type, so we don't really have choices here)

In Windows. char is 8 bits only and wchar_t is 16 bits. Things are good, we used wchar_t* to store all our strings. Then, we migrated to Linux. In Linux, we are using char, because it is already capable of supporting UTF-8 unicode (i.e. datatype char in Linux is 16 bits).

Under Linux, GSOAP doesn't support unicode if char is used. We found it too troublesome to change all our string datatype to to wchar_t*. 

I finally come up with the idea to hack header file generated by GSOAP wsdl2h. I modified certain strings that needs to be in unicode to wchar_t*. So, only certain string variables are in wchar_t*, not all.

Next, I encounter problem trying to convert wchar_t* to char*. Using wcstombs doesn't help. I have UTF-32 stored in wchar_t* from GSOAP, and I am trying to convert it to UTF-8 stored in char*.

I finally find handy help from code project. It pointed me to library file; however, it's a broken link. I manage to find it hosted somewhere in Googlecode site. The code project help and library help me to convert wchar_t* to char* (UTF-32 to UTF-8) successfully. It's a big relief.

That's it for now.

Wednesday, May 26, 2010

ADB Driver for HTC Evo 4G

I just came back from Google IO 2010. It is awesome developer conference. Each attendee was given Nexus One , HTC Evo 4G, and of course Google TV Socks :) HTC Evo 4G is amazing device.

HTC Evo 4G

I got home, hooked the Evo to my PC and found that my Windows machine did not recognize it. I managed to find the solution in Android Developer Google Groups, you can read it here. We basically need to modify the entry in android_winusb.inf to add the VID and PID of HTC Evo. You can download the modified android_winusb.inf from here (right click on the link and select save as).

Monday, December 14, 2009

IEC Christmas 2009 / Projector Calibration

We just finished with our church Christmas Celebration, it was tiring, but it was worth it. We had wonderful team working together to serve God in this event. Great job guys and gals!

GII Christmas 2009 Crew

I would like to share one challenge we encounter in the visual presentation team. The challenge actually starts last December, but I just write about it now. Last December, we are asked to utilize projector for helping audience to virtualize settings in the drama, since we do not have any physical stage decorations. So far so good, we just create the contents and display them using appropriate program. Ideally, we will have something like the following.

Ideal Projector Placement (credit to Martin for the illustration)

However, we could not implement the ideal projector placement. We have problem hanging the projector, as we do not have skill to build custom mounting bracket that could be hang on the curtain's rod (i.e. we rent the building, so we could not mount anything on the wall). Ehm...trouble, fortunately, I found an idea that we could use. If I could put the projector on the side and adjust the perspective, I could achieve larger projection size without obstructing drama/choir people and I do not have to hang the projector at the top center. In short, the program development is started right away and the first version is used last December, unfortunately, with a lot of bugs :(

Implemented Projector Placement (credit to Martin for the illustration)

In the initial release, the ideal perspective could not be achieved, because I only consider translation, scaling, and skewing. I miss rotation. Hence, on last December event, half of the projection image looks ok, the other half looks stretched :( Moreover, there are heavy memory leak on the program at that time as well, so video playing is pretty bad.

Image on the left side is ok, but it is stretched on the right side

Time passed, the program is still used on Easter, but this time we avoid placing projector at extreme angle to avoid rotation problem I mentioned above. We are ok this time since the building we rent has enough space that allow us to do rear projection, and we also put another projector on the balcony. In total, we used three projectors: two projectors for rear projection to form 2048x768 resolution, and one projector on the balcony, mainly used for subtitle and video (i.e. projector calibration is disabled on this projector).

GII Easter 2009 Celebration

This year, we are renting the same building as last year. Ehm...I am pretty scared when hearing about this. I suggest to the stage coordinator (ko Hendri) to find a way to mount the projector on top at the center of the stage.

In the mean time, I try to go through my program's code to perform various improvements, I also added rotation as one of the variable when adjusting the perspective. I fix most of memory leak, but I am sure there are still some that still exist. I do not have enough time to dig into this. However, we are able to handle video playing at 1024x768 without any problems.

So I notify ko Hendry and do demo to show that the program could be used again this time. He agreed and then we proceed with it. We do however need to rent a projector with 4000 ANSI Lumens, since our projector could not handle it (ie. 2500 ANSI Lumes).

2009 GII Christmas Celebration (Image Courtesy of pak Felix Teja)

That's it, I forgot to mention that everything is done in Flash, which could easily top up CPU usage. Machine on the left (gray machine) is used as controller for both audio and video. Machine on the right is running the projector calibration program only. It is being controlled via socket by the gray machine. I used my Android G1 to remote control the audio and WiiMote to remote control the projector calibration program. It is possible to control everything just with mouse and keyboard, but I am more comfortable with this setup.

The Machines

For the next version, I am planning to bring everthing to OPENGL, GPU could give better horse power especially when we want to play HD video.

That's it for now.

Tuesday, October 27, 2009

Android 2.0 aka Eclair is Here

Waow, Android 2.0 SDK is just released. It now supports RFCOMM Bluetooth, which is great for peer to peer communication. WIFI is great but it does not work when you want to establish communication with other devices in WIFI-less environment. I also could not depend too much on 3G, in some areas, it is very slow and sometimes it does not even exist.

Monday, October 5, 2009

Automating inDesign for Repeating Content and QR Code

Our church is going to hold Bible Camp this coming week. We are all getting busy preparing for this event. I am responsible for creating publication materials, such as event booklet, brochure, name tag, etc.

Creating name tag might sound easy, but how about creating name tags for 50 persons. It will be painful to do it manually, copy and paste the layout plus typing names fifty times. So, I did some reading on Adobe inDesign documentation and found out that it's possible to create placeholders for repeating content using XML. Here is the article that I used. I just need to design the name tag, generate XML data for all attendees using Perl script, import XML to inDesign, and inDesign will do the rest of the work.

Generated Output by inDesign

Notice above figure, there is small box on the right of each name. It is QR Code containing information for each person. I was thinking that since I am going to automate the name tag creation process, why not adding some extra information. I decided to add QR Code and our team decided to add color coded group information (i.e. person with the same color belong to the same group).

Bible Camp GII 2009 Name Tag

I wrote a PERL script for grabbing contact information of each Bible Camp 2009 attendees from our church database and use GD-Barcode module to generate the QR Code associated to each individual.

Most people nowadays have phone with built-in camera, and most of them can decode QR Code. So, I think this as a good way for letting people to exchange their information with each other easily during our Bible Camp event. That's it for now. Following QR Code contains our church contact information.

Decoded Message on Android