Sunday, November 29, 2015

Raspberry pi - prepare for Kernel Space Programming

Raspberry pi is one of the most popular SBC in market with ARM processor. It is very popular among students for playing as embedded stuff.

There are few points, need to noted down, while working or playing with Raspberry pi.

1. SDCard shows 56 MB, while I've 4 / 8 / 16 GB etc.

The reason, windows cannot read the actual size of SDCard is, its reading only the boot partition. To get rid of this problem, its advised to use SDFormatter.

2. Which image to Install ?

Default Raspberry pi gives two type of installation image.
        1. NOOB -- completely for beginner. I'd say for those who have no / less knowledge about linux.

        2. Raspbian -- A good place to start learning with Raspberry pi. Usually WHEEZY image is popular as starting. If you've smaller SDCard, and no requirement of Desktop, you may choose Jessie Lite minimum version.

Sunday, November 22, 2015

ERROR - vSphere Client could not connect.

if you are running ESXi 5 / 5.5 [ I've experience only these two], you probably experience error as below image, with error message -

" vSphere Client could not connect to "XX.XX.XX.XX". An unknown connection error occurred. (The client could not send a complete request to the server. (The underlying connection was closed: An unexpected error occurred on a send.)) "

Saturday, November 7, 2015

Hadoop changes on Single-Node Cluster Installations

There are many notes about HADOOP single node cluster installation, mostly in Ubuntu machine. All of them I've seen worked. But as time passed by, hadoop developer also made some structural and logical changes to fit the application better.

Here I wish to sum-up those changes (e.g. change of conf, file structure etc.) so newer user would get required commands or files easily while doing HADOOP signe node installation.

first to download hadoop =>
Best option is to search for nearest repository for hadoop from -

for me, below is the nearest

$ wget

Tuesday, October 27, 2015

XML or .osm special character issue and solution in C

You probably have experience while parsing openstreetmap .osm file - some name [TAG-NAME] appear as

C&C - which is in clear text "C&C". So while you are coding for a .osm or XML parser, it is important to consider such special character at XML specification.

If it need to present such value at literal form, it is important to replace those characters with some other clear text format.

For example, if it need to replace the above "&" a below C program can make an idea.

 char *special_ch_replace   
 (char *s, char ser, char rep)   
  char *p1;  
  for (p1=s; *p1; p1++)   
   if (*p1 == ser)  
    *p1 = rep;  
  return s;  

Saturday, October 3, 2015

C program to generate .osm[XML] with efficient memory management

It was a requirement to generate new .osm file with selectively extracted openstreetmap's data from a big file [e.g. a country / state .osm file].

Equally the requirement extended as no use of any pre-programmed library, only simple C programming and very importantly, the program should avoid -

1. memory leaking
2. buffer overflow
3. change of pointer address
4. extra memory allocation, and
5. efficient.

End output has to be something like this -

     <node id="73900462" lat="54.3884" lon="10.38285">  
         <tag k="name" v="Lidl"/>  
         <tag k="shop" v="supermarket"/>  
         <tag k="addr:city" v="Schönberg"/>  
         <tag k="addr:street" v="Große Mühlenstraße"/>  
         <tag k="addr:housenumber" v="51"/>  

The output will write to a file. Where, node_id, lat, lon, tag_value/s etc. will be dynamic.

Saturday, September 19, 2015

Parsing and splitting openstreetmap file [ C ]

Its quite bizarre to me, more I'm trying to friendly with string / character processing with C programming, they are showing their envy to me.

I was/am need to split a / any big osm file to three parts, NODE, WAY and RELATION. You can do that by giving line number range to program. But I want to get the line number automatically.

This was seems very easy, just counting the new line till getting required string, i.e. <way id=

So I wrote,

 char way_compare[] = "<way id=";  
 FILE *fp = fopen("Kiel.osm", "r");  
 char ckchr[10];  
 int count_line=1;  
 char chr = getc(fp);  
 while(chr != EOF)  
   if(chr == '\n')  
     {  count_line++;  
       fgets(ckchr, 10, fp);  
         { break; }  
     chr = getc(fp);  
   printf("Searched: %s found at %d\n",way_compare,count_line);  

Wednesday, September 2, 2015

Reading between two given line number of a File

 It is sometimes very important, to let program to read a big file only some specific part/s.

For example, I was and still trying with Openstreetmap with readosm library. Which really need such option.

As .OSM file is quite a large and readosm does read every single bit of the file, on other hand my projected implementation hardware is quite low in resources, badly needed to optimize readosm reading style.

I'd and still have a plan of doing indexing for .OSM file and apply program to read according it.

To do so, here comes the first part of virtually slicing the .OSM file and apply to program to read by given lines between.

My program is an extension of

Wednesday, August 26, 2015

Simple thing but difficult to find [ALSA wav file]

I was in need of ALSA and honestly, I'd just few testing style programming of it long before.

It need to take wav file as input and do a playback of that file using ALSA. However, I need to learn it form scratch, though to find any suitable example according how I can handle wav file to send as ALSA PCM playback, was difficult.

So I wish to write some explanation of it here, and will try to exclude those what you can find and learn by a short googling.

Below part, I presume you already know, or if you don't, I found -,0

         is the best and most informative.

Wednesday, August 12, 2015

GEO-Search - Faster approch between two point

Previous post, I port the calculation and formula from Federico

My search bring me another solution, which is more faster than previous ->

Below it is, [This one calculate for Kilometre]
struct arg_max_min_lo_lt

    double min_long;

    double min_lat;

    double max_long;

    double max_lat;

struct arg_max_min_lo_lt get_lo_lt_values()


        int eRadius = 12742;

        float radius=5;

        struct arg_max_min_lo_lt m_lo_lt_ptr;

        //each degree of lon or lat is approximately 69 miles or 111 kilometres difference

        double denominator = cos(deg2rad(curr_lat)) * 111;

        m_lo_lt_ptr.min_long = curr_long - (radius / denominator );

        m_lo_lt_ptr.max_long = curr_long + (radius / denominator );

        m_lo_lt_ptr.min_lat = curr_lat - (double)radius / 111;

        m_lo_lt_ptr.max_lat = curr_lat + (double)radius / 111;

        return m_lo_lt_ptr;


Friday, August 7, 2015

GEO-Search: The Haversine Equation

To calculate longitude & latitude of an area easiest way is to calculate The "Haversine Equation".
Implementation of this equation in various programming language was done at here ->

I port it in basic C programming ->

 #include <stdio.h>  
 #include <math.h>  
 double deg2rad(double lat);  
 int main()  
 double curr_long=-2.708077,curr_lat = 53.754842;  
 int radius=20;  
 double denominator = cos(deg2rad(curr_lat)) * 69;  // 69 as calculation in Mile
 double min_long = curr_long - (radius / denominator );  
 double max_long = curr_long + (radius / denominator );  
 double min_lat = curr_lat - (double)radius / 69;  
 double max_lat = curr_lat + (double)radius / 69;  
 printf("Minimum Longitude :%1.9f\nMaximum Longitude: %1.9f\n",min_long,max_long);  
 printf("Minimum Latitude :%1.9f\nMaximum Latitude: %1.9f\n",min_lat,max_lat);  
 return 0;  
 double deg2rad(double lat)  
 return 0.0174532925*lat;  

Wednesday, July 29, 2015

Eat insect - UN said.

So far I know and can guess there's million or could be billion of dollars are set on budget as expense for entertainment [food] for guest coming/working/visiting any / one UN office round the world. Current new advice came on board from UN to eat insect in order to have proper nutrition and to minimize food scarcity.

Lets have some hypothesis of such FOOD SCARCITY ->

1. In 2012 - 2013 total UN approved budget was $5.152 B.

2. If 2% of total amount has been used for food & related stuff (UN offices, for employee and guests) - $103.04 Million is in total.

3. Average annual budget for UNESCO is $326 Million. However due to US suspension of funding UNESCO is in shortfall of $188 Million.

So, we can make a corollary as, if UN follows its report, its possible to cover 60% of US contribution to UNESCO, which ensure better living with education, science and diversity.

Tuesday, July 28, 2015

Schleswig-Holstein & North Sea Tour

Last Sunday, actually a lot to do, but I cought with lazy disease. I can't sit, I can't type, I can't read, even I can't concentrate to movie - so I made Schleswig Holstein tour. And honestly speaking, I'm cured from disease.

My first stop was in Friedrichstadt, a very little Town, about 400 years old. Friedrichstadt is established by Dutch settler, and made it a little Netherlands with Canals and Dutch style buildings.

Interesting thing about the city is, it started with population more / less 2500 inhabitant and for decades maintain it, however still total inhabitant is around 2500.

Thursday, July 9, 2015

Asterisk & A2billing on production

I was thinking of this for long, to keep notes of my different works on Asterisk and A2billing in different time.

Many different problem I'd faced and put them in various places, that quite difficult to find now.

So, now I thought to put them in together and keep updating everytime, I'm updating anything. Which means, this blog, is elastic.

1. Today I was installing asterisk CDR viewer, the simplest CDR viewer for asterisk, and faced a problem like -
 my_load_module: Failed to connect to mysql database asteriskcdrdb on localhost.
 This problem is just placed in /etc/asterisk/cdr_mysql.conf