Tuesday, September 1, 2015

Garmin GPS 18x USB with Ubuntu

1. Install GPS babel, driver for the garmin device
      sudo apt-get install gpsbabel

2. dmesg to the device is detected

3. lsusb

4. ls -l /dev/bus/usb/001/002

5. sudo adduser ubuntu lp

6. modprobe -r garmin_gps

7. gpsbabel -T -i garmin -f usb: -o kml -F xxx.kml

8. Give permission to normal user in Ubuntu for using GPSBabel

    sudo /etc/udev/rules.d/51-garmin.rules

    Enter this line and save file

   SYSFS{idVendor}=="091e", SYSFS{idProduct}=="0003", MODE="666"


GSM AF-007 Modem with Ubuntu 

1. apt-get install gammu

2. gammu-config

   a. set port to /dev/ttyUSB0
   b. Connection to at115200
   C. Save setting

3.gammu sendsms TEXT 09790847087 -text "Lati:15.76454 Longi:9.07564356" 

Monday, August 31, 2015

Install Ubuntu in Beaglebone Black and setup network with Ethernet connection


Installation of Ubuntu in BBB

1. Download prebuilt image of Ubuntu (*.img.xz) from http://elinux.org/BeagleBoardUbuntu#eMMC:_BeagleBone_Black

2. Extract the image

3. Write image to a microSD card using Win32DiskImager (Used Windows 7 Professional).

4. Insert the SD card into poweredoff beaglebone. Keep pressed the boot button and Power on the board (used 5 V adapter to Power ON).

5. Keep the boot button pressed till the indicator leds start blinking. Wait for about 10 to 15 min till all the indicator leds stays ON.

6. Power off the board, take out the SD card and power it on again with USB connected to your computer (Can remove the 5 V adapter now).

7. ssh to ubuntu@192.168.7.2 using terminal in linux or putty in windows. Password is "temppwd".

8. You are logged in to the Ubuntu OS in Beaglebone black.

Setup Network with Ethernet connection

The set up explained here is specific for my network, where  a static ip is set to the beagle board.

1. Connect power, usb and ethernet cable to BBB.

2. ssh to the board with 192.168.7.2 (for usb connection)
      ssh ubuntu@192.168.7.2
      password: temppwd

3.  Set static IP to the primary n/w interface, which is eth0.
       a. nano /etc/network/interface
       b. Add below lines in primary n/w interface part
             # The primary network interface
             auto eth0
             iface eth0 inet static
                address 10.184.36.6  // Contact system admin for ip informations.
                netmask 255.255.255.0
                gateway 10.184.36.1

4. Now logout of the terminal and ssh to the board with 10.184.36.6 (assigned static IP)
      ssh ubuntu@10.184.36.6
      password: temppwd

5. Assign name server (This step is needed to be done each time the BBB is rebooted, Or else do something to make this change permanent).
      a. nano /etc/resolv.conf
      b. Commend all lines and add below line
            nameserver 10.184.0.11 // Contact system admin for ip informations.

6. Update by giving below command and enjoy.
      sudo apt-get update

Friday, August 21, 2015

Linux useful commands and informations

1. In debian based OS apt-get install command will download the .deb package in the below folder before installation.

    /var/cache/apt/archives/

2. To format disk in commandline

      sudo cfdisk /dev/sdb

   One another option is

     sudo mkfs.ext4 /dev/sdb1

3. Find User ID (uid) of the current user in Linux system.

      id -u [USER_NAME]

      eg:  id -u root  (which will be 0).

4. Change ownership of a folder for specific user.

      chown -R [UID_OF_USER] [PATH_TO _FOLDER]

      eg: chown -R 1000 /opt/tinyos-2.x/

5. Find a file or directory in specific place.

      find [PATH_TO_SEARCH] -name [FILE_NAME]

      eg: find /opt -name tinyos.sh

6. Install grub due to some error in grub.

      grub-install --root-directory=/dev/sda

7. Write OS image (*.img) into USB/ microSD in linux (Ubuntu).
     Create bootable USB/ microSD from image file (.img)

      sudo dd if=./BBB*.img of=/dev/sdX

      sdX, here X denote where the device is mounted.

8. SSh connection failure due to the error "Host key verification failed."

     ssh-keygen -R



9. Find baud rate of a serial device through commanline

    sudo stty -F /dev/ttyUSB0    //replace ttyUSB0

Monday, June 1, 2015

PostgreSQL Useful commands


PostgreSQL Useful commands

  • To copy a table to create new one
    • CREATE TABLE table_name_2 ( like table_name_2 including all)
  • Insert columns from one table to another
    • insert into table_name (phone_no,subscriber_name,address,pincode,place,district) select phone_no,subscriber_name,address,pincode,place,district from tabele_2;
  • Insert column of one table from another table, where second table colum length is less than 95
    • insert into table_back 
    • (
    •   phone_no,subscriber_name,address,pincode,place,district
    • ) select phone_no,subscriber_name,address,pincode,place,district from table_2 where length (subscriber_name) > 95;
  • Delete complete content from table
    • DELETE FROM table_name;
  • Delete a column from table
    • DELETE FROM table_name WHERE phone_no = 7382613796;
  • Change table name
    • ALTER TABLE table_name RENAME TO TABLE_NAME_2;
  • Change column datatype
    • ALTER TABLE table_name ALTER COLUMN phone_no TYPE bigint USING (phone_no::bigint); 
      • phone_no is the column name.
  • Delete row when length of a column not equal to 10
    • delete FROM table_name WHERE length(phone_no)!=10;
  • Update column by its first n characters, if the character length is to be reduced
    • update test_1 set subscriber_name = left(subscriber_name,10);
  • To create new table from old table, sorted by systemtime
    • create table new_racktemp as select * from racktemp order by systemtime;
  • Alter/ Update existing table by inserting new column, setting it with primary key and insert the column with serial numbers starting from 1.
    • alter table new_racktemp add column slno bigserial primary key;
  • For creating sequence number and updating column with that (not tested)
    • CREATE SEQUENCE seq;
    • ALTER SEQUENCE seq RESTART WITH 1;
    • UPDATE racktemp SET slno=nextval('seq');
  • Dump and restore for command line
    • Go to "cmd"
    • Change directory to the Postgres Bin folder      
    • cd // cd C:\Program Files\PostgreSQL\9.3\bin
    • Use pg_dump to backup
      • pg_dump.exe -U postgres -t "table_name" "Data_base_name" > "Path&Name_Backup"
      • //pg_dump.exe -U postgres -t consotable hpc > C:\Users\CFD\Desktop\consot.backup
  • Use psql to restore to another database
    • psql.exe -U postgres "DB_name" < "Path for backup file"
    • //psql.exe -U postgres testdb < C:\Users\CFD\Desktop\consot.backup
  • Get values of the last updated row inreference to serial number
    • SELECT * from table_name order by slno desc limit 1