Archive for February, 2007

Rip / record online radio stream

Written on February 27th, 2007 by
Categories: Information Insemination

I enjoy listening to music while doing my work, but doing it with online radio is not really enjoyable as during daytime, it’s hard to listen to 128 kbps stream without buffering issue, thanks to TMNut’s Streamyx. Even if (at times) it’s ok, the bandwidth is better saved for other meaningful purposes. What I did was to create a script to dump the broadcast, run it by midnight (the time when the highways is clear for Streamyx) and stop it in the early morning. Let cron help you with this and it should make your life even easier.

In my example, I’m using 1.FM’s Channel X, and a lot more is available from www.shoutcast.com‘s playlists.
(Script updated on 20070301)

#!/bin/bash
URL=http://64.62.252.130:8070
WORKDIR=/home/shakir/temp/mplayerdump
MAXDUMP=3
CURRENTDUMP=`ls $WORKDIR | wc -l`

mv $WORKDIR/current.mp3 $WORKDIR/`date +%F`.mp3
if [ $CURRENTDUMP -ge $MAXDUMP ] ; then
   for i in `ls $WORKDIR | head -n $[($CURRENTDUMP-$MAXDUMP)+1]`; do
      rm $WORKDIR/$i
   done
fi 

mplayer -dumpstream  $URL -dumpfile $WORKDIR/current.mp3
#ffmpeg -i $URL -ab 128 $WORKDIR/current.mp3

Huawei E600 Data Card (Celcom 3G) in Linux

Written on February 16th, 2007 by
Categories: Information Insemination

I’m on my way to my hometown now for this 4 days CNY break, and thanks to this Huawei E600 UMTS data card, I’m able to post this blog entry while having some light meal on the roadside. I’m a registered Celcom 3G unlimited plan, and  with it I can enjoy 3G connection with my laptop wherever possible, with GPRS as fallback if 3G is not available in the area.

Setting up the data card is supposed to be a very easy task in Linux, but before I get to know the right way to actually get it to work, I screw up the data card for few times that I need to send it for warranty to have the firmware flashed after following some online guides. It was not a pleasant journey, and I hope with this post others wouldn’t need to go through the path that I’ve been to.

The first thing to do is to make sure you have PCMCIA support in the kernel.

Bus options (PCI, PCMCIA, EISA, MCA, ISA) —>
    PCCARD (PCMCIA/CardBus) support —>
         PCCard (PCMCIA/CardBus) support
         CardBus yenta-compatible bridge support

and you also need the driver for your data card

Device Drivers —>
    USB support —>
         OHCI HCD support
        USB Serial Converter support —>
             USB Serial Converter support
            [*] USB Generic Serial Driver
             USB driver for GSM and CDMA modems 

and support for PPP connection

Device Drivers —>
    Network device support —>
         PPP (point-to-point protocol) support
         PPP support for async serial ports

That’s all needed in the kernel, and now it’s time to install the required software. As I’m using comgt and kppp, the rest of the post will be specific to these 2 applications, though there are other methods in establishing the connection.

Let’s first install comgt:

wget http://optusnet.dl.sourceforge.net/sourceforge/comgt/comgt.0.32.tgz
tar xvzf comgt.0.32.tgz
cd comgt.0.32
make
sudo make install

kppp is a KDE application to handle ppp connections and your distro might already have it installed in your system. Here’s the configuration file used to establish the connection (copied from the net, but some parts of it are not important as comgt will fetch the pre-set settings from the data card itself, in our case specific to Celcom):

root@herugrim ~ # cat .kde/share/config/kppprc
[Account0]
AccountingEnabled=0
AccountingFile=
Authentication=3
AutoDNS=1
AutoName=0
BeforeConnect=xterm -e /usr/local/bin/comgt -x -d /dev/ttyUSB2
BeforeDisconnect=
CallbackPhone=
CallbackType=0
Command=
DNS=
DefaultRoute=1
DisconnectCommand=
Domain=
ExDNSDisabled=0
Gateway=0.0.0.0
IPAddr=0.0.0.0
Name=Celcom3G
Password=1234
Phonenumber=*99***1#
ScriptArguments=
ScriptCommands=
StorePassword=1
SubnetMask=0.0.0.0
Username=user
VolumeAccountingEnabled=0
pppdArguments=defaultroute,crtscts,modem,noipdefault,usepeerdns,novj,debug

[Account1]
pppdArguments=

[General]
AutomaticRedial=0
DefaultAccount=Celcom3G
DefaultModem=HUAWEI
DisconnectOnXServerExit=1
DockIntoPanel=1
NumberOfAccounts=2
NumberOfModems=3
PPPDebug=0
QuitOnDisconnect=0
RedialOnNoCarrier=0
ShowLogWindow=1

[Graph]
Background=255,255,255
Enabled=true
InBytes=0,0,255
OutBytes=255,0,0
Text=0,0,0

[Modem0]
AnswerResponse=CONNECT
AnswerString=ATA
BusyResponse=BUSY
BusyWait=0
ConnectResponse=CONNECT
DLPResponse=DIGITAL LINE DETECTED
Device=/dev/ttyUSB0
DialString=ATD
Enter=CR
EscapeGuardTime=50
EscapeResponse=OK
EscapeString=+++
FlowControl=Hardware [CRTSCTS]
HangUpResponse=OK
HangupString=+++ATH
InitDelay=50
InitResponse=OK
InitString=AT+CFUN=1
InitString1=AT+CGDCONT=1,"IP","gprsinternet","",0,0
Name=HUAWEI
NoCarrierResponse=NO CARRIER
NoDialToneDetection=ATX3
NoDialToneResp=NO DIALTONE
PreInitDelay=50
RingResponse=RING
Speed=460800
Timeout=82
ToneDuration=70
UseLockFile=1
Volume=0
VolumeHigh=M1L3
VolumeMedium=M1L1
VolumeOff=M0L0
WaitForDialTone=1

[WindowPosition]
WindowPositionConWinX=487
WindowPositionConWinY=498
WindowPositionStatWinX=815
WindowPositionStatWinY=485


That’s all the preparations needed, and you should be able to connect to Celcom 3G. Here’s a screenshot of my connection.

Script for scanning for available wireless network

Written on February 12th, 2007 by
Categories: Information Insemination

My current job deals with deploying wireless network (WiFi), and part of my job routine is to scan and get some details of the available access points (APs) in the area. This simple script is useful if one can’t get Kismet running, and also as in my case, when Kismet is considered an overkill for this simple task.

As my laptop is using Atheros wireless chipset, the kernel module to reload would be different if you’re using different chipset, and wlanconfig is an Atheros specific program and is available in madwifi-utils package (madwifi-ng-tools in Gentoo).

#!/bin/bash

echo "### Initializing driver.."
sudo modprobe -r ath_pci
sudo modprobe -r wlan_scan_sta
sudo modprobe ath_pci
sudo ifconfig ath0 down
sudo ifconfig ath0 up
echo "### Sleeping for 3 seconds before scanning.."
sleep 3
watch -n 1 "
        sudo wlanconfig ath0 list ap
        echo
        echo
        sudo iwlist ath0 scan
"

While iwlist gives more details on the scan result, wlanconfig‘s output is more brief and is more suitable if there are many wireless access points around (that it wouldn’t just fill up the screen). Combining these two, we get the best of both :)

I’ve been using sudo a lot in my scripts, and if you’re wondering won’t sudo be asking for passwords, well, by having this in my /etc/sudoers, the problem is solved;

shakir  ALL=(ALL)      NOPASSWD: ALL

Inspiron 6000 slow CD / DVD burning speed – solved

Written on February 5th, 2007 by
Categories: Information Insemination

CD / DVD burning was quite a nightmare for me and my Gentoo on Inspiron 6000, since CD burning won’t go faster than 10x speed, choking the CPU at 100% utilisation, and very prune to buffer underrun, even if I just leave my favorite burning software doing it’s work without disturbance. When it comes to DVD, hmm, not a single disc was successfully burned.. :(

During my stressful second attempt to make up with Ubuntu (our relationship didn’t work out anyway, I’m back with my Gentoo now) in the past 2 weeks, I didn’t get such problems with my burner. It made me wonder and found out that my burner was detected as scd0 while with my Gentoo it was hdc.

With that I came to realize that my burner is SATA based, and so enabling a SCSI CDROM support in the kernel (and disabling ATA/ATAPI support) should fix my problem.

Device Drivers  --->
    ATA/ATAPI/MFM/RLL support --->
        < > ATA/ATAPI/MFM/RLL support
    SCSI device support  --->
        <*> SCSI CDROM support

With the new kernel, udev assigned sr0 to the device (it’s ok not to be assigned sdc0), and CD / DVD burning is no longer a nightmare for me..

shakir@herugrim ~ $ ls -l /dev/ | grep sr0
lrwxrwxrwx 1 root  root           3 Feb  5 09:50 cdrom -> sr0
lrwxrwxrwx 1 root  root           3 Feb  5 09:50 cdrw -> sr0
lrwxrwxrwx 1 root  root           3 Feb 5 09:50 dvd -> sr0
lrwxrwxrwx 1 root  root           3 Feb  5 09:50 dvdrw -> sr0
brw-rw---- 1 root  cdrom  11,   0 Feb 5 09:50 sr0

Let’s burn, baby, burn.. :D