Currency display issues with Magento

July 1, 2009 by buckycat

Lately, we have been implementing an open-source ecommerce system, Magento, for a client. Magento seems quite nice, and fully featured, and the code seems well organised, and easily extensible. The main issue at the moment is the shortcomings in documentation. This post is largely a copy of one on the Magento Wiki, and added here only because that page strangely disappeared once.

Indian users of Magento might have encountered what seems to be a strange display problem, where Indian currency is displayed as “Rp” rather than “Rs” with Firefox on Microsoft Windows (IE7 on the same platform shows a box).This happens because Magento (through Zend) uses the Unicode codepoint, U20A8, for the INR currency symbol, rather than the string “Rs”. This is actually correct behaviour, but Microsoft Windows fonts apparently lack coverage for this codepoint unlike in Linux. Hence, the wrong display with Firefox on Windows (I am not sure why it falls back to Rp, and this seems to be a bug in Firefox’s fallback mechanism). This issue is not unique to INR, and similar problems will probably crop up for other currency symbols in the Unicode range U20A0-U20CF.

A possible solution is to edit lib/Zend/Locale/Data/en.xml (assuming one is using an English variant as a locale, e.g., en_US or en_UK. For users of a French variant locale, one would similary edit lib/Zend/Locale/Data/fr.xml), find the entry for “<symbol>U20A8</symbol>”, and within it replace “U20A8” (here, U20A8 is the actual Unicode character, and might show up differently depending on your editor and operating system), and replace it with “<symbol>Rs</symbol>”. Do not forget to refresh the cache. A better method would be to override this setting with a local modification within Magento to lib/Zend/Locale/Data/en.xml, but I am new to Magento and am not sure how to do this.

Here be Dragons

March 24, 2009 by buckycat

Over the past year, we at Srijan Labs have been dabbling in a variety of areas. One key area of interest has been the possibilities afforded by GPS tracking, FOSS GIS tools, and location-based services centred around these. Also, of interest to us is how these services can be harnessed through mobile devices like cell-phones, and hand-held devices that are becoming increasingly ubiquitous. With this in mind, I have put down some thoughts in a document available here as PDF. Nothing earthshaking, but just an idea of the areas which we wish to explore in the immediate future. Comments are invited.

Download PDF article

Multiple Bluetooth GPS devices

April 2, 2008 by buckycat

This article takes off from where the initial note on using GPS Bluetooth devices left off, and shows you how to use more than one Bluetooth GPS device at the same time. This is actually quite easy.

  1. Set up /etc/bluetooth/hcid.conf as described in section F. of the initial note
  2. Get the ID for both devices as described in section E. of the initial note
    • hcitool scan
      should now show you two GL50BT devices, something like:
         00:01:53:02:DF:A5 GL50BT
         00:01:53:02:DF:BA GL50BT
  3. Edit /etc/bluetooth/rfcomm.conf as in section G. of the initial note, adding an entry for the second device. Mine now looks like:

    #
    # RFCOMM configuration file.
    #

    rfcomm0 {
    # Automatically bind the device at startup
    bind no;

    # Bluetooth address of the device
    device 00:01:53:02:DF:A5;

    # RFCOMM channel for the connection
    channel 1;

    # Description of the connection
    comment "GL50BT GPS device 1";
    }

    rfcomm1 {
    bind no;
    device 00:01:53:02:DF:BA;
    channel 2;
    comment "GL50BT GPS device 2";
    }

  4. Establish RF communication similar to section G. of the initial note. Thus:
       sdptool add --channel=1 OPUSH
       sdptool add --channel=2 OPUSH
       sudo rfcomm bind /dev/rfcomm0 00:01:53:02:DF:A5
       sudo rfcomm bind /dev/rfcomm1 00:01:53:02:DF:BA
    Remember to match the device ID to rfcomm0 or rfcomm1 according to as defined in /etc/bluetooth/rfcomm.conf
  5. You can now check that things are working by opening /dev/rfcomm0, and /dev/rfcomm1 in cutecom. In principle, as Bluetooth transfer rates are much faster than the serial transfer rate from each device, it should be possible to transfer data from two devices in parallel, achieving a higher throughput. However, I have yet to check whether this is true in practice.

Bluetooth GPS devices with Linux

January 18, 2008 by buckycat

A. Talking to Bluetooth GPS devices with Linux

This is a guide for communicating with Bluetooth GPS devices on a Linux platform. As there are a wide range of GPS Bluetooth devices, and a fair number of Linux distributions, we focus on the GL50-BT device from San Jose Navigation on an Ubuntu Gutsy (7.10) distribution. However,
the ideas should be generally applicable to other Bluetooth devices, and to other recent Linux distributions. Much of this information is gleaned from a thread on Ubuntu forums, but is made specific here to Bluetooth GPS devices.

B. For the impatient

Impatience being one of the cardinal virtues of a FOSS programmer, if you do not have the time to go through the entire article, here is a minimal set of steps for getting your Bluetooth GPS device working:

  1. Get Bluetooth working on your computer: You will need to install the appropriate packages. On some machines, such as Acer laptops, you might also need to install a kernel module. Check that Bluetooth is working, with:
    • hcitool dev
      This should display the ID of the Bluetooth device on your computer, something like:
         hci0 00:16:CE:DE:3C:B1
    • hcitool scan
      will now scan for other devices that are in range. Make sure that Bluetooth on the GPS device is on, as some devices are discoverable only at startup, or when a button is pressed. You can also check that the scan is working by having another Bluetooth device, such as a mobile phone, within range. You should see something like:
         00:01:53:02:DF:A5 GL50BT
      If you have trouble detecting the device, one thing to ensure is that the batteries are in good shape. Bluetooth uses up a fair bit of power, and II have had trouble connecting when the batteries are low.
  2. Set up /etc/bluetooth/hcid.conf
  3. Set up /etc/bluetooth/rfcomm.conf
  4. Establish RF communications:
       sdptool add --channel=1 OPUSH
       sudo rfcomm bind /dev/rfcomm0 00:01:53:02:DF:A5
    Use the channel no. specified in /etc/bluetooth/rfcomm.conf, and the Bluetooth ID for the GPS device as reported by “hcitool scan”.
  5. Read data fom the GPS device:
    • cat /dev/rfcomm0
      will read realtime NMEA data from the device, but included with this will be binary data in the device buffer
    • sudo gpsd /dev/rfcomm0
      will start gpsd using the proper device node, and
      gpspipe -r
      will show you properly formatted NMEA sentences.

On to the detailed instructions.

C. Packages to install

This is what I have installed, though I am not sure if all packages are needed, nor if I have missed some that are not included by default in Gutsy. Please let me know of any required modifications:

  • bluez-gnome
  • bluez-utils
  • gnome-bluetooth
  • kdebluetooth
  • Also, useful are

  • cutecom
  • gpsd
  • gpsd-clients
  • gpsdrive
  • gpsd seems to work with the GL50-BT, though I did have some problems, and am not yet completely satisfied.

D. Get bluetooth working on your laptop

This might involve having the proper drivers, and the appropriate kernel modules. For an Acer laptop, you should use the acerhk kernel module. Thus,
   sudo modprobe acerhk
   echo on > /proc/driver/acerhk/blueled
The blue LED on the front should now come on. “hcitool dev” should also show you something like
   hci0 00:16:CE:DE:3C:B1
Check http://www.cakey.de/acerhk/ for supported model numbers. If you do not see your model number, and the above instructions do not work, you can often force the series to the closest model number lower than the actual model number. Thus, for the unsupported Acer Travelmate 4200, use:
   sudo rmmod acerhk
   sudo modprobe acerhk force_series=4000
   echo on > /proc/driver/acerhk/blueled
Likewise, the Acer Aspire 5550 can be coerced into working with
   sudo modprobe acerhk force_series=5020
The documentation for this driver in the Linux kernel source has more details.

E. Check device visibility:

Turn the GL50-BT off, start “hcitool scan”, turn it on, hold the little white button, labelled “connection”, down for a couple of seconds, and release. The connection button can also be used to re-establish a dropped connection while the GPS is running, but this does not seem entirely reliable.
   hcitool scan
should show you something like:
   00:01:53:02:DF:A5 GL50BT
   00:1D:FD:EC:AC:44 Rahul
The GPS device here is the one labelled GL50BT, while the other one is a Bluetooth-enabled mobile phone that was in range. The first string of digits is a device-specific ID.

F. Edit /etc/bluetooth/hcid.conf

Mine looks like:

#
# HCI daemon configuration file.
#

# HCId options
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security none;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;

# Default PIN code for incoming connections
passkey "1234";
}

# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";

# Local device class
class 0x3e0100;

# Default packet type
#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan
iscan enable; pscan enable;
discovto 0;

# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;

# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;
}

From my incomplete understanding of the file format:

  1. The “autoinit yes” and “security none” options are important.
  2. In the device section, the “lm master” is what is recommended, though things seemed to work for me with “lm accept”. Not sure what the difference is.
  3. In the device section, the “class 0×3e0100″ is important. Part of the bit settings in the class indicate that this is a location device. However, there are apparently other ways (sdptool) of setting up communications.

G. Edit /etc/bluetooth/rfcomm.conf

Mine now is:

#
# RFCOMM configuration file.
#

rfcomm0 {
# Automatically bind the device at startup
bind no;

# Bluetooth address of the device
device 00:01:53:02:DF:A5;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "GL50BT GPS device";
}

Notes:

  1. The device ID string in “device 00:01:53:02:DF:A5″ is specific to a GPS unit. Use the one reported for the GL50-BT by “hcitool scan”.
  2. The comment string is arbitrary.

H. Establish the RF communication:

   sdptool add --channel=1 OPUSH
should return something like,
   OBEX Object Push service registered
and,
   sudo rfcomm bind /dev/rfcomm0 00:01:53:02:DF:A5
should set up /dev/rfcomm0 for communication with the device. Again, the last string is the device bluetooth ID, e.g., as reported by “hcitool scan”.

I. Read data from the device

You can check quickly that things are working with:
   cat /dev/rfcomm0
Be warned that binary characters in the output might be interpreted as ANSI escape sequences, and scramble your terminal settings. Pipe output into less. (For gnome-terminal, you can recover from a scrambled terminal with Terminal > Reset and Clear, followed by hitting keyboard return.)

A better way is to use gpsd. E.g.,
   sudo gpsd /dev/rfcomm0
will set it running in daemon mode. You can examine NMEA sentences from the GL50-BT with
   gpspipe -r
One can also run cutecom, using device /dev/rfcomm0. All the usual GL50 device-specific commands, @PCgs, @PCsr, @PCrr, etc., work as expected. Programmatic readout of stored data should also work, but I have not tried that as of yet.

J. Resuming connection, and data reading

Note that once the above commands (C-H) are done, there is no need to redo them unless the machine is rebooted. Thus, one can turn off the GPS device, turn it on again (maybe checking that it is visible with “hcitool scan”), and reading GPS data from /dev/rfcomm0 should still be possible. Likewise, gpsd should still be running, so that rerunning “gpspipe -r” should start showing NMEA sentences.

Srijan Labs takes wing

January 18, 2008 by buckycat

Welcome to Srijan Labs

For far too long, Srijan Labs has been just a gleam in our collective eye. Driven by some interesting recent exploration in the area of GPS devices and mobile phone applications, we have finally taken the plunge and formally set up Srijan Labs to explore cutting-edge technologies. Srijan Labs aims to combine our proven experience in web development with our expertise in programming to provide interesting interfaces to emerging technologies.

We will be exploring several areas of new technology, with a view to developing mashups that bring out new possibilities. Besides commercial product development, we have the explicit goal of taking up fun and socially useful projects.

Immediate areas of interest

We are currently looking at the following areas:

  1. Geo-location: With GPS-based devices, and information from other location sources such as cell phones and stray wireless connections, it is now possible for one to know their physical location on the Earth, and to build their own maps of the territory. Geo-location, as this area of work is called, might sound trivial on the face of it, but it opens up exciting possibilities, such as making up your own idea of what constitutes a map of your locality. For example, my ideal map would have real dragons at the edges, and well-marked locations for damsels, whether in distress or not. Community-based maps are now a distinct possibility, and there are indeed plans afoot to do just that in India. Several workshops are being conducted for this purpose at various places around the country. Various aspects of social networking can also be addressed, such as the ability to view on your mobile phone a map of where your friends currently are, peer-recommended areas of interest, etc. Some examples of the stuff that we have been playing around with are at:
    1. Sudev’s trip to Sonepat (look for a blue line going to Sonepat, and a red one for the trip back)
    2. Same trip showing the GPS data points (1 in 100) as markers
    3. Four tracks: Same trip, showing four different tracks from two GPS devices in the vehicle for the up and down trips
    4. Many more applications are on the way on the site, including ones that let you register on the site, and upload your personal GPS tracks, and landmarks. Watch this space.

    The possibilities are practically endless, and various people are doing interesting things in this area, such as at:

  2. Mobile phone applications: Maybe we are late to the party, but we have just woken up to the fact that there are more Java-enabled mobile phones in the world than there are personal computers. J2ME standards notwithstanding, in our opinion, the problem with the mobile computing world is that there are so many standards to choose from. It is here that initiatives like the Linux Phone Standards Forum, and even the Open Handset Alliance working on the Android platform are sorely needed.

    Open source is also reaching the hardware, and we are keeping a keen eye on the OpenMoko phone. Hackers, including students here in India, have managed to put together a mobile phone that is open-sourced right down to the hardware. While still some time away from being available on the market as an end-user phone, it can be used right now by people willing to get their hands a little dirty. We are in the process of acquiring a copy of this.

  3. Bio-informatics, and bio-technology: Bio-technology is one of the forefront areas of current research, and we are living in an era in which advances in bio-technology will bring about almost unimaginable changes to our lives. Bio-informatics matches these advances with those in computing, and offers many exciting possibilities, such as open-source drug design.

    We have worked with the Centre for Bio-Technology at the Jawaharlal Nehru University (JNU) on a student-mentoring project, aimed at producing an open-source drug design program. Though this project has since been made somewhat redundant by the open-sourcing of Autodock, we look forward to continuing our collaboration with JNU.

  4. Open-mesh wireless networks: We have not really gotten started on this as we need to go out and buy a wireless router that can be hacked on. However, the idea is to use private wireless routers to put together an ad-hoc network that is independent of commercial networks. Such networks are entirely community based, and it is possible to use the Internet as a backbone to hook up mesh networks in widely separated locations. Various examples exist all over the world, and people at Janastu (Servelots) in Bangalore have set up one there. Similar ideas are also being actively pursued to bring wireless connectivity to rural areas. See
  5. Software-defined radio: Another piece of the puzzle of non-restricted communication is software-defined radio. This was originally developed for the US Army, but there is now an open-source version, called GNU Radio ( http://gnuradio.org/trac ). The idea is simple, in that all the processing normally done in hardware by an ordinary radio is instead done in software. It is quite possible to do this with modern CPUs, and this simple idea has enormous ramifications, as it is possible to reconfigure the device on the fly. For example, with radio/TV receivers and transmitters as software applications, one could build a frequency-hopping, encrypted, radio-based network that is practically undetectable, which is what the military was originally after.

    A comprehensive hardware setup for this, covering a wide range of radio frequencies, would cost $1000, though there are also cheaper, if more limited, alternatives. We are trying to get someone to sponsor the purchase of such a device. If interested, please get in touch.

  6. Other embedded devices: We expect embedded devices to be an area of great interest in India over the next few years, and beyond. More and more, computing is going to move from general-purpose computers to devices designed for a specific application, and the innovation is going to come from putting together these pieces in interesting, new configurations.

    A couple of areas that we are looking at in embedded devices is robotics, and automated sensors for things like traffic monitoring, and control.