Harikrishnan's Blog

November 7, 2010

Android Tab using Buttons

Filed under: Uncategorized — harikrishnanr @ 8:12 am

Here I want to explain how to simulate Android Tab using Buttons.

One of the obvious question is why we need it !. Sometimes User is using track ball on the tabs. I don’t want any action on moving the focus , but I need action when he/she click.

Download the source code from here and run it on the simulator.

September 12, 2010

Android adb devices : ??????????????? permission denied

Filed under: Uncategorized — harikrishnanr @ 7:53 pm

Adb tool is for managing Android devices or emulator.

$ adb devices // Will list the devices and emulator.

While I hit the command it shows my emulator, but the Motorola device is shown as ?????????????????? permission denied.

To solve this we should know the device vendor Id , use lsusb -v | grep [device name] to find it.

Create a file 51-android.rules which should contain a line

SUBSYSTEM==”usb”, SYSFS{idVendor}==”22b8“, MODE=”0666”

You should fill your device Id instead of 22b8. Done ! . Copy 51-android.rules to /etc/udev/rules.d.

Restart udev process :  /etc/init.d/udev restart

Restart adb server  : adb kill-server followed by adb start-server

Then you can see your devices by applying adb devices

July 1, 2010

CGI Script – malformed header from script

Filed under: Linux Tips — harikrishnanr @ 1:08 pm

It is very easy to add cgi-scripts in Apache. But most of the people (including ME)  stuck with the  problem Internal Server Error .You can see that error is because of BadHeader from one of log files (/etc/httpd/log) of Apache.

When writing the scripts we should add a blank line after the header. That’s ALL.
I wrote three CGI Scripts. copy it to “cgi” folder (read /etc/httpd/conf/httpd.conf to find the folder). And goto http://localhost/cgi-bin/hello.py . Make sure that python is installed in the system. You can download the source from here

June 25, 2010

Sharing Windows drives in Linux

Filed under: Linux Tips — harikrishnanr @ 5:51 pm

I like to talk about sharing Windows drives in a network . My aim is to access these drives in Linux.
I have fc11 on my laptop (192.168.1.3) connected to BSNL Modem and a windows machine (192.168.1.2) .
Make sure that firewall is off and share
the drives appropriately.
Requirements in Linux are smbclient and mount programs.
1) smbclient -L 192.168.1.2
//This will print the drives and their status of the windows machine .
2) mkdir /mnt/windows
3) mount -t cifs //192.168.1.2/F username=guest,password=asdfgh /mnt/windows
// Where F may be the shared drive of Windows, that can be verified from first step.

April 29, 2010

Google Summer of Code 2010

Filed under: Achievements — harikrishnanr @ 9:16 pm

I am selected in GSOC this year. My project is pydra. Pydra is a distributed and parallel computing framework for python.

My mentor is  Peter Kreneskyp. The proposal is based on FunctionTask. I sent one patch regarding a ticket, which was accepted. I selected this project because I am interested in Python.

Thanks to Pramode Sir for motivating and helping me.

February 13, 2010

Makefiles in Erlang

Filed under: Erlang — harikrishnanr @ 2:38 pm

Here i like to talk about compiling the Erlang modules using Makefile. Makefiles are used for integrating different modules to form a single one. These are very helpfull  in big projects.

I have two files in Erlang for computing double of a number. The main function is in main.erl and double function is in my_double.erl. The structure of the files are given below.

1 % main.erl
2 -module(main).
3 -export([start/0]).
4
5 % start function call double from my_double
6 start() ->
7         io:format(“Double ~w~n”,[my_double:double(2)]).
—————————————————————————————————

1 % my_double.erl
2
3 -module(my_double).
4 -export([double/1]).
5
6 double(N) ->
7         2 * N.

—————————————————————————————————

The Makefile is shown below

1 .SUFFIXES: .erl .beam
2
3 .erl.beam:
4         erlc -W $<
5
6 ERL = erl -noshell
7
8 MODS =  main my_double
9
10 all: compile
11         ${ERL} -pa $(shell pwd) -s main start -s init stop
12
13 compile: ${MODS:%=%.beam}
14
15 clean:
16         rm -rf *.beam erl_crash.dump
——————————————————————————————————-

Typical Makefile has the structure

Target:dependencies
actions

For producing the target ‘make’ look for existence of dependencies and then execute the actions. There should be a “tab space” before the action. In this example the modules are defined in the line 8 and actions are described in line 10. When we type make it start from the “all” target. We have to look carefully the line 11, here “main” is the module name and “start” is the function to execute at first. If you want  to pass  parameters to the function “start” then it should be specified after the function name.

For example the line 11 is changed as follows if you want 23 as parameter
${ERL} -pa $(shell pwd) -s main start 23 -s init stop
This is not included in this source
The source can be downloaded from here

January 30, 2010

Erlo-sapien at Foss 2009

Filed under: Projects — harikrishnanr @ 5:54 pm

I consider December 2 to 4 to be some of the most memorable days of my life. We presented the robot without any problems. The whole stuff looks like  a TANK.

Erlo-sapian

It got a lot of attraction. Many people are new to the Erlang language. Our motive was to popularize this functional language. We did not use the concurrency of this language. It was only a demonstration. The webcam functionality was not  implemented.

I attended many talks and workshops. All  the people were willing to express their ideas with a lot of explanation. I met many developers of KDE, and I am still in touch with them through IRC.

At the end of the last day, Dec 5, we lost our Erlang Robot from the stall. The whole work was lost. But the happiness of the exposure cured the sadness.

We are grateful to Pramode sir , who gave us these ideas, and to our  Computer Science Department and Electrical Department for  giving the facilities required.

Code for Erlo-sapien

Filed under: Projects — harikrishnanr @ 3:05 pm

Now I will explain the code for the robot. The name of the robot is ERLO-SAPIEN. Here Erlang code works as the server and C code as the client. The lower level parallel port functions are written in C. What Erlang does  is just call these functions. So Erlang starts the execution by  spawning two functions move and read_ir. Spawning is something “like” forking in C. The idea is that these two functions work in parallel. Two Erlang functions communicate to C functions through a Port.They can send messages to each other. Our simple model is the IR read function, which checks the status and gives orders to the move function according to the status. The move function moves the wheels and polls the read_ir  for status.The code is very simple, and the problem is in the sleep function. Any way the things worked fine. We also tried image detection in OpenCV. But the problem was that the image did not match, because of the light variation. The source code has been published in the git repository .

January 14, 2010

Sharing internet (PPP)

Filed under: Linux Tips — harikrishnanr @ 7:03 pm

Type the following commands in the System where internet is available
$ sysctl -w net.ipv4.ip_forward=1
$ iptables –table nat –append POSTROUTING –out-interface ppp0 -j MASQUERADE

Next command is issued in the client system
// Assigning gateway address
$ route add default gw [ip_of_system_having_net]
for example route add default gw 192.168.1.1

Airtel Mobile Office

Filed under: Linux Tips — harikrishnanr @ 6:55 pm

You should have a package “wvdial” which dials the modem
To install it
$apt-get install wvdial
Then you have to configure a file in /etc/wvdial.conf by
$wvdialconf  //this will detect your modem and its speed
edit the page  /etc/wvdial.conf
$vim  /etc/wvdial.conf

[Dialer Defaults]
Init = AT+CGDCONT=1,”IP”,”airtelgprs.com”,””,0,0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
Stupid Mode = yes
Phone = *99#
Password = a
Username = b

Save the file and do  $wvdial    // you can see some messages in the terminal
open another terminal and type  $ping google.com
and open a browser or type  $firefox google.com

This configuration is only for connecting Mobile through usb..
If you want to connect it through bluetooth some more work is to be done…

First of all, install the bluetooth package
$apt-get install bluez-gnome bluez-utils
then configure the bluetooth connection by
$hcitool scan         // you can see an ID and name of ur phone

Edit the file  /etc/bluetooth/rfcomm.conf as follows
#
# RFCOMM configuration file.
#

rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device 00:1D:3B:09:12:C3;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
comment “Dial-up Networking”;
}

then edit  /etc/wvdial.conf as
[Dialer bluetooth]
Init = AT+CGDCONT=1,”IP”,”airtelgprs.com”,””,0,0
Modem Type = Bluetooth Modem
Baud = 460800
New PPPD = yes
Modem = /dev/rfcomm0
Stupid Mode = yes
Phone = *99#
Password = a
Username = b

Save the file and type
$wvdial bluetooth
and  $firefox google.com    //from another terminal

The complete wvdial.conf file looks like this:

[Dialer Defaults]
Init = AT+CGDCONT=1,”IP”,”airtelgprs.com”,””,0,0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
Stupid Mode = yes
Phone = *99#
Password = a
Username = b

[Dialer bluetooth]
Init = AT+CGDCONT=1,”IP”,”airtelgprs.com”,””,0,0
Modem Type = Bluetooth Modem
Baud = 460800
New PPPD = yes
Modem = /dev/rfcomm0
Stupid Mode = yes
Phone = *99#
Password = a
Username = b

If you have usb type
$wvdial    //this will automatically dial the default part
If you have bluetooth type
$wvdial bluetooth

Next Page »

Blog at WordPress.com.