Archive

Archive for the ‘KnowHow’ Category

Fitting LED Strip to Getz Radiator Grill

August 15th, 2010 No comments

White (Blueish) LED strips with 3M water proof stickers are available for 300-350Rs/30cm.  These LED strips are pretty bright when illuminated and draws lesser power when compared to incandescent lamps.

Step 1: Open the Bonnet of the Car

Step 2: Identify the Parking Lamp + Head Lamp Positioning Motor Power Line

Step 3: Remove the Parking Lamp, Lamp Positioning Motor Power Connector

Step 4: Remove the Connector Shield to find the Power lines

Step 5: Find and Tap the Parking Lamp Line.

Step 6: Put the connector shield back on the connector
Step 7: Put the connector back on the Lamp assembly
Step 8: Turn on Parking Lamp; Hurray LED Strip is AWESOME.

Powered by ScribeFire.

CRB Plus Vs Active 4T

August 9th, 2010 No comments

I had been using CRB Plus for my Thunderbird bike for the engine compartment and the clutch case. For the gear section I am using a 90 grade oil.  Lately, I found that the clutch case was getting overheated within few minutes.  When I enquired about this to my mechanic, he advised me to try Active 4T oil.  Later that day, the oil from the clutch case was drained and refilled with Active 4T. Wow, the heat dynamics is much better now.  I am able to touch the case with my bare foot even after 1 hour of driving.  Thanks to Active 4T.

BSNL Broadband Connectivity Issue on Noise phone lines

April 10th, 2010 No comments

If you are an exclusive BSNL broadband user, you might not have attached the telephone to the phone line.  I have connected my Netgear modem to the DSL/Phone line splitter and left the other connection floating.  Lately, when I noticed that the Netgear modem was not able to make the connection with BSNL servers, originally I thought the telephone line is dead.  To my surprise the telephone line was fine, but I perceived the lines to be little noisy.  I made a complaint to the BSNL portal and as usual nothing much happened.  Accidently, I had to connect my telephone to the splitter for making a local call.  To surprise, the Netgear modem managed to connect to the server this time.  So, the hypothesis is;

When the telephone line is noisy, attach the telephone to the splitter along with the modem connection to get connected to the BSNL Servers.  Most likely it could be because of the Reactive load offered by the telephone on the phone line ends up conditioning the Phase modulated signals for the Netgear modem to connect to the Servers.

Powered by ScribeFire.

BSNL Broadband Unlimited usage

April 4th, 2010 No comments

Are you a BSNL Broadband user enjoying the 2AM-8AM unlimited access ?  Are you a person who has automated downloads programmed between 2AM – 8AM IST ? Are you seeing higher bill amount despite your carefully planning internet downloads during the unlimited access times ?  You should read this article for sure.

Do you know, you could track your internet usage on daily basis ? If not, register yourself at http://www.data.bsnl.in/. If you send the webmaster an email requesting for user account, you promptly get response within a couple of days with the required credentials.  You could login to the website to check your usage on a daily basis.  Infact, you can see your usage data for the past months also.  It is really very useful.  Alternately you could register your mobile number with BSNL and activate the notification service.   Upon activation, BSNL would send you SMS if your usage crosses the set-limit for your account.  See the following excerpts from BSNL website about this service.

If you are an user of BSNL Broadband and are not on any one of the unlimited plans, then you must keeping tabs on the data usage you have done. But what if you are on the move and not able to access the internet to check the data usage?

Simple, Send an SMS.

Yes, BSNL has now introduced a new feature where in you can now know your broadband usage via SMS.

How to Register for this New Feature?

Just SMS “REG Landline Number” prefixed with your STD code (For Example REG 080 23456789) to the following numbers:

52295: For Bsnl Mobile Customers.

9448077777: For Any Other Mobile Customers other than BSNL.

After Registering your landline number, you will receive a Thank you message and from then onwards, you can check the broadband usage of your account anytime by just sending an SMS.

How to Check the Broadband Usage of My Account?

Just SMS “BBU Landline Number” prefixed with the STD Code (EG BBU 080 23456789) to the following numbers:

52295: For Bsnl Mobile Customers.

9448077777: For Any Other Mobile Customers other than BSNL.

Note: This service is completely free, and you will be charged only for the SMS, based on your operator’s sms charges.

Coming back to the billing issue.  Lately, I noticed that I get very high BSNL broadband usage bills.  I wanted to keep a tab on that and sent a couple of complaint mails to BSNL billing.  But I did not get any response from them.  Following that I registered on the Broadband Usage statistics website mentioned before and was surprised to see that I had indeed used beyond my 2.5Gb limit (I have subscribed to 500C+ plan). 

When I looked the data usage pattern, I could figure out something very interesting about the way BSNL charges.  Consider that I have my automated download scheduled to start at 2:05 AM and stop at 7:55 AM.  I generally keep my machine in Sleep mode and have enabled the Scheduler application to wake up the machine for downloads.  Sometime, I keep the machine on over night.  I figured out that whenever I kept my machine on, I was charged for the usage even for the free-usage timespan.

Consider the case of a machine running over night.  When the machine is running the router to BSNL connection stays in “connected” state.  If the machine was in sleep mode, the connection is “offline” and whenever the machine wakes up, the connection is reestablished.  BSNL has setup the usage measurement exclusion only for the connections started after 2AM. Meaning if a computer was running over night and the connection status is “connected”, one may not get the free usage time-span.  Because the current connection is active and it was started before 2AM and hence the current connection is billable, as per the BSNL usage algorithm. 

The thumbrule here is: “Unlimited usage only for connections start at or after 2AM”.But interestingly, the 8AM connection is correctly handled by BSNL.  If you connection stretches beyond 8AM, the usage is billable for all the bytes transferred from 8AM onwards.

The following are the action points:

  1. Avoid running the computer over night with the connection is “connected state”. Because if the connection stretches beyond 2AM, you would not get the benefit of unlimited usage.
  2. Prefer to put the machine on sleep mode and make the scheduler wake up the machine for running your download tasks.
  3. Make the time of your computer synchronized with a standard time server like in.ntp.pool.org or time.windows.com
  4. Plan to start the download at 2:05 AM and stop at 7:55 AM
  5. Register on http://www.data.bsnl.in and keep a tab on your usage
  6. Register for SMS notification service

Powered by ScribeFire.

Restrict MSN file transfer

November 27th, 2009 No comments

MSN uses port 1863 to transmit messages and for file transfer.

Lot of people have said that the file-transfer using MSN happens via port range 6891-6900.  But when I experimented, I found that MSN is using same 1863 port.  Linux machines are able to identify this port as “msnp”.  I used “tcpdump” to verify this.  Whenever MSN attempts to send a file across the Internet, I creates several smaller packets (typically in the range of 536-1350 bytes) and sends them one after the other.  During the file transfer process, if there are messages (text or IM) to be transmitted, the message data block is piggy-backed on the file-transfer packets and sent across.

I was desperately looking for filtering the MSN based file-transfer for some official purposes and wrote some iptables rules based on the Internet literature that said file transfers happen via 6891-6900 by TCP.  Then, to validate the rules, I used tcpdump again on the gateway machine to monitor the packets that are originated from my machine. 
tcpdump src host dev02 -i eth1 -vvv
To my surprise, the file transfer was still happening also the ports are blocked.  Then I made an “iptables” rule to drop all the packets other than 1863 and repeated the experiment.  Still the file-transfer was happening.  I could see using tcpdump that the packet transfer is happening via port 1863.
tcpdump src host dev02 and dst port 1863 -i eth1 -vvv
So, it became apparant that the file-transfer and the text messaging are all happening via port 1863 instead of the port range 6891-6900.  I then decided to write an iptables rule to filter the packets using the packet size constraint.  A rule was written to drop packets that are more then 600 bytes assuming that the IM packets shall never reach the limit.

iptables -A FORWARD -i eth1 -m length -p tcp –length 600:65535 –dport 1863 -j DROP
iptables -A FORWARD -i eth1 -p tcp –dport 1863 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp -j DROP

I did see that the packet size is around 1350 bytes when files are transferred and that’s why I chose 600 bytes as the limit.  When I monitoring using the “tcpdump” command as before, I was surprise to see that the protocol adjusted the packet size automatically to 560 bytes to continue the transmission.  It tried with 1350 bytes for 3 times and as the acknowledgments were not received, it’s flow control mechanism reduced the packet size to 560 bytes and finished the transfer.  So, I had to redo the iptables rule:-

iptables -A FORWARD -i eth1 -m length -p tcp –length 600 512:65535 –dport 1863 -j DROP

It worked like charm.

The happiness did not last long.  When people logout and tried logging in, they were not able to login at all.  When I investigated the cause of this problem, I could see that the packets that are exchanged during the login process is more than 512 bytes (typically 1350 bytes).  So, I had to relax the rule for a brief time to let people login to MSN messenger service.  I enabled the file-transfer restriction after everybody logged in by enabling the iptables rule.
NOTE: iptables based filtering shall work only for packets that travel across the network.  If the MSN file-transfer happens inside the LAN, MSN cleverly does the file-transfer using P2P where the gateway is not involved at all.

Although, this is not a very good solution, it is definitely worth knowing about!
Happy firewalling!.

Compile 32bit C/C++ Application in 64bit Linux

October 8th, 2009 No comments

To build (cross compilation) 32 bit C/C++ applications on 64 bit linux box, use “-m32″ as a compiler argument.  You would need the following 32bit libraries in place.

  1. Install glibc.i386, glibc-devel.i386
  2. Install libgcc.i386
  3. Install libstdc++.i386

#include <cstdio>
#include <iostream>
main()
{
    std::cout << “C++” << std::endl;
    printf ( “long: %d\n”, sizeof(long) );
    printf ( “long long: %d\n”, sizeof(long long) );
    return 0;
}

To compile in native 64bit:
[sudar@tstsrv12 tmp]$ g++ -m64 -o out64 code.cpp

[sudar@tstsrv12 tmp]$ ./out64
C++
long: 8
long long: 8

[sudar@tstsrv12 tmp]$ ldd out64
        linux-vdso.so.1 =>  (0x00007fffc43fe000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003e7be00000)
        libm.so.6 => /lib64/libm.so.6 (0×0000000000601000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003e79e00000)
        libc.so.6 => /lib64/libc.so.6 (0×0000000000886000)
        /lib64/ld-linux-x86-64.so.2 (0×0000000000110000)

To compile in 32bit:
[sudar@tstsrv12 tmp]$ g++ -m32 -o out32 code.cpp

[sudar@tstsrv12 tmp]$ ./out32
C++
long: 4
long long: 8

[sudar@tstsrv12 tmp]$ ldd out32
        linux-gate.so.1 =>  (0×00130000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0×00133000)
        libm.so.6 => /lib/libm.so.6 (0×00223000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0024c000)
        libc.so.6 => /lib/libc.so.6 (0x0025a000)
        /lib/ld-linux.so.2 (0×00110000)

Another Automation Project

May 2nd, 2009 No comments

Powered by ScribeFire.

/dev/mapper empty after reboot

February 26th, 2009 No comments

I had configured raid STRIPE on 2 500Gb hard disks to create a 1TB stripped disk using Intel Raid controller on Asus D5Q motherboard.  When I loaded CentOS 5.2, it identified the stripped disk correctly and formatted that too.  After the installation is completed, CentOS 5.2 was not able to detect the disk array at all.

dmesg was showing messages like the following:

device-mapper: uevent: version 1.0.3
device-mapper: ioctl: 4.11.5-ioctl (2007-12-12) initialised: dm-devel@redhat.com
attempt to access beyond end of device
sda: rw=0, want=1953535936, limit=976773168
Buffer I/O error on device sda1, logical block 1953535872
attempt to access beyond end of device

When I tried “fdisk -l”, I got the following:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1      121602   976768033+  83  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

The above is natural as RAID STRIPE is built using /dev/sda and /dev/sdb.

When I tried “dmraid -r”, I got

[root@tstsrv12 sudar]# dmraid -r
/dev/sda: isw, “isw_djiaeaj”, GROUP, ok, 976773166 sectors, data@ 0
/dev/sdb: isw, “isw_djiaeaj”, GROUP, ok, 976773166 sectors, data@ 0

Till this point, my /dev/mapper directory is:

[root@tstsrv12 sudar]# ll /dev/mapper/
total 0
crw——- 1 root root  10, 63 Feb 26 13:24 control

To enable the RAID multi-device, I had to run “dmraid -v -d -ay”, which returned:

[root@tstsrv12 sudar]# dmraid -v -d -ay
DEBUG: _find_set: searching isw_djiaeaj
DEBUG: _find_set: not found isw_djiaeaj
DEBUG: _find_set: searching isw_djiaeaj_Volume0
DEBUG: _find_set: searching isw_djiaeaj_Volume0
DEBUG: _find_set: not found isw_djiaeaj_Volume0
DEBUG: _find_set: not found isw_djiaeaj_Volume0
DEBUG: _find_set: searching isw_djiaeaj
DEBUG: _find_set: found isw_djiaeaj
DEBUG: _find_set: searching isw_djiaeaj_Volume0
DEBUG: _find_set: searching isw_djiaeaj_Volume0
DEBUG: _find_set: found isw_djiaeaj_Volume0
DEBUG: _find_set: found isw_djiaeaj_Volume0
DEBUG: checking isw device “/dev/sda”
DEBUG: checking isw device “/dev/sdb”
DEBUG: set status of set “isw_djiaeaj_Volume0″ to 16
DEBUG: set status of set “isw_djiaeaj” to 16
RAID set “isw_djiaeaj_Volume0″ already active
INFO: Activating GROUP RAID set “isw_djiaeaj”
DEBUG: _find_set: searching isw_djiaeaj_Volume0(null)1
DEBUG: _find_set: not found isw_djiaeaj_Volume0(null)1
RAID set “isw_djiaeaj_Volume0(null)1″ already active
INFO: Activating partition RAID set “isw_djiaeaj_Volume0(null)1″
DEBUG: freeing devices of RAID set “isw_djiaeaj_Volume0″
DEBUG: freeing device “isw_djiaeaj_Volume0″, path “/dev/sda”
DEBUG: freeing device “isw_djiaeaj_Volume0″, path “/dev/sdb”
DEBUG: freeing devices of RAID set “isw_djiaeaj”
DEBUG: freeing device “isw_djiaeaj”, path “/dev/sda”
DEBUG: freeing device “isw_djiaeaj”, path “/dev/sdb”
DEBUG: freeing devices of RAID set “isw_djiaeaj_Volume0(null)1″
DEBUG: freeing device “isw_djiaeaj_Volume0(null)1″, path “/dev/mapper/isw_djiaeaj_Volume0″

Now, my “/dev/mapper” directory is:

[root@tstsrv12 sudar]# ll /dev/mapper/
total 0
crw——- 1 root root  10, 63 Feb 26 13:24 control
brw-rw—- 1 root disk 253,  0 Feb 26 13:25 isw_djiaeaj_Volume0
brw-rw—- 1 root disk 253,  1 Feb 26 13:25 isw_djiaeaj_Volume0(null)1

Now, I am able to mount the RAID array on to my folder:

mount LABEL=/vendors /vendors

The output of “df” is now:

[root@tstsrv12 sudar]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdc1             29753556   3516168  24701576  13% /
/dev/sdc3            410600744  26227400 363179596   7% /opt
/dev/sdd1            473086160    202800 448464160   1% /backup
tmpfs                  8154532         0   8154532   0% /dev/shm
/dev/mapper/isw_djiaeaj_Volume0(null)1
                     946176360    204572 897133388   1% /vendors

See, the RAID drive is mapped to /vendors folder.The Real Issue behind the problem is identified and a solution is presented at http://www.linuxquestions.org/questions/linux-kernel-70/centos-kernel-upgrade-breaks-dmraid-on-intel-software-raid-638450/. I am summarizing the changes here:

1. The real problem is the way dmraid is initialized at initrd’s init script. There is a bug in ‘mkinitrd’ script that generates ‘initrd**img’.
2. Open ‘/sbin/mkinitrd’ and search for “dmraid -ay -i -p”; It may appear something like “dmraid -ay -i -p “isw_cfgaijfacg_Volume0″.  Look at the suffix “Volume0″, this suffix attachment has become the problem for us.  dmraid does not like the Volume% suffix.  It should have been initialized as “dmraid -ay -i -p “isw_cfgaijfacg”".
3. Let’s change the script to the following from:
emit “dmraid -ay -i -p \”$dmname\”" 

to

dmnamecore=$(echo $dmname | sed -e ‘s/_Volumn[0-9]\+//;’)
emit “dmraid -ay -i -p \”$dmnamecore\”"
4. Generate a new initrd image by running “mkinitrd /boot/initrd-2.4.18-92.el5.img.dmraid `uname -r`”
5. Edit your /etc/grub.conf to use the newly created initrd image instead of the old one by editing the following line from “initrd /boot/initrd-2.4.18-92.el5.img” to “initrd /boot/initrd-2.4.18-92.el5.img.dmraid”
6. Reboot your machine.

Powered by ScribeFire.

Error: Can not start thread: error writing TLS. (error 87: the parameter is incorrect.)

February 18th, 2009 No comments

When I tried building an multi-thread TUI application using wxWidgets framework, I got the following error while executing the application.

Error: Can not start thread: error writing TLS. (error 87: the parameter is incorrect.)

I was not able to reason out this behavior. I tried changing between THREAD_DETACHABLE and THREAD_JOINABLE, but was not able to get through.  When I search for hints from the web, I got the following link.

http://osdir.com/ml/lib.wxwindows.general/2004-01/msg00759.html

It was advised to create a dummy wxInitializer object so that the wxWidgets platform does the necessary initialization.  wxInitializer class is an undocumented class and called internally when a wxFrame or wxDialog based GUI application is built.  Typically, wxInitializer object is instantiated internally by the wxApp class.  Since, in my application there is no wxApp object which led to the above problem

When I dug the declaration of wxInitializer class, I found it declared at wx/init.h;  Also I found that instead of instantiating the object, we may call the following function.

extern bool WXDLLIMPEXP_BASE wxInitialize(int argc = 0, wxChar **argv = NULL);

In my application, I did the following:

main( int argc, char **argv )
{
      extern bool wxInitialize( int, char ** );
      wxInitialize( argc, argv );
      ….
      ….
}

It worked like piece of cream.

Powered by ScribeFire.

Green Lines, Blue Patch while playing AVI in VLC

January 30th, 2009 No comments

I have downloaded a lot of videos uploaded by aXXo from mininova.org.  Lately, I found that all the videos that I download from aXXo, were getting a blue patch or bunch of green lines while playing in VLC player (0.8.6b).  I am not able to take a snapshot of the video to show how bad the patches are.  Interestingly, VLC’s snapshot option is giving out the snapshots that are pretty clean.  I searched in many places for a solution.. People adviced of a) remove YV12 in ffdshow b) install XVid instead of the MP4 plugins c) disable WMV acceleration d) setting de-interlacing to Discard/Mean in VLC e) reinstall nVidia driver f) reinstall VLC player and many more. I tried all of them and nothing worked out for me.

Finally, I figured out the answer from the following URL:
http://forum.videolan.org/viewtopic.php?f=14&t=41484

The answer is pretty simple.

a. Click on Setting->Preferences
b. Open Video on the Left pane
c. Click on Output Modules
d. On the right hand side, check enable on the “Advanced Options”
e. You will see a pull down menu named “Video Output Module”
f. Select DirectX 3d video output
g. Click on Save
h. Restart VLC.

There you go.. The video plays super smooth.

Still, I am not able to figure out why should I do this to make the video work. The problem is definitely not a codec problem, not a de-interlacing problem.. I am yet to discover what got changed for aXXo’s videos.

Powered by ScribeFire.