Tata Photon+ in Ubuntu 10.04

As of today, Tata Photon+ EC152 doesn’t work on Windows 7. And they don’t have any patch or upgrade too. It works perfectly on Windows XP.
I tried and got it working on Linux – Ubuntu ‘Lucid Lynx’ 10.04
Here are the few simple steps:
1. Install the following libraries:
i. usb-modeswitch-data
ii. usb-modeswitch
(To download these libraries u’d need a net connection :D)

2. Open /etc/usb_modeswitch.d/12d1:1446 as root and change this line:

TargetProductList = “1001,1406,140c,14ac” to
TargetProductList = “1001,1406,140c,14ac,140b”

2.Right click on Network connections icon on Top right corner and select “Edit connections”(or goto System> Preferences> Network Connections)
3. Goto “Mobile Broadband” tab,
In the IPv4 settings, select Method: “Automatic (PPP)”

4. In ‘Mobile Broadband’ tab, set the following:
Number: #777
Username: your Tata Photon+ number@photon.ttml.in
e.g. 9221475882@photon.ttml.in
password: internet

No change in PPP settings.
Apply.

5. There’ll be notification that “Tata Indicom (Photyon+)” connection established and your photon should start working.
Conn established

Happy Surfing!

Microcontroller programming in Linux

Are you using Windows Vista or 7 and want to work on your microcontroller??
Then you would have definitely faced 2 problems in:
1. Using your USB programmer to burn the code into the uC. The digitally signed driver issue.
2. Using a USB to Serial converter to test serial communication.

I was fed up of trying different things and so i thought of giving a try to Linux.
I am working on AVRs on Ubuntu 10.10 now.

For dumping the code: On Linux, I just had to install the following packages:
libusb0 – library to using USB for programming
avrdude – the programmer.
thats it.
Run the normal avrdude commands & done! (run as Superuser or root ($sudo avrdude … )).

For serial communication: I installed “Cutecom“, a GUI based serial terminal (like hyperterminal of windows XP). Run it from the console ($ cutecom). It shows 4 serial devices namely “/dev/ttyS0” to “/dev/ttyS3”. For using USB to Serial cable, manually type in the device name as “/dev/ttyUSB0”. Thats it! you can now test all your serial communication.

For writing and compiling the code there is “avr-gcc“. Or if you are familiar with CodevisionAVR on windows, you can install the same using “wine”… but remember to configure “wine” for windows XP before installing.

Note: I tried to program using Linux on VMware on windows 7… but it was not working.

Task Manager in Linux

Everyone is familiar with the task manager in Windows.
There is a similar option in Linux too.
It is known as “System Monitor” is present under “System> Administration> System Monitor”. It lists out many details u would like to know about any running process.

Another way is the “ps” command, stands for Process Status. It basically reports a snapshot of the current processes. It is much more powerful, customizable and useful(if you know how to use it). To execute it just type out:

$ ps

Now there are many more options ie. the processes u want to display(or “Select” as it is called in linux) possible with this. I have listed out some important & useful options and information.

SIMPLE PROCESS SELECTION
-A, -e Select all processes. Identical to -e.
-N Negates the selection. Identical to –deselect.
T Select all processes associated with this terminal. Identical to the t option without any argument.
-a Select all processes except session leaders and processes not associated with a terminal.
a List all processes with a terminal (tty), list all processes when used together with the x option.
r Restrict the selection to only running processes.
x List all processes owned by you (same EUID as ps).
–deselect Select all processes except those that fulfill the specified conditions. (negates the selection) Identical to -N.

PROCESS SELECTION BY LIST
These options accept a single argument in the form of a blank-separated or comma-separated list. They can be used multiple times.
For example: ps -p “1 2” -p 3,4

-C cmdlist Select by command name.
-G grplist Select by real group ID (RGID) or name.
U userlist Select by effective user ID (EUID) or name.
-U userlist Select by real user ID (RUID) or name.
p pidlist Select by process ID. Identical to -p and –pid.
-p pidlist Select by PID.
This selects the processes whose process ID numbers appear in pidlist. Identical to p and –pid.
-u userlist Select by effective user ID (EUID) or name. Identical to U and –user.

OUTPUT FORMAT CONTROL
These options are used to choose the information displayed by ps. The output may differ by personality.

-F extra full format. See the -f option, which -F implies.
-O format is like -o, but preloaded with some default columns. Identical to -o pid,format,state,tname,time,command or
-o pid,format,tname,time,cmd, see -o below.
O format is preloaded o (overloaded).
The BSD O option can act like -O (user-defined output format with some common fields predefined) or can be used to specify sort order. To ensure that the desired behavior is obtained (sorting or formatting), specify the option in some other way (e.g. with -O or –sort). When used as a formatting option, it is identical to -O, with the BSD personality.

THREAD DISPLAY
H Show threads as if they were processes
-L Show threads, possibly with LWP and NLWP columns
-T Show threads, possibly with SPID column
m Show threads after processes
-m Show threads after processes

PROCESS FLAGS
The sum of these values is displayed in the “F” column, which is provided by the flags output specifier.
1 forked but didn’t exec
4 used super-user privileges

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header “STAT” or “S”) will display to describe the state of a process.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct (“zombie”) process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group

More information can be obtained by using the usual "man" command for the linux manual.
$ man ps

Hope this information will be helpful esp. for System programming.

Unix Multiprocess Programming and IPC

Good material on
1. Unix Multi-Process Programming and Inter-Process Communications (IPC):
http://users.actcom.co.il/~choo/lupg/tutorials/multi-process/multi-process.html

2. Threads Programming(IEEE POSIX 1003.1c):
http://www.llnl.gov/computing/tutorials/pthreads/

Installing opencv in linux(Ubuntu) from .tar.gz file

I installed opencv for g++ in Ubuntu 9.04 (jaunty) through the following procedure.
Things to know before starting installation:
i. This installation needs a C++ compiler like “g++”(which is most commonly used). So install g++ first using Synaptic.
ii. Type out the following code to know the version of GTK+ installed on ur pc.

$ dpkg -l | grep libgtk

GTK is graphical user interface library. OpenCV requires GTK+ 2.0 or higher for displaying images.
This command should give o/p something like:

libgtk-directfb-2.0-0 2.16.1-0ubuntu2

If not, then u need to install the libraries for GTK+ 2.0 first, then start with this opencv installation.

If both g++ & GTK+ 2.0 are there then proceed as follows:
1. extract the opencv.tar.gz(right click> extract) into a folder, say “opencv”
2. copy that folder to /home
3. open terminal & cd to that folder
$ cd /home/opencv

4. type out:
./configure –prefix=/home/opencv –enable-apps –with-gnu-ld –with-x

If g++ is not installed, error may come as:
checking for C++ compiler default output file name… configure: error: C++ compiler cannot create executables
See `config.log’ for more details.

If you check this config.log, it says that g++ compiler not found. So you need to install it first.

5. Assuming all goes well, the configuration program will end with a prompt to ‘make’. Do that and then register the libraries (make install).

6. sudo make
Wait patiently, it’ll take time.
7. sudo make install
8. go to /home/ using
$ cd ~

9. Open .bashrc file using your favourite editor, eg:
$ gedit .bashrc

10. Append the following 2 lines to it:(before adding check whether these 2 paths respectively contain “lcxcore” & “opencv.pc”. If no, findout the path where these two files are & then modify the path accordingly)

export LD_LIBRARY_PATH=/home/opencv/lib
export PKG_CONFIG_PATH=/home/opencv/
and save & close .bashrc

11. Close the terminal & reopen(as this process requires relogin of the terminal)
12. Type the following command to check the location of opencv
pkg-config –cflags opencv

o/p:
-I/home/opencv/include/opencv

13. Type the following command to check the location of opencv lib files
pkg-config –libs opencv

o/p:
-L/home/opencv/lib -lcxcore -lcv -lhighgui -lcvaux -lml

14. To compile & build your code, cd into the folder where u have your program(*.cpp) & do:
$ g++ -I/home/opencv/include/opencv -L/home/opencv/lib -lcv -lcxcore -lcvaux -lhighgui -lm”

15. To run: $./a.out
or $./a.out

If things like the following appear-
recompile libraries using Windows,GTK+ or Carbon
Terminating blah blah..

Then goto synaptic Package Manager & install the library files for GTK+.
Then restart from step#3

16.Now lets simplify the above big command by making a shortcut for it:
go to your local home directory(cd /home/) and open the .bashrc file using gedit(the file will be hidden). Append the following to the file:

alias gcv=”g++ -I/home/opencv/include/opencv -L/home/opencv/lib -lcv -lcxcore -lcvaux -lhighgui -lm”

and save. Close the terminal and open it again.

17. Now onwards, to compile, build & run a program, u can simply do:
$ gcv filename.cpp
$ ./a.out img_name.extension

Enjoy!!!