If your application needs to support multiple languages or if it needs to support languages with different character sets such as simplified Chinese (GB2312, GBK, GB18030, HZ,..) or traditional Chinese(BIG5, HKSCS, EUC-TW) you’ll need to make yourself familiar with Unicode and the different character sets. In this article, we’ll focus on introducing character sets, manipulating and converting charsets and the possible challenges you may encounter while handling Unicode text files. If you plan to support multiple languages, you’ll also have to internationalize your application, for example by using Po files for different languages, a Po file editor and possibly have the translations done in launchpad if your project is open source. But this would be another subject. Go for Unicode If you are building a new application make sure its structure is based on Unicode (UTF-8, UCS-2, UTF-16 or UTF-32 ) since those charsets can handle most written languages (UTF: […]
Linux Scripts to find Public IP Address
In some cases, you may need to know your public IP or the public IP of a server behind a NAT (e.g. for remote SSH login) if the IP is assigned dynamically as is the case for PPPoE connections. Here are several ways to find your public IP in Linux using the shell. 1. Using curl (almost too simple) curl -s http://www.whatismyip.org 2. Using wget wget -q -O – checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’ 3. Using lynx lynx -dump checkip.dyndns.org If you have access to a web browser, you can simply use http://www.whatismyip.org, http://checkip.dyndns.org or http://www.moanmyip.com. Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011. www.cnx-software.com
Linaro: Embedded Linux for ARM
Linaro is a Not For Profit (NFP) engineering organisation that works on Linux based open source software and tools. The organisation focuses on the ARM platform, mainly ARM v7A architecture, for example ARM Cortex-A8 or dual-core Cortex-A9 processors and is sponsored by ARM, Freescale, IBM, Samsung, ST-Ericsson, and Texas Instruments. The purpose of Linaro is to reduce the number of different Linux kernel for the ARM platform. They plan on releasing tools and Linux kernel every 6 months. And after about 6 months of existence, with around 80 engineering staff, they managed to release their first public version: Linaro-10.11 on the 10th of November for TI OMAP4 Panda Board, IGEPv2, Freescale iMX51 and ST-E U8500 platforms. This release is based on Linux 2.6.35 kernel, GCC 4.4 toolchain and uBoot 2010.09. They released Linux 10.11 source code and tools, the hardware packs and the build instructions. Linaro also planned several technical […]
USB Hotplug Parameters and A Simple Linux USB Hotplug Script
USB Hotplug allows your system to detect a USB device has been inserted or removed and perform certain actions upon the USB device detection. The article below is largely inspired by http://linux-hotplug.sourceforge.net/?selected=hotplug which does not seem to work anymore. USB hotplugging involves: MODULE_DEVICE_TABLE support in the USB Device Driver API, so that a driver’s probe() routine is called only when it’s very likely to want to bind to a particular interface. USB always uses this. Support for invoking the hotplug helper (/sbin/hotplug by default) when devices are added or removed. This functionality is enabled only by CONFIG_HOTPLUG. That hotplug helper usually contacts a policy agent which handles the USB-level configuration or activation tasks appropriate to this device and the current system configuration. Boot-time configuration (“cold-plugging”) can be managed by the /etc/rc.d/init.d/hotplug startup script, if the “usbmodules” command line utility is available. (There is also a “diet hotplug” tool for use […]
Socket Programming: Client crashes when exiting server
One of our digital signage applications was crashing when the control server was shutdown at the same time a command was sent with no apparent reason. It would always crash inside the write function (see code below) and no error message were returned. sent = write(fd, buf, n); After a while, we found that in case the connection with the server is lost, and write tries to access the server, it will generate a SIGPIPE signal and in most systems, the application would just exit by default. A simple way to handle this case was to ignore the pipe signal by adding the following line during initialization: signal(SIGPIPE, SIG_IGN); In case the server is down at the time the write function is called, the signal SIGPIPE would be ignored, write would return -1 and errno should return 32 (Broken pipe). Alternatively, if needs be you could also handle the SIGPIPE […]
List the dynamic libraries used by a program
In order to know which dynamic libraries a particular binary is using, just type ldd. For example with busybox: sh-3.00# ldd /bin/busybox /bin/busybox: is setuid libcrypt.so.0 => /lib/libcrypt.so.0 (0x2aaed000) libm.so.0 => /lib/libm.so.0 (0x2ab41000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2ab9c000) libc.so.0 => /lib/libc.so.0 (0x2abeb000) ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x2aaa8000) Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011. www.cnx-software.com
Digital Signage: Implementing a smooth scrolling text
Many digital signage hardware feature scroll text. However, in many cases the scrolling text is either not smooth, sometimes teared or very slow. It may depends on the performance of the hardware used but also on the implementation of the software. Once easy way to implemented scrolling text is just to redraw the text again and again at different position. However, this is very slow and yields poor results unless maybe you have a Truetype accelerator or similar hardware font accelerator. The next step is then to convert the text into pixmaps. This can either be done in the digital signage manager software (Windows PC/MAC or Linux based) or the digital signage player. Doing so in the latter makes it much more flexible. So you may create 2 pixmaps whose width and length match the region to be displayed, you write the text on those 2 pixmaps, then simply move […]
Script to convert Twitter RSS feeds into text
[Update Nov 2012: URLs such as http://twitter.com/statuses/user_timeline/759251.rss do not work anymore, but you can get a Twitter timeline RSS feed by using http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=xxxxx, where xxxxx is the screen name such as cnxsoft] We needed to convert Twitter RSS feeds to UTF-16 text for displaying them into a digital signage (That did not support RSS feed directly). This digital signage supports regular http download, .e.g every 5 minutes. Here’s the script (called with crontab) we used for CNN News Twitter RSS feed. #!/bin/sh # CNN Twitter wget http://twitter.com/statuses/user_timeline/759251.rss sleep 10 cat 759251.rss | grep title | sed s/\<title\>// | sed s/\<\\/title\>// > cnn.txt rm 759251.rss iconv -f utf-8 -t UCS-2LE cnn.txt > cnn-utf16.txt cp cnn-utf16.txt /var/www/html/livepics/cnn.txt The resulting text file looks like: Twitter / CNN CNN: BREAKING NEWS: Military: Last U.S. brigade combat team leaves Iraq; 56,000 troops remain. Fifty-thousand set to stay past August 31. CNN: NY Gov. David Paterson […]