Monday, April 30, 2012

My cycle journeys.. 1st May

Today i traveled about 6km  only to pangode military base. It was the first time i was seeing a military camp base. I was filled with patriotism on the sight of it and felt proud about our armed forces of our country.

Jai Jawan.
Bharat Matha Ki jai





View Larger Map

Thursday, April 26, 2012

Wednesday, April 25, 2012

Cycle journeys in Trivandrum..

Being a techie results in lack of exercise manly due to sitting in front of the PC from morning to evening. Now this can cause problems later in life so i decided to cycle through my way in Thiruvananthapuram.
Cycling is one of the exercises which i like and for that i bought my cycle to Thiruvananthapuram from Kochi on train. i had started cycling from last week and thought it would be great if i could share some of the routes i cycled.

Thiruvananthapuram terrain is a difficult terrain to cycle for starters as  it is hilly in some parts and requires building up stamina by taking it slow.
This the route i did today


View Larger Map

Tuesday, April 24, 2012

CVS integration into eclipse for easy team sharing

Sharing of source code and version controlling is an important process to ensure that code is effectively shared and updated correctly. So if you have a CVS server setup in your machine then you are good to go.

Configuring Eclipse:-


  1. Open the CVS Repositories view.
  2. Click on add CVS Repositories button on the top left of the view
  3. Put the settings according to cvs settings of the server
  4. Now Take the project Explorer window and take the team option > share project
  5. Use the cvs option
  6. Then select the server you had configured earlier
  7.  Now in the project explorer the project folder will be succeeded by the ip of the cvs server. Also their will be full cvs options in the team sub menu when we right click on the folder\
Note:- If the option 6 is not shown for project, then delete the project from project explorer without deleting the files physically and re-import the project back into the workspace.

For Reference use the following site 

Monday, April 23, 2012

Automatic Documentation generation using eclipse and doxygen plugin - Eclox

Documentation is a process which most programmers feel lazy about doing but is quite important for future reference and also for people to contribute to the project. Doxygen is a tool for writing software reference documentation. The documentation is written within code, and is thus relatively easy to keep up to date. Doxygen can cross reference documentation and code, so that the reader of a document can easily refer to the actual code.

Eclipse is a favourite IDE for many programmers and Doxygen integraion can easily be done with   the existing setup:-

Installation steps:-
  1. Download and install Doxygen executable from the official site depending on OS and PC architecture.
  2. Eclox Installation :-
    1. INSTALLATION
      There are two options to install the plugin: using the update site or using the packaged feature.
      The update site is the more convenient way to install eclox. It is located athttp://download.gna.org/eclox/update. See eclipse's user guilde for additionnal details.
      When using the packaged feature, you must extract the archive content into your eclipse's root location. For additionnal details, please refer to eclipse's user guide.
    2. CONFIGURATION

      Once the plugin installed, you must ensure that the default PATH environment variable makes the doxygen binary reachable for the plugin. If not, you can update PATH to include to directory containing the Doxygen binary, or you can tell Eclox where that binary is located on your system (which is in my opinion the better solution). To do this, open eclipse's preference edition dialog window and go into the new "Doxygen" section.
    3. USAGE

      You can create new Doxygen projects (also called doxyfiles) using the creation wizard. Go to "File->New->Other->Other->Doxygen Configuration". Press next and set both file location and name. Then a empty doxyfile will be created at the specified location, the wizard automatically adds the ".Doxyfile" extension.
      You should now see a file with a blue @-sign icon. This is your new doxyfile. Double-clicking on it will open the editor. You can now browse and edit the settings.
      Once your have properly set all doxyfile fields, you can launch a documentation build using the toolbar icon showing a blue @-sign. In the case the button is not visible in the toolbar, your current perspective needs to get configured. Go to "Window->Customize perspective->Commands" and in "Available command groups" check "Doxygen". Additionnaly, you can browse the laetest builds by clicking the down arrow right to the toolbar button.

      When the documentation build starts, a new view showing the build log opens. In its toolbar, a button named "Stop" allows you to halt the current build process. The current build also appears in the Eclipse job progress view and you can control the job from there.
      The build toolbar action determine the next doxyfile to build depending on the current active workbench part (editor or view) and the current selection in that part. For example, if the active part is a doxyfile editor, the next doxyfile to build will be the one being edited. If the active part is the resource explorer and the current selection is a doxyfile, that doxyfile will be next to get build. In the case the active part selection doesn't correspond to a doxyfile, the last built doxyfile will be rebuiled. And if the build history is empty, you will be asked for the doxyfile to build.

Copy Paste in Putty

Many a times we may need to remote login into a macine and we may have to use putty. But Cntr+C and Cntrl+V routines will not work here. Instead it is mouse only.

To Copy from putty:
  1. Select the word to be copied by holding down the left mouse key.
  2. Position the pointer at the place where the data is to be copied and press the middle button.
To copy to putty:-

  1. Copy the word using Cntrl+C or copy menu.
  2. Position the pointer at the place where the data is to be copied from putty and press the middle button.


Wednesday, April 18, 2012

automount usb drive and execute a script in embedded linux using udev

Today let us see how to use udev for automounting of a usb pendrive and execute some scripts to copy files..


For reference use the link given here.


Lets get started
  • Ensure that udev feature was enabled during kernel configuration. Alternatively you can use mdev from busybox for same purpose. But here we see examples for udev.
  • For udev we must write rules for what udev must do when a particular device is mounted. For finer understanding of udev please read the man pages.
  • Make a entry in /etc/udev/rules.d/  with a file name like "10-local.rules". This is because each rules are applied in lexical order and we have to ensure our rules load before the default the default rules.
    • PS. See the default rule to have an idea on how to write a rule
  • i wrote my rule like this:-
    • SUBSYSTEMS=="usb",DRIVERS=="usb",SYMLINK+="test_usb",RUN+="/home/usb_mount.sh"
  • the values for writing this can be got from executing the command                                              udevinfo -a -p /sys/block/sda for all sda device
  • A new device file /dev/test_usb is created. the script usb_mount.sh will contain the script  to execute like  mounting and copying file. 
    
    
    
    
    NOTE:Please do not use the command like 'cat' to test the script as it may not print on         console (given in refference). Instead use echo >>(redirection) text file to debug and test
    
    
    this is the script i wrote
    
    
    
    #!/bin/sh
    logfile=/home/usb_txt
    if [ "${ACTION}" = "add" ]; then 
            #mount as vfat partion
     mount -t vfat -o umask=777 /dev/cdac_usb /home/disk
          #to copy all contents of the file to an array and each can be accessed as ${variable[i]} 
     file1=($(cat /home/igate/pass.txt))
     file2=($(cat /home/disk/test.txt))
     echo password in file 1:${file1[0]}>>$logfile
     echo password in file 2:${file2[0]}>>$logfile
     if [ ${file1[0]} = ${file2[0]} ]; then
         echo 'password authenticated'>>$logfile
     for i in 1 2
     do
      ls /home/disk/${file2[$i]}
           if [ $? == 0 ]; then
              echo "file found" >>$logfile
    #this  portion ensures that the program is killed before copying 
        if (ps -A | grep ${file2[$i]} 1>/dev/null 2>/dev/null)
        then
               killall -KILL ${file2[$i]} 1>/dev/null 2>/dev/null
        echo "Stopping " ${file2[$i]}>>$logfile
        else
        echo "Failed to kill" ${file2[$i]}>>$logfile
        fi
        sleep 2
        cp -f /home/disk/${file2[$i]} /home/igate/${file2[$i]}
        if [ $? == 0 ]; then
               echo "file found" >>$logfile
        fi
       else
              echo "file not found">>$logfile
          fi
     done
     else
         echo 'password failed'>>$logfile
     fi
    umount /home/disk
    fi
    
    
    Script working:-
    It first stores all the values in the text files in arrays file1 and file2. Then it checks whether program it plans to update is not running before copying the file. All this is recorded in th ffile usb_log.txt