Ladakh – Yet again

It is that time of the year when roads to this wonderland starts to open and time for me to pay another visit to the land of highest mountain passes.

This year its going to be a special ride, during the ride I would be completing an association of 10year with Fiero. Together we have traversed this land of lamas thrice and hope to visit some new places this time.

To make things a bit more  adventurous, the road between Manali and Leh isn’t officially opened yet (with less than 2 days left for me to ride on it).

Spare Parts to Carry on a Road Trip

I’m going on a long road trip for the first time, on my motorcycle, what all spares shall I carry?” If you are having the above question, then read ahead.

How many times and which all parts in recent past (1month/1year/3years/10years), on your bike have failed you? Normally your answer would be “none” (that’s what it will be in most of cases). But if there are some parts that have failed more than once, in recent past, add them to the list as the first items (for example HT coil on one of my motorcycle). On a well maintained (regularly serviced & with all parts replaced whenever the need arises) bike, you shouldn’t have parts that would have failed frequently (here I’m talking about a bone stock bike).

So, if no part has failed, so far, on my bike why should I even bother to carry any spares? Well, there are certain spares that aren’t very expensive and don’t occupy too much space and aren’t too difficult to replace either BUT if they fail can land your bike in an unusable state. So, it’s better to be safe than sorry and carry them.
Following is a list of such spare parts:

  • Fuses
  • Spark Plug
  • Spark Plug Cap
  • Chain Link
  • Clutch lever
  • Clutch lever mounting clamp
  • Brake Lever
  • Brake lever mounting clamp
  • Cables: Accelerator, Clutch and Brake (if your bike runs on front drum brakes)
  • Headlamp bulb
  • Engine oil (if you are using one that is not easily available and you think during trip it will require to be changed)

Other than the above mentioned carry spare set of tubes (if your bike runs on tube type tire). Even if your bike runs tubeless tire, it is better to carry a spare tube just in case the alloy wheel is damaged and starts to leak air, fitting with tube can fix the problem.

One point to note is that, it’s important to know how to replace the spare part that you are carrying else often it would be as good as not carrying one. So, learn to change these parts and practice before you head out on that ride which you always dreamt off.

Though the following items are not exactly spare parts, one should also be carrying them:

  • Electrical wire
  • Electrical tape
  • M-seal

One might ask, for a long road trip the above mentioned list is fine but what about Ladakh? My answer is, Ladakh is no different than any long road trip. Yes, the terrain is different, so is the altitude and the help on road side is rare but other than how does it matter what all parts one should carry?

The list is kept short to only those parts that one can carry easily and don’t need much skill to change them and if they fail you might be left stranded. Though one can carry much more parts than the above listed but then are you preparing yourself for the worse? Than what about the “adventure” part of the road trip? In that case may be use a backup vehicle or better use some other mode of travel.

Now, if you wonder where in my city I can find a good place to get my motorcycle prepared or learn how to replace the above mentioned parts. Though I don’t have information for many cities but I can help you with Mumbai. In Mumbai Arpan & Reddy conduct sessions for leh riders free of cost and teach you basics of motorcycle maintenance. For all my long trips (including 3 Ladakh rides), my bike(s) were prepared by them.

Merry Christmas & A Happy New Year

Wishing you all and your near and dear ones a very Happy New Year. Another year is coming to an end and hopefully with a new year this place will be more regularly updated (something that I really wanted to do this year itself).

Mailbox #2: String Reverse and Array Bound Checking

Query: How to reverse a string without using any variable. You are not even allowed to use a variable to store a string.

There has to be some temporary variables to be used, for looping over the string.
Reversing a string requires swapping first character with the last, second with second last, third with third last and so on. Now the problem requires the string to be reversed in place (without using any other buffer to store the reversed string). So, we will have to interchange the elements in the original string buffer itself. Following is a pseudo code for the same.

i = 0;
j = StringLength – 1;
while (i < j) {
Swap i and j element of String
++i;
--j;
}

The swapping of the two elements can be done either using a temporary variable or using XOR operator.

Query: “C” doesnt provide boundation checking on array but it is still able to findout the length of array using the sizeof(). Why it cannot enforce boundation checking on array?

The reason why C is able to find out the length of array is because the length of array is part of its type declaration. As the type of a variable is known at compile time, sizeof operator can be used to find the length of array.
Faster execution speed would be one reason why C don’t do array bound checking.

First Rain Ride of 2009

My first decent rainy ride in more than 2 years, turned out to be a really good and satisfying in the end. Though I have ridden to Mumbai in the very first rains of the season, it was more of a high speed run on near perfect piece of tarmac.

In search of a decent resort in or around Mulshi, for a family outing next weekend, I decided to visit there on a motorcycle.

By the time I got kitted for the ride it was lunch time, though the normal routeto Mulshi is via Chandni Chowk – Pirangut – Paud, I have been on that stretch so many times that today I was just not feeling like riding on the very same stretch. So, I head out in opposite direction on NH4. After filling more than enough fuel for the ride at Shell pump (a rare thing for me, I often land up filling lesser fuel than needed for the ride and then searching for one later) I headed towards Lonavala. After having covered some 10 odd km’s, I got bored of the tarmac and got onto a road through villages and headed towards Pavana dam.

It was a bumpy, slow ride all the way with lush green scenery all around me. Though it was bone dry in Pune, as soon  as I got on this road rain god welcomes me with heavy showers. All my plans of stopping to capture greenery were put on hold, thanks to rain.

Enjoying every water filled pothole, occasional good section of tarmac and gravel, I reach the dam. Disappointed to see it not yet fully filled. A small stop and I was heading towards Paud. Just as I started to climb, the beautiful view of Tung fort made me get off the road for some offroading on slush + green grass stretches.

The ride till Paud was kinda monotonous with no rains and no great view that would made me stand up on brakes. Road conditions deteriorated soon after Paud and I was already in no mood to repeat the Paud – Mulshi stretch on my way back.

After finishing the inspection of all the probably resorts, I was feeling hungry so pulled over for a pit stop around 3:15. Missal Pav it would be for the near empty stomach. While having food I decided to head towards Lonavala. It was almost 4pm and with bike’s chain a bit loose for my comfort and rear sprocket having a bit of play (may be rubber bushing/bearing gone), there was a distinct possibility of getting stranded in a jungle. All part and parcel of adventure on two wheels, I said and got on the bike and headed towards Tamhini.

The road was bit better than before but the non-stop rain was giving very little chance to bring out the camera. Just after crossing Tamhini village, I got off the road and got on the offroad section towards Amby Valley. After a decent stretch initially, consisting of broken tarmac and some gravel I got on a stretch that was mostly a layer of stones, almost till the end. With rain, jungle and hardly any civilization, I wasn’t complaining much about the road surface. After all I didn’t want to go berserk on near perfect tarmac.
It was disappointing to see not too many sections of road under water, not enough water streams or over flowing rivers, as I encountered during my last ride on this section.

Before it got anywhere close to dark I was on the tarmac section near Amby valley, twisties at its best. It was tempting me to push like crazy in search of scraping my knees against tarmac. Alas, if wishes were horses I would have been on a 223bhp machine and not a 223cc machine. In no time I was riding in thick fog, with near zero visibility, so all plans of pressing that “red” button were put to rest. Though the pace was really slow, still it was fun. After all I was still out of city limits with not much traffic to deal with.

Soon the dream run came to an end, as I approached Bushi Dam. With no fog and rain around, I switched from fun mode to reach home mode. After a initial struggle to pass the long queue of cars, I somehow managed to come out on NH4. The traffic is diverted and I came out just next to the turn for Rajmachi. It was very very tempting to take the turn but with clock well past 6, it was just too late for my comfort. So, it was time to slot into top gear and finally press the “red” button to head home before it gets dark. In the end, just managed to park my bike in garage before it was pitch dark to end a much needed and entertaining ride.

When: 8th Auguest 2009
Route: Pune – Pavana Dam – Paud – Mulshi – Tamhini – Kundalika – Amby Valley – Lonavala – Pune.
Distance: 213km’s
Time taken: 6hrs 35min.

Back from Snow Land ala Ladakh

and I’m back, back to modern civilization.
The above picture is one that was clicked during the trip, as we climbed up Chang La after it was happily snowed for more than 30minutes. During this trip, I got to experience more than what I was looking for.

I’ll try to pen down the wonderful experience I had during this trip as soon as possible and share them with your all soon, very soon. :)

Out of reach

Pangong Tso

It is not that I was very actively updating my blog here, that anyone will notice that I’m away from Internet for sometime.

Still, for those who stay in touch with me via e-mail, IM’s and other mode of communication, please note that I’ll be out of reach for next two weeks. The picture above should give you an indication as to where I can be found, if at all. :)

Mailbox #1: Pointer query

Query: What this pointer exactly holds in this case and how it works.

int *p;
p = (int *)300;

In the above assignment statement, we are storing an integer into a pointer. Since it will not be allowed directly, hence a type casting is required.
Once the assignment is done, pointer p will contain 300 and it will be interpreted as an address. Dereferencing the pointer p, will try to access an integer stored at address 300. The result will be garbage (unless you know what is stored at address 300). Also, the safe execution of the dereferencing statement will depend on the OS in which the code is executed. As under Linux the program will generate segment fault/core dump.

Read Pointer in C/C++ Part – 1 for more explanation.

Query: What is this declaration ? For this printf what will be the answer and why?

double *p,*q;
p=(double *)4000;
q=(double *)2000;
printf(”%d”,p-q);

For the explanation about declaration, see the above explanation.

In the printf() we are printing the result of subtracting two pointers of the same type. The number of memory locations between the two addresses will be 4000 – 2000 = 2000bytes. Since the size of double (as both are double pointers) is 8 bytes. The result will be 2000 / 8 = 250. Hence, printf() will print 250 as the output.

Read Pointer in C/C++ Part – 2 for more explanation.

Pointer in C/C++ Part – 2

Having covered the basics about pointers in last article, let’s look into pointer arithmetic. The arithmetic operations that are allowed with pointers are adding/subtracting integer to/from a pointer and subtracting two pointers.

How to add/subtract integer to/from pointer?
The result of adding/subtracting an integer (‘n’) to/from a pointer will be the address of the nth element (of the same type as pointer) with address in pointer used as a base address.

Let’s look into this with an example. Say we have an integer (32-bit integer) pointer pointing to address 1000. Now if we want to add integer 4 to this address, what the result will be?
So, we will assume address 1000 as the base address into which we will be adding integer, 4. Now, since the pointer is an integer pointer, it means at address 1000 an integer will be stored, since it’s a 32-bit integer, it will take 4 bytes. Hence, starting from address 4 byte will be used by that integer (address 1000, 1001, 1002 & 1003). So, next integer will be stored only starting from address 1004, and taking 4 bytes.

By the above explanation we can see that since every integer takes 4 bytes, going to next valid integer, we need to increment the address by 4 bytes or 4n bytes to reach nth integer. Now, this number 4 has come from the fact that the pointer’s type was integer pointer. Had it was a character pointer, we would have to increment address by 1 byte to reach the next valid character.

So, we can form the following generic formula to find the result of adding an integer to an address.

Result = Pointer + Integer * sizeof(Value stored at Pointer Address).

Let’s apply this to our example:
Pointer = 1000
Integer = 4
Value stored at Pointer Address = integer (as it is a integer pointer)
Sizeof(Value stored at Pointer Address) = 4 (it is a 32-bit integer)

Result = 1000 + 4 * 4 = 1016.

If we replace addition with subtraction in the above text, we can come up with the following formula to subtract an integer from a pointer.

Result = Pointer – Integer * sizeof(Value stored at Pointer Address).

So what is the type of the value that we get as a result of adding/subtracting integer to/from pointer? The answer is, same type as the pointer which was involved in addition/subtraction operation, i.e.,  Integer pointer, in the above example.


How to subtract two pointers?
Two pointers of same or different types can be subtracted from each other. Though, normally we subtract pointers of same type only.

In short, subtracting two pointers of same type tells us how many elements of the type of pointers can be stored between those two addresses. In case we subtract two pointers of different types, the result is number of elements, of largest type (type that needs more memory) of pointer, that can be stored between two addresses.

The type of value returned by subtracting two pointers is of type integer, as it gives us the element count.

Let’s subtract two pointers of the same type. Say the two pointers are pA and pB with addresses 2000 and 1000 and their types are integer pointers. So, if we do pB – pA. The result should be number of integers that can be stored between 2000 and 1000. Since the memory locations between 2000 and 1000 are 1000 and each integer takes 4 bytes (32-bit integer). Number of integers that can fit in 1000bytes will be 1000/4 = 250. So, if we subtract two integer pointers with addresses 2000 and 1000, the result will be 25.

Now, the above can be put in a generic formula as follows.
Result = (PointerA – PointerB)/sizeof(Value stored at PointerA or PointerB).

Now, let’s look at the case where the two pointers are of different types, say pA is character pointer and pB is short integer pointer. Since size of a character is 1byte and size of short integer is 2bytes, the result of subtraction will tell us how many short integers can be stored in between the two pointers getting subtracted. Since there are 1000 memory locations between two pointers, the result will be 1000/2 = 500.

Now, the above can be put in a generic formula as follows.
Result = (PointerA – PointerB)/MAX(sizeof(Value stored at PointerA), sizeof(Value stored at PointerB)).

Similar topics
Pointer in C/C++ Part – 1

In & Around Lavasa

Sunrise viewed through wild flowers.

After spending almost entire night @ office, I dumped the idea of hitting bed. Started in dark towards Lavasa to greet Sun a very good morning. Also got a chance to ride my bike into Lavasa township. Picture from a wonderful morning.

View from Lavasa Top, just before Sun was about to come out.
View from Lavasa Top, just before Sun was about to come out.

It was not just me but moon also waiting to greet Sun.
It was not just me but moon also waiting to greet Sun.

First view of the sun as it come out to brighten up the sky.
First view of the sun as it come out to brighten up the sky.

Watching Sun rise from Lavasa top.
Watching Sun rise from Lavasa top. Watching Sun rise from Lavasa top.

Viewing Sun through leaves of a tree.
Viewing Sun through leaves of a tree.

Temghar Dam backwaters view from road to Lavasa city.
Temghar Dam backwaters view from road to Lavasa city.

Standing on the banks of warasgaon dam backwaters.
Standing on the banks of warasgaon dam backwaters.

Warasgaon Dam backwater as viewed from Lavasa City.
Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City.

Twisties – No matter how much you have them, you always want more.
Twisties - No matter how much you have them, you always want more. Twisties - No matter how much you have them, you always want more.

CBZ Standing at the bottom of Lavasa township. Towards Warasgaon end.
CBZ Standing at the bottom of Lavasa township. Towards Warasgaon end.

Standing in Lavasa city.
Standing in Lavasa city. Standing in Lavasa city.

While I was sipping on Tea, I found this young chap making the most of the early morning warm Sun rays.
While I was sipping on Tea, I found this young chap making the most of the early morning warm Sun rays.

Click on image to view in bigger size.