December 14, 2009

Reliance netconnect usage - GUI version

Follow up from previous post here.
At present, checking the bandwidth usage statistics for Reliance netconnect is clunky and laborious. In the previous post, I published a python script that I use to get the usage. To me, it seemed unnecessary to use a GUI for this. However, judging by the number of downloads, a lot of people have the need for this. And on windows, these people are not finding it as easy to install python and run the script from a terminal.
So responding to the demand, here is a GUI version. Remember to input the phone number with 0 (zero) as the first digit. The phone number and billing date are stored for subsequent uses. This was compiled and tested on windows XP.
For users with python and wxpython installed, you can download the script here and run it for the gui.
Any comments are welcome.

Credits:
Compiled with PyInstaller
Icons from here.

November 8, 2009

How I rooted my HTC phone and put in a new ROM

The HTC Magic brought to India by Airtel came with the "perfect" SPL. However, this was hacked sometime back making it possible (though with some difficulty) to root it. The discovery of the "one-click method" simplified this process significantly though. So after some agonising decision making, I decided to jump in and try to mod my phone. At the end of it all, it seemed almost too easy and the change, with the availability of the Android Market, is well worth it.

This is not a complete guide, just a documentation of some of the specifics as it relates to this phone. Standard disclaimer applies - this could possibly brick your phone, remember you take that risk if you plan to do this !

My phone information
SAPPHIRE PVT 32A SHIP S-ON H
HBOOT-1.33.0010 (SAPP10000)
CPLD-12
RADIO-3.22.20.17
Jun 2 2009, 17:28:28

Method I chose to root the phone
The on-click method, following this post.
I used FlashRec 1.1.3. I was unable to install with a file manager or by downloading from the phone, I used adb from android-sdk to install.

The alternative to this method would be the more difficult gold card method.

My new ROM
Amon Ra’s Clean Donut. No problems with the ROM so far.

October 28, 2009

Reliance netconnect - check your usage

Update December 14, 2009: Self contained exe for windows with a GUI - see here.

I have been using netconnect from reliance without any complaints for two months now. One problem, though, has been that the reliance website is fairly bad and it is not at all easy to verify your usage until you get the bill. When you log in and check your usage, what is shown is a huge table with the usage in kb for each session along with the session start time. So, if like me, you have a plan with a separate limit for nighttime, you have to download the csv file and then add up the usage yourself for sessions starting in the 'nighttime' and similarly for those starting in the 'daytime'. Seeing that many people have complained of being over-billed, it seems prudent to keep a tab on usage. While vnstat can give you the usage on any machine, it is less helpful when you use the account from multiple machines and also it does not seem to be easy to get usage for specified time limits.

So here is a small python script I wrote to get the usage information from the reliance website, calculate the split usage for daytime (6am-10pm) and nighttime (10pm-6am) and present the results in a human readable form. You can download the script here.

Here is the script in action -



Any comments and suggestions are welcome.

October 3, 2009

Reliance Netconnect on Ubuntu

Note: These are specific instructions for using ZTE-AC2726 modem on Ubuntu Jaunty.
If you are using a different modem, instructions may vary.

I got one of the newer modems with my wireless broadband connection from Reliance. It is a model that I had not come across in other blog posts, but I was encouraged by seeing 'Linux OS' mentioned among the system requirements.

Step 1: Open box and first look
The linux support is in the form of a driver on the cd that comes in the package. There is a deb package, but an attempt to install it fails because it seems to support kernels upto 2.6.27 only. The modem looks nice though!

Step 2: Plug in modem
On plugging in the modem, it gets mounted and shows up in nautilus like any storage drive. 'lsusb' confirms the bad news - the device is listed as 'Bus 007 Device 006: ID 19d2:fff5'. The modem is being recognised as a storage device only.

PS: In Ubuntu 9.10 (Karmic), the device is recognized as a modem directly and the steps 3 and 4 are not required.

Step 3: usb_modeswitch to the rescue
usb_modeswitch is an application written specifically for this purpose.



wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-1.0.5.tar.bz2
tar -xjvf usb_modeswitch-1.0.5.tar.bz2
cd usb_modeswitch-1.0.5
sudo make install


If there were no errors, you can add this snippet to /etc/usb_modeswitch.conf. I have broken MessageContent into 2 lines so that it can be shown in entirety. You should put everything on one line.



# ZTE AC2726
#
DefaultVendor= 0x19d2
DefaultProduct= 0xfff5

TargetVendor= 0x19d2
TargetProduct= 0xfff1

MessageContent="5553424312345678c00000008000069f03
0000000000000000000000000000"


Now run


sudo usb_modeswitch


You should see the success message and lsusb should show the product id is now fff1.

Step 4: Load the usbserial module


sudo mobdprobe usbserial vendor=0x19d2 product=0xfff1


Step 5: Connect using wvdial
If all has gone well, the modem should be recognised and ready to use.
'ls /dev/ttyUSB*' should show some USB devices


sudo apt-get install wvdial


You can run 'wvdialconf' to generate the initial configuration file and then edit it to enter your phone number and password.
This is my wvdial.conf


[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyUSB0
ISDN = 0
Phone = #777
Password = XXXXXXXXXX
Username = XXXXXXXXXX
PPPP Path = /usr/sbin/pppd
New PPPD = 1
Stupid Mode = 1
Tonline = 0


Now you are all set to


sudo wvdial


and get connected.

Notes:
1. I did the initial activation of the device from a windows pc. Not sure if it can be done with wvdial by using the phone number for that purpose.
2. Loading of the specific usbserial module can be automated by adding it to the kernel line in the boot menu. udev rules can be used for running usb_modeswitch on plugging in the modem - these are not covered here.

August 11, 2009

Making a smartphone out of the HTC magic

As mentioned in my last post, the HTC Magic marketed in India, as it comes out of the box is no smartphone. It is crippled in not having access to the android market. Which means you have to hunt for apps available outside the market to make your phone smart. These are the apps I have found in about a month of searching - what are yours ?

Android Scripting Environment
A fantastic application that gives you a scripting environment, currently for Lua or Python on your phone. This is an early python script written as a poor man's mapping solution. Obtain your coordinates from GPS, construct an url fit for consumption by google maps and open the browser.


SkyMap

A great way to see the night sky. Using GPS and position information from the phone, the objects in the night sky in your field of vision are displayed.


Connectbot
A secure shell client allowing you to get a local shell (connect to localhost) or connect to an ssh server on a pc. Second screenshot shows emacs running in an ssh session.




FBreader
A very good ebook reader.


Nav4all
In the absence of the google maps application, this is an option to use a map with a GPS. Quite comprehensive maps and a wealth of options. On the flip side, this is free only until 01-01-2010, you cannot use offline maps and the interface is a little messy.


AndNav
A truly free mapping system. You have a choice of renderers (including google maps) and you can store the maps offline by 'preloading' them.


And finally, installing the android SDK on the pc is helpful in various ways. I used adb a couple of times to install apk files when for some reason it wouldnt work when browsing from the phone. And also, of course, to get these screenshots.

July 17, 2009

Airtel's HTC magic in India - buyers beware !

So, I returned to India recently and looking to get a mobile phone, settled on what seemed to be the only android phone available in India - the HTC magic. Could not find any detailed reviews specific to Airtel's offering, but it did not appear as if the phone should be any different from that described in other reviews or on the HTC website.

So imagine my surprise when I cannot find the promised integrated google applications on the phone. The biggest disappointment is that there is no android market to get your apps and you have to settle for what is available at Leafs 'Openmarket' or Handango.

Turns out there are two versions of this phone - one is the google version which has all the goodies and a HTC version which instead has none of the google goodies and some additional software (most of which I am not interested in, and none of which compensates for the lack of access to android market).

Searching around on the internet, I find I am not the only one to have been surprised by this after buying the phone. I think the blame is on the seller for not making the distinction clear. SO I hope this post helps warn other potential buyers to be prepared for this when you buy the phone.

Apart from this, the phone feels great and the virtual keyboard works wonderfully. And for the geek side, ASE (Android Scripting Environment) could be installed and using connectbot I have a local shell and can use ssh ! At some point, I think I will be tempted to take the risk and attempt flashing a new ROM.

Edit - 08 Nov 2009 - I rooted the phone and put in a new ROM - freedom !

March 20, 2009

The command line tutor returns

I had stopped work on this long back, but found people still downloading it and discussing it once in a while. So here we go - a rewritten version can be got from its new home at google code. Any suggestions are welcome.

February 28, 2009

Ubuntu Jaunty Alpha 5 screenshots







The new notifications look good !

January 21, 2009

'Scroll animating' an image





Needing to create an animated image of an ECG scrolling, I wrote a bash script to create sequential frames from the image and then combine them into an animated gif, all using imagemagick.


#!/usr/bin/env bash

# Convert a rectangular image into an animated gif with
# sections from the image scrolling through

# Raja S
# Jan 2009
# GPL

nargs=$#
if [ $nargs -eq 0 ]
then
echo "Error - No arguments provided !"
echo ""
echo "animate converts rectangular image to a scrolling animated gif"
echo "Usage : "
echo " animate filename [width] [overlap] [delay] [loop]"
echo " width is width of final gif (pixels), default same as image height"
echo " overlap is overlap between successive 'frames', default is tenth of width"
echo " delay in time in hundredths of a second between frames, default is 20"
echo " loop is number of times to loop, default is 0 (loop infinitely"
exit
fi

# command line arguments - filename, width of gif (opt) and overlap (opt)
imagefile=$1
basefilename=${imagefile%.*}

# find image size using identify
imagesize=$(identify $imagefile | awk '{print $3}')
imagewidth=$(echo $imagesize | awk -Fx '{print $1}')
imageheight=$(echo $imagesize | awk -Fx '{print $2}')

# width of gif - default is image height
if [ $nargs -gt 1 ]
then
width=$2
else
width=$imageheight
fi

if [ $width -gt $imagewidth ]
then
echo "Error - Width of gif cannot be larger than width of input image !"
exit
fi

# overlap - default is tenth of width
if [ $nargs -gt 2 ]
then
overlap=$3
else
overlap=$(($width/10))
fi

# delay
if [ $nargs -gt 3 ]
then
delay=$4
else
delay=20
fi

# loop
if [ $nargs -gt 4 ]
then
loop=$5
else
loop=0
fi


# make the image frames
filecount=0
for i in $(seq 0 $overlap $(($imagewidth-$width)))
do
printf -v suffix '%06d' $((filecount++))
convertstring="$width""x""$imageheight""+""$i""+0"
filename="$basefilename""part""$suffix"".jpg"
convert -crop "$convertstring" "$imagefile" "$filename"
done

# combine into gif
convert -delay "$delay" -loop "$loop" "$basefilename""part*.jpg" "$basefilename""animation.gif"



If you want to try it out, you can download it here.
Example usage:


raja: ls /data/tmp/sample/
train.jpg

raja: ./animate.sh /data/tmp/sample/train.jpg

raja: rm /data/tmp/sample/trainpart*

raja: ls /data/tmp/sample/
trainanimation.gif train.jpg



Disclaimer: This is provided with all good intentions, but I cannot guarantee that it will cause not harm. Note that I do not delete the files to avoid inadvertent deletion of any important files. However, it is best to place the target image in a separate folder and then run the script.

January 3, 2009

Emacs - a beginner's setup


It's almost 5 months since I started using emacs on a regular basis. After beginning to use it as a platform to learn lisp (with SLIME), now I use emacs for coding python and bash, writing manuscripts (with markdown), doing statistics with R (using ESS), file and directory management and sometimes even to play chess on FICS.

Emacs, in my opinion is something anyone should give a whirl. It is open source, free and easily installable on any operating system. It is an absolutely amazing piece of software - give it a shot and if after a couple of months you decide to give up, atleast you have got a taste of what it is about. Here I will attempt to list a few things that will ease the introduction to emacs.

Note: Many of these instructions may be specific for Gnu-emacs on Linux. They may vary if you are using another emacs variant or another platform.

1. Start off with a good looking emacs

An oft-repeated complaint is that emacs looks bad, bad enough to deter a newcomer sometimes. But then, it doesn't have to ...

Use the latest emacs snapshot that allows use of your preferred fonts with nice antialiasing. In Ubuntu this means

sudo aptitude install emacs-snapshot-gtk emacs-goodies-el

Now you can use any font you prefer by modifying the Xresources file as detailed here.

2. Disable the splash screen, scrollbar and toolbar. Add to your .emacs -

(setq inhibit-startup-message t)
(tool-bar-mode -1)
(scroll-bar-mode -1)


It may seem surprising to consider disabling the scrollbar and toolbar. Maybe a case can be made for having these on while you wean yourself from the mouse, but I believe that there are greater dividends to doing this early and getting used to mouseless editing. I have preferred leaving the menu-bar on although I dont use the menu items, just because it sometimes allows me to easily refer to the shortcuts available, but again, it is worth considering disabling this too.

3. Syntax highlighting

Install color themes. In ubuntu, this is done easily by installing emacs-goodies-el. Now, add this in your emacs to have 'font-lock' on for syntax highlighting.

(global-font-lock-mode t)

After M-x, typing color-theme- and hitting tab will shows the completions available. Try out the different color-themes to decide what you want to use. To enable it automatically, add a line like this -

(require 'color-theme)
(setq color-theme-is-global t)
(color-theme-scintilla)


4. Enable line numbers

If you feel lost without them,

(require 'linum)
(global-linum-mode)

5. If you like to 'see' a selected region, you have to enable transient-mark-mode -

(setq-default transient-mark-mode t)

6. And if you have trouble copy-pasting between other windows and emacs, this worked for me -

(setq x-select-enable-clipboard t)

With these basic things out of the way, you have a decent emacs set up to start with. There are multiple options for further customization, but I will leave them for you to experiment with. Packages to definitely try out are ido-mode, pabbrev, bookmarks and yasnippet.

Loading image

Click anywhere to cancel

Image unavailable