Tuesday, July 28, 2009

How to read (ASCII) data file in C

/*Function that reads the data file into an array and returns a pointer that points to this array of FP32*/

FP32* readData(const char *i_filename){

FILE *fp;
fp = fopen(i_filename, "r"); //open file , read only
INT32U numElements = 0;
FP32 value; //keep value at pointer position
FP32 *array=NULL; //set to NULL because of realloc
/* loop until all data keep into array */

while( (!feof(fp))){
fscanf(fp, "%f", &value);
array = (FP32 *) realloc (array,(numElements+1) * sizeof(FP32 *));
array[numElements++] = value;
}
/* shift array and add "size of array" to its first element
since there is no way to get size of an array from its FP32 pointer*/

INT32U i;
array = (FP32 *) realloc (array,(numElements+1) * sizeof(FP32 *));
for(i=numElements;i>0;i--){
array[i]=array[i-1];
}
array[0]=numElements;
/* close file */
fclose(fp);
return array;
}

Labels: , ,

Friday, July 17, 2009

DIY: How to Replace Subaru Forester Spark Plugs

It has been 30K [km] and almost a year since my last spark plug change (That was first for me). So, today i bought four NGK Spark Plugs from one of (Official Service) Subaru Dealers in Ankara and replaced them.

For now this post is copied as is from Wikimechanist.
The upcoming posts that can be named as "mechanic" will be posted only to Wikimechanist.




1 - Remove air filter elements going to the air filter to get free space:





2 - Remove Spark plug cables:





3 - Remove Spark plugs with suitable socket. That is 16 mm.
Also you'll need torque wrench to tighten with proper torque. If you have not one. Turn spark plugs 1/2 to 1/4 turn after contact occurs.








The previous change was 30K [km] before. You can see the old and the new spark plugs. The clean one is new of course. It must have 1 - 1.1 mm gap. If not adjust it.



For the driver side plugs, you need to remove window washer water container.
But not fully removal is needed. You may fix it with some elastic holders after turning it a little. You may have enough space to handle replacement of spark plugs.



Update (02.01.2010) some pictures for driver side plug removal:





Good luck.
It is pretty easy. Just half an hour for me.

Labels: ,

Friday, July 10, 2009

Forester arka camındaki örümcek ağı

Labels:

Thursday, July 09, 2009

How to Change Rear Differential Oil of Subaru Forester

Step 1: Lift up vehicle a little bit. Since you'll need some free space to handle 24'' wrench to loosen the differential 1/2" plugs.



Step 2: Loosen the upper plug first. If you can not be succeed still you will have a chance to call mechanic. Otherwise the lower plug will drain the oil.
The oil will start to bleed a little. Put your waste oil container below the plug.





Step 3: Now loosen the lower plug and drain the full oil.



Step 4: Differential needs 0.8 liters of 75-90 GL-5 performance level oil. You may need a plastic pipe to reach differential. I choose a plastic container and put a pipe on it. Fill up the differential till it starts bleeding from the upper plug hole.




Tightening torque for the plugs: 49 NM
Thnx to:
subruforester.org

Labels: