Thursday, April 15, 2010

GPRS Internet on Ubuntu 9.10 using Nokia mobile phone

I have been trying to set up my laptop with a GPRS connection using my mobile phone - in this case a Nokia 5230 cell. I have found out that in Greece, telecom company named WIND offers in its F2G card a 3GB (!!) free internet connection and I wanted to experiment with it. In Windows (duh) one can use the Ovi Suite to connect to the internet. On linux, there is also a way by using wvdial and it took me a while to find out.

First of all, the connection is performed through a USB cable, so make sure you have one. (If you don't, like in my case, you can always search ebay for a cheap cable, I got mine for the 5230 for almost 4 euros included shipping charges!!!). Go ahead and connect the USB cable and select 'Nokia PC Suite' functionality from Nokia's pop up menu. Then open up a terminal and type:


and you ll get something like that:

Bus 001 Device 005: ID 0421:02e3 Nokia Mobile Phones
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The first line corresponding to your Nokia phone, has two numbers: 421 which is the vendor ID and 2e3 which is the product ID. These two numbers must be used in order to enable the serial connection through the usb cable from the connected phone. On that terminal type:

sudo modprobe usbserial vendor=0x421 product=0x2e3

In your case go ahead and replace the above numbers with the ones from your output.

Now, if you do not have wvdial installed, go ahead and install it (in debian-like linux distros):

sudo apt-get install wvdial

And now you are ready to start configuration for your modem. On the terminal type:

sudo wvdialconf create

The tool will try to identify the serial port the modem is connected and will make some tests in order to give you the final settings. Hopefully you will get a -not so small- list ending with something like this:

Found an USB modem on /dev/ttyACM0.
Modem configuration written to create.
ttyACM0: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

So, /dev/ttyACM0 is the device node that it is going to be used with speed 460800. Now, we will edit the options for dialing. Edit the following file with your favourite editor:

sudo vi /etc/wvdial.conf

 And enter the following:

[Dialer Defaults]
Modem = /dev/ttyACM0
BAUD = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=, ,""
Phone = *99***1#
Username = web
Password = web
New PPPD = yes
Stupid Mode = 1

Edit the above according to the setting that you received. Also, change the "" according to your cell settings.

Save it, close it and then in terminal type:

sudo wvdial

And if you get the following:

--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Thu Apr 15 15:27:00 2010
--> Pid of pppd: 2975
--> Using interface ppp0
--> pppd: `(Q �1Q �(Q
--> pppd: `(Q �1Q �(Q
--> pppd: `(Q �1Q �(Q
--> pppd: `(Q �1Q �(Q
--> local  IP address
--> pppd: `(Q �1Q �(Q
--> remote IP address
--> pppd: `(Q �1Q �(Q
--> primary   DNS address
--> pppd: `(Q �1Q �(Q
--> secondary DNS address
--> pppd: `(Q �1Q �(Q

You are done!!! You have internet from your mobile and you can go ahead and start using the internet!


The  above solution can be achieved through a bluetooth connection. First of all, you need to have bluetooth utilities installed on your machine. So make sure to install them.

After installing them, open up a terminal and type:

hcitool scan

This will identify all bluetooth devices that are in range. When your device shows up, use its MAC address to identify the channel for the rfcomm property (needed to access the modem):

sdptool search DUN

This will give you a list for the properties of your phone:

Inquiring ...
Searching for DUN on [mac address] ...
Service Name: Dial-Up Networking
Service RecHandle: 0x1001a
Service Class ID List:
  "Dialup Networking" (0x1103)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 22
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100

Note the MAC and the channel number so that you may use it. Now we should create the rfcomm0 node so that it can be accessed:

sudo rfcomm bind 0 [mac address] [channel]

The device node has been created and now you can use it for dialup. Last step before dialing, you should change the modem property on wvdial.conf to:

modem = /dev/rfcomm0

And you are done!

Sources:  [1], [2], [3]

Saturday, January 23, 2010

Speaker sound on LG P1 Express

Three years ago I bought an LG P1 Express laptop, which seemed a decent choice back then. I should confess that still is but I got really disappointed with the ATI cards and the support they have in linux. Anyway, I have been always having trouble with the sound from my system. I was never able to hear sound from the speakers of my laptop, and it was kind of irritating. I have been trying for along period of time (and I mean a lot!) to find a workaround or some solution to it. At first I thought it had to do with the kernel. There were other users out there that were using the same laptop but there was a difference. The audio chipset was different: the ones that were working were using the ALC882 chipset from Realtek and mine was ALC883. In earlier kernels and distros, my soundcard was not even recognized. At later kernel versions, and specifically after the 2.6.29 tree family, my card was recognized but the speakers did not work. I had to connect headphones to hear sound and being a linux user (and developer) I was getting irritated. It was not an ALSA issue neither and I have tried every single solution proposed in the internet. One day, I installed Ubuntu 9.10, and I performed a system test. As expected, the sound from the speakers did not work and I filed a report to the analysing the problem. After a couple of months, I found another user (!!!) that had the same problem with me. We both had the ALC883 chipset, and therefore no sound from speakers. We provided a lot of information to the launchpad and to the Ubuntu developers hoping to find a solution. But! BUT one day the other user came up with a solution! Yes a solution! The solution is simple, but we have never came up with:  just open /etc/modprobe.d/alsa-base.conf and append the line:

options snd-hda-intel model=laptop-eapd

Reboot and Voila! Sound comes out from speakers and I can also you Skype for my phone calls! It's been sooo long! But (I hate it when there's always a 'but') the problem now is that even with headphones plugged-in, sounds comes out from speakers! Well, what can we say? One step at a time!

Torrent server with Sheevaplug

One day I was browsing the internet and I was looking one of my favourite sites Distrowatch where I check out news for upcoming linux distros. That day I came across this article which talked about the Sheevaplug, a new type of computer introduced in a field called, plug computing. To cut the long story short, after reading the whole article it seemed a really good idea getting one these little 'toys' due its low power consumption (almost 8W with an external USB HDD attached)! I was also fascinated by this product of being so small and running linux.

I placed my order from Globalscale Technologies for only 70 euros plus 30 euros shipping. I could have ordered it from the UK but the company that was distributing them was short of components at that period of time.

Unboxing the plug

SheevaPlug is a small computer which consists of:
  • 1 GHz ARM processor
  • 512 MB of RAM 
  • 512 MB of Flash memory
  • Gigabit Ethernet 
  • USB host connector & small USB for serial connection
  • an SD card slot
It comes with Ubuntu 9.04 Jaunty pre-installed in the Flash Memory and uses U-Boot to boot the device. Also, it contains a CD with several documentation pdfs and of course the necessary packages for recovery (yes yes, I messed up once!).

The first thing that I had to do was to connect the mini-USB in order to get the serial console up and running. I was using Ubuntu so I installed gtkterm which I think is more usable than minicom that some sites where suggesting. Once you get gtkterm, you instruct it to look for the /dev/ttyUSB0 or /dev/ttyUSB1 devices.

Getting inside the serial console, you will see the U-Boot prompt. There is always an option to stop the automatic boot and enter appropriate information in order to boot from the device of your choice. I have done some research beforehand and I have read that there are various ports to the SheevaPlug & the ARM arch, so one can choose according to his/her preferences. As far as I remember, there were Gentoo, Slackware, Debian, Ubuntu (only v9.04, v9.10 supports ARMv6+VFP instructions, not ARMv5  arch, which I believe is a major drawback), Fedora and FreeBSD ports available to choose from and all of them have guides that can be found online. I chose to go with Debian simply enough because it seemed it had less drawbacks in contrast to other ports. For example, in the FreeBSD port the hardware support was limited to the serial console, gigabit ethernet  and the USB port.

There are many ways [1], [2] to install Debian on Sheevaplug, but I prefered to go the hard way which uses manual bootstrapping and it was used in the Distrowatch Weekly article. It seemed a really good idea to start from scratch and watch the whole procedure step by step.

So, I bought an external USB HDD (an Apacher 320GB) which is good and in a decent price. I created 3 partitions: 1 for root, 1 for /home (depends on every user) and 1 swap. NOTE: The root partition MUST be formatted as an EXT2 filesystem or else the U-Boot will not recognize it and it will not be able to boot. For the second partition, I used XFS because I wanted to use it primarily as a download server. After googling a little bit, I came up with this article that was comparing a few filesystems. XFS seemed to fit me better due to its lowest CPU usage, HDD capacity and quick operation handling on large files.

Once I had my disk set up, I started with the installation described in the above link. I chose a Debian mirror which was close to me, so that I may have the maximum speed possible and I followed each step of the installation guide.  You will have to have some sort of access to a debian system, to perform the bootstrapping procedure. I will not post  it here but I will give some insides I did in order to finish the installation. First of all, when editing the options throughout the guide, be sure to adjust it to you needs. For example, set your hostname in line:

echo > etc/hostname

into whatever you want. Also, you can edit the etc/network/interfaces beforehand so that when you login, you can have an internet connection. For my network the setup was:

auto eth0
iface eth0 inet static

Although etc/fstab could be edited now, I saved it for later when I could log into the system. Everything up to editing the etc/inittab file went smoothly. Don't forget to disable the tty[1-6] when editing the /etc/inittab because they do not exist (I did not notice the comment on the guide!). The tricky part was before executing the command:

exec /sbin/init

 For some reason, no login prompt appeared and re-spawning was not taking place. After googling a little bit I found out that the /dev/ttyS0 node needed for the serial console did not exist so I had to create it (after several reboots) by hand BEFORE the execution of init command. So according to this source I entered in the cmd prompt:

mknod -m 660 /dev/ttyS0 c 4 64

and then:

exec /sbin/init

and Voila! the login prompt appeared! Provided that I had already changed the root password, I was able to login and continue with the installation. The last part where the configuration of U-Boot was taking place, I took extra care because messing up or misspelling something could end up catastrophic (meaning starting over).

Once I had my system rebooted, I logged in as root and installed a dozen of packages such as: SSH, Python, iptables, rsync, samba, nfs, portmap, apache, postgresql, php, perl, transmission-daemon, ntp, transmission-cli, cron and some other I cannot recall right now. Also, I updated /etc/fstab with the second partition information, where my downloads will be stored. Don't forget to set the appropriate permissions, or else you will be getting in to trouble and to perform a swapon /dev/sda[NUMBER] to the swap partition to activate it. Also, I created a normal user so that all operations would be carried away be him and not by root. Since I wanted this server to act as a torrent download server, I followed the procedures described in the previous entries of my blog. In addition, I have set up the download  directory (mounted inside my home in my user account) to be shared with Samba (for Windows - yes, I use them once in a while) and NFS (for my Linux PCs).

My complete sheevaplug-based torrent download server

One last thing I had to do was to set the time and date appropriately, and disconnect the USB for the serial connection. Once setup, the device can be controlled through SSH. There are some guides on the internet where one can setup a IceWM graphical environment, but for me the pure and plain headless server with only terminal works better!

In conclusion, experimenting with such a component was extremely interesting and I had a lot of fun doing so, although in the beginning I messed up a little bit and I had to do some system recovery. It is a great component which of course consumes really really low power and it is intended to stay on 24/7 without producing any noise (from fans and stuff). As a future work, I am considering attaching a USB hub / bridge where I will attach one USB camera and install zoneminder for security surveillance.

Monday, January 18, 2010

Torrent download with Transmission & RSSdler & Bash

I wanted to find a torrent client that is lightweight and accessible from anywhere. Especially one that would have some kind of RSS link download, in order to download torrents for the TV Shows which come out every week. I have been using KTorrent which has a pretty nice interface and offers a lot of plugins. But it needs a lot of KDE libs and generally is not as lieghtweight as I would like to. So, I decided to use rssdler, Transmission-daemon and some bash-scripting (after googling a little bit  :-]  ).

So, I have come across this nice utility (so far...) which can run like a daemon in the background and it is used to download files from an RSS feed. It can be run in any platform (daemon only in Linux) because it's written in Python. You can download the main package at Before installing it you will have to install some other prerequisites:

1. Make sure Python v2.4+ is installed
2. Since this tutorial is based on ubuntu, you can install the feedparser & mechanize by using aptitude (or apt-get)

sudo aptitude install python-feedparser python-mechanize

After these prerequisites are installed, you cd to the downloaded tarball of rssdelXYZ.tar.gz, untar it and execute:

sudo python install

So, now you rssdler installed. Go ahead and make the default dir in your home dir:

cdmkdir .rssdler
cd !$
touch config.txt

The above is the default rssdler dir where the rsslder program will look for a config fule. The contents of this file should look like this . It is a very basic configuration and you can play with it around so that you can adjust it to your needs. Trial and error would be the best option to achieve what expected.

When done adjusting the conf file, just open a terminal and type:

    rssdler -r         # just run the rssdler
    rssdler -d        # run in daemon mode, in background
    rssdler -k        # kill the instance

That's it!

Now, off to transmission-daemon. I like transmission because it has a nice web-UI. Installing transmission-daemon in Debian-like systems is easy. Also, in order to access the daemon, transmission-remote needs to be installed. Open up a terminal and enter:

sudo aptitude install transmission-daemon transmission-remote

When the install completes, you can edit the configuration file at /home/user/.config/transmission-daemon/settings.json. I have found out that a daemon is also installed in /etc/init.d but personally I want to start it and stop it whenever I want, and also I want to edit the settings as a user in my home dir. So, it's up to you.

When editing the settings.json be sure to enter correctly the path for the downloaded files. HINT: I must note that the path where the torrents should be downloaded MUST NOT BE a symbolic link or else the torrents will not start downloading and will remain idle. Also, you should enable the web interface and disable the authentication method. Be sure to enter in the rpc-whitelist the address or range of addresses of your computer's IP so that it will allow other connections, besides localhost. To check that everything is ok, open your favorite browser and type: http://localhost:9091 .

With transmission-daemon being a background process, it lacks features like monitoring a folder for automatic addition of the torrents and bandwith scheduling. This can be done using some Bash scripting. In order to automatically add torrents from a specified folder open up a text editor and add the following:

for file in /path/to/torrents/*.torrent

if [ "$file" != "/path/to/torrents/*.torrent" ]; then
echo [`date`] "$file" added to queue. >> //path/to/script/added.log
/usr/bin/transmission-remote -a "$file"
rm "$file"
sleep 1

exit 0

Save it somewhere in your home folder and then open up crontab and add:

* * * * * sh /path/to/script/

This will fire every minute and add the torrent to the daemon.

The scheduling part can also be done through cron using the transmission-remote command. For example, if I would like to restrict the maximum upload of all torrents in e.g. 10:00 and remove this restriction at 23.00:

00 10 * * * transmission-remote -u 40 1> /dev/null
00 23 * * * transmission-remote -U 1> /dev/null

where the '-u ' is the limit in KBytes and th '-U' implies no restriction.

So scheduling can be achieved through transmission-remote and cron. It is usefull to play around with the transmission-remote command and discover it's true potential.

Last, but no least, in order to view the status from the command line, open a terminal and enter:

transmission-remote -l

Or in order to have it running (in case you do not prefer the browser solution):

watch transmission-remote -l

So, that's all. Happy torrent-ing!

Tuesday, January 5, 2010

Zoneminder with Logitech Quickcam Easy/Cool (E1000) on Ubuntu 9.10

I have been trying to setup zoneminder on ubuntu 9.10 with my Logitech Quickcam Easy/Cool and I have been bumping into problems that I could not figure out. Recently, I run across into a work around which it worked for me and I will outline here the complete steps that I followed.

Zoneminder is a video camera security and surveillance solution designed for Linux. It supports single or multi-camera video security applications with various features such as theft prevention and child, family member or home monitoring, nanny cam installations etc. It supports capture, analysis, recording, and monitoring of video data coming from one or more video or network cameras attached to a Linux system. If you are not familiar with zoneminder, take some time and visit the website .

First of all, we update the system, making sure that it is up-to-date:

sudo apt-get update
sudo apt-get upgrade 

Apache, php, MySQL and some other packages and its dependencies are required for ZM, so we install them: 

sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server ffmpeg libarchive-tar-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libjpeg62 libmime-perl libstdc++6 libwww-perl zlib1g zoneminder

when the installation finishes, we can access the ZM console at http://localhost/zm or we can replace localhost with our system's ip.

I was not able to get the Quickcam to work locally with ZM, so I have found a workaround which uses the stream from another service. I used the uvc_stream to do so. First of all, download the source: 

svn co .


cd path-to-uvc_streamer
sudo cp uvc_stream /usr/local/bin

Now you can start the stream by typing:

/usr/local/bin/uvc_stream -f 60 -r 320x240 -d /dev/video0 -p 8082

You can change -f option to a number of frames per second you want (depends on the memory of your system - too many frames may consume system's resources). Also, change -d to your device and -p to whichever port you want. If you would like to start this a service you may append the -b (background) to the above command.

Now you can test your video stream at: http://localhost:8082.

Now that you have your stream, open the Zoneminder console at http://localhost/zm and add a new monitor. On the General tab, give a Name to your camera, and choose Remote type. On the function you may choose depending on your needs: I chose Modect to apply also Motion Detecting. Also, depending on the frames that you have defined in the uvc_stream, you might have to put that value in the Maximum FPS field.

On the Source tab, leave Remote Protocol as HTTP, and enter in Remote Host Name either localhost (if the camera is attached in the same computer) or the IP of the machine that 's used for streaming. Enter in the port the number that you entered in the uvc_stream and on the Remote Host Path field enter the word snapshot . Finally, set Colours to 24, Width to 320 and Capture to 240. Then, go ahead and click Save.

That's it! Now you have one camera setup for surveillance. By clicking on the name of the camera you can see the live streaming.