Skip to content →

Daoyuan Li Posts

C a[i] vs i[a]

When following the MIT 6.828 open course, there’s one C source code discussing pointers in Exercise 4 of lab 1.

There’s one line of code in pointers.c:

3[a] = 302;

Looks weird at first sight; but TCPL says in Chapter 5.3:

In evaluating a[i], C converts it to *(a+i) immediately; the two forms are equivalent.

So: a[i] and i[a] are equvalent (if i is a constant). 🙂

Leave a Comment

i386-jos-elf toolchain on OS X Lion

Yesterday friend and I decided to follow the MIT Operating System Engineering course together in order to get a deep understanding of OS’s. And today I started setting up the cross compling environment for the labs. At first I wanted to get the toolchain from macports, but unluckily it didn’t successfully build binutils on my Mac. As a result, I started building the toolchain from the source code, following the instructions at http://pdos.csail.mit.edu/6.828/2011/tools.html.

The programs you need for the toolchain include binutils, gcc, and gdb. For compiling gcc you also need GMP, MPFR, and MPC. The source codes are available at:

wget http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2
wget ftp://ftp.gmplib.org/pub/gmp-5.0.4/gmp-5.0.4.tar.bz2
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.0.tar.bz2
wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-4.5.1/gcc-core-4.5.1.tar.bz2
wget http://ftpmirror.gnu.org/gdb/gdb-6.8a.tar.gz

Unzip them in a directory and build binutils, gcc, and gdb one by one.

$ tar jxvf binutils-2.21.1.tar.bz2
$ cd binutils-2.21.1
$ ./configure --target=i386-jos-elf --disable-nls && make && sudo make install

In order to build gcc, GMP, MPFR and MPC needs to be built first.

$ mkdir -p libs/install
$ mv gmp-5.0.4.tar.bz2 mpfr-3.1.0.tar.bz2 mpc-0.8.2.tar.gz libs/
$ tar jxvf gmp-5.0.4.tar.bz2
$ mkdir gmp-build; cd gmp-build
$ ../gmp-5.0.4/configure --prefix=$(cd ../install && pwd)
$ make && sudo make install
$ cd ..
$ tar jxvf mpfr-3.1.0.tar.bz2
$ mkdir mpfr-build; cd mpfr-build
$ ../mpfr-3.1.0/configure --prefix=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/ --with-gmp=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/
$ make && sudo make install
$ cd ..
$ tar zxvf mpc-0.8.2.tar.gz
$ mkdir mpc-build; cd mpc-build
$ ./configure --prefix=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/ --with-gmp=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/ --with-mpfr=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/
$ make ; sudo make install
$ cd ..
$ tar jxvf gcc-core-4.5.1.tar.bz2
$ mkdir gcc-build; cd gcc-build
$ ../gcc-4.5.1/configure --target=i386-jos-elf --disable-nls --without-headers --with-newlib --disable-threads --disable-shared --disable-libmudflap --disable-libssp --with-gmp=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/ --with-mpfr=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/ --with-mpc=/Users/daoyuanli/Downloads/i386-elf-gcc/libs/install/
$ make ; sudo make install

Note that it’s essential to build gcc in a directory different from the source code directory to avoid compiling errors.

Then make gdb:

$ tar zxvf gdb-6.8a.tar.gz
$ mkdir gdb-build; cd gdb-build
$ ../gdb-6.8/./configure --target=i386-jos-elf --program-prefix=i386-jos-elf- --disable-werror
$ make && sudo make install

QEMU is available in macports:

$ sudo port install qemu
15 Comments

Port already in use issue of Arduino for Eclipse plugin

When uploading with avrdude the plugin give a error prompt saying “Port already in use” (while no other application is using the port). After clicking OK it actually uploads the program to Arduino board.

port_in_use

After reading issue #6 I check the librxtxSerial.jnilib in eclipse:

.cp$ file librxtxSerial.jnilib
librxtxSerial.jnilib: Mach-O universal binary with 4 architectures
librxtxSerial.jnilib (for architecture x86_64): Mach-O 64-bit bundle x86_64
librxtxSerial.jnilib (for architecture i386): Mach-O bundle i386
librxtxSerial.jnilib (for architecture ppc7400): Mach-O bundle ppc
librxtxSerial.jnilib (for architecture ppc64): Mach-O 64-bit bundle ppc64

While in my Arduino application the librxtxSerial.jnilib output is:

llibrxtxSerial.jnilib: Mach-O universal binary with 2 architectures
librxtxSerial.jnilib (for architecture i386): Mach-O bundle i386
librxtxSerial.jnilib (for architecture ppc): Mach-O bundle ppc

So I just copied the Arduino.app//Contents/Resources/Java/librxtxSerial.jnilib file to eclipse/configuration/org.eclipse.osgi/bundles/419/1/.cp/librxtxSerial.jnilib It works after restarting eclipse. No error prompts are shown.

Leave a Comment

Summary of 2011 and New Year’s Resolution

This year is approaching to its end at such a high speed that, before I realize it, there’re barely ten days left. It has been a busy and fruitful year for me. And it started quite well, too. I believe it’s beneficial to summarize what has happened so far at this point, now that I’m waiting to go back home and enjoy my winter vacation in one and a half hours.

It began with the confirmation of being in love with my lovely girlfriend in the beginning of this year (or rather end of last year). It was hard to keep this relationship especially most of the time we are thousands of kilometers apart from each other. We have had problems and had argued and blamed each other. Luckily we went through those hard times. Now although she is still two hour’s flight away from me, we are making some progress. The progress reflects of course not only in the distance, but also in the expectations towards and understandings between us. I’d say to myself: “you’re not doing perfectly, but not terribly either. Keep improving.”

This year also marks the beginning of my career. I was fortunate enough to get position at Ericsson to do my thesis and be offered a contract when I was finalizing the thesis work. The work was not perfect neither, to be frank. I’m not gonna lie to myself, but I wished I were treated equally when doing my thesis, for example, it would have improved my moral a lot if I had been offered a salary for my thesis work. And it would definitely help a lot if my work gets fully and really appreciated. I understand it was the problem of both others and myself; I was not doing my best. I should have done a better job by not caring too much about what others do and think. Anyway in all I think this is a good start of my career despite of some of the downsides.

I finished my thesis in time and got my master’s degrees — a degree from Aalto and one from KTH. It’s not so difficult to get two, but people are often amazed at the fact.

I also did something ‘crazy’ — cycling for around 1,000 kilometers from Espoo to Rovaniemi, a town in the arctic circle. Looking back, it was not difficult, but I was glad that I did it. Though many others are surprised at that, I do not see the meaning of doing that. — “But why do one has to bother the meaning of doing something?” I also tried to put on some weight and succeeded. I went to the gym for around two months with a colleague and successfully gained around five kilograms. I guess that was the first time when my weight has exceeded 120.

Looking forward, I have a few resolutions:

First of all, getting myself heard. This involves not only improving my english and language skills, but also expressing my feelings. I need to convey my ideas, my emotions, and my interests to others, so that hopefully they will see to it that I’m no longer ignored. I have also set some concrete goals for the next year: 1) talk to at least five persons face to face each day. 2) Get some publications and patent approved. 3) Pass at least two Ericsson’s internal certifications.

Secondly, improve my professional competence. I’ve targeted my competence as efficient and quick programming, especially in networking protocols. I also need to recap the complicated but efficient data structures and algorithms.

Thirdly, take good care of my physical and psychological health. I should resume going to the gym.

Last but not least, giving more time to the ones I love — my family and my friends. They’re one of the most important things in one’s life, if not THE one.

I shall keep all the determinations in mind and come back to them regularly, and monitor the progress of executing all these tasks.

Leave a Comment

Finnish Christmas Food

One colleague said that he felt lucky because they don’t have to eat the traditional Christmas food any more. But I think the food is not that bad, at least the salad is quite good. Especially the salty and sour and sweet herings, they taste delicious.

christmas_food1

christmas_food2

Leave a Comment

iCal crashes with iCal Reply Checker uninstalled

My iCal crashes everytime when someone sends me an invitation and I try either to accapt or decline it. After some investigation I found out it is the problem with “iCal Reply Checker” at http://www.nhoj.co.uk/icalreplychecker

After unstalled this app, it resets the Mail.scpt file to an empty file. To solve the problem: get another copy of Mail.scpt from another Mac, preferably from the same OS X version; and put it inside the folder: /Applications/iCal.app/Contents/Resources/Scripts

Lesson learnt: take care when trying amature software.

9 Comments

Cycling from Espoo to Lapland

An overview of the whole route:

Route to Lapland

7.1 Sunny Temperature 28 – 42+ °C

Route: Otaniemi, Leppävaara, Vantaa via Route 145 and 140 to Kerava and Lahti, around 130 km

day1

Today is the first day of my trip to hunt Santa Clause (because I haven’t recieved any gifts from him for the last 24 years). We (me and my French friend Gaëtan) started at 8:30 in the morning. The weather was a bit hot: around 28 °C even in the morning. It was until we arrived at Leppävaara when I realized I forgot to bring my bottle and tooth brush with me. Since it was not good to go back and fetch them, I decided to ride on and buy the necessary stuff in
Lahti.

We went via a road close to Vantaa Airport, where we saw planes around 50 meters above us. There were fields full of rape flowers, astoundingly beautiful under the sunshine.

We stop at around 12:30 for lunch, about 75 km from my home. After lunch we rested a bit and restarted at 14:00. It was even hotter in the afternoon; the temperature reached more than 42 °C at 5 pm. There were some slopes when entering Lahti; some slopes as well in the city. One
cyclist encouraged us with a thumb up; while one guy in a car at Lahti downtown showed us his middle finger. I guess some Finns don’t like foreigners. We bought some food in Lahti and refilled our bottles at a bar next to a gas station. At around 6 pm we arrived at a lake and found a camping place among the trees. We put up the tent on a small road leading to a farm field and went to swim, because there were too many mosquitoes in the woods. Unfortunately the bottom of the lake is
covered my mud; but it was OK just near the shore. The temperature of the water is just perfect. So we washed ourselves and then had dinner. There were a lot of fish in the lake. Some of them have red wings and tails and they were standing with their heads down in the water.

It was around 8 pm when we tried to have a rest in the tent. However, it was too hot. The temperature was around 28 °C and the sun was still hanging in the sky baking the tent. Outside the tent it was not
so hot, but there were mosquitoes trying to kill us. I stayed in the tent and it was until an hour later when the temperature was comfortable. Besides the high temperature, the humidity was also high. It was difficult even to breathe. There were kids playing in the water and making a lot of noises till 11:00 pm. Finally I felt asleep after 12:30 am. It was not a good sleep. My sleeping bag kept me too warm and there were mosquitoes in the tent.

7.2 Sunny/Cloudy/Overcast Temperature 28 – 42+ °C

Route: Lahti to Asikkala via Route 24 and Roads 3131 and 313, to Virtaa and Otamo via Road 314, to Sysmä via Road 410, to Luhanka via Road 612, to Putkilahti via Road 610, around 125 km

day2

We started again at
8:30 am today. It was as hot as yesterday. There was a field full of rape flowers again. The road began to be bumping. There were a lot of slopes since we were entering Middle-Finland (Keski-Suomi). There were a lot of lakes as well. On the way to Sysmä there was a part (around 5 km) of a road with water on both sides.

water-both-sides

We had lunch on a dock for motorboats near a gas station. There were lotus leaves and flowers on the water. Not surprisingly, the bottom of the water was also covered with mud. Gaëtan didn’t mind and swam in the water twice, once before lunch and once after. There were people driving there motorboats to the dock in order to refuel at the gas station. I noticed especially on old couple in their 50s. When the husband was refueling the tank, the wife stood on the dock and
watched her man with a constant smile on her face. They didn’t speak much but you could feel their love for each other. We rested a bit after lunch and started again a few minutes past two.

In the afternoon it was even hotter. Besides the high temperature, the slopes also made it difficult to cycle. When we were approaching Luhanka, the newly paved asphalt roads nearly melted and it was extremely difficult to move on. Anyway we had to because we have to buy food ahead in
Luhanka. Luckily we arrived at Luhanka 40 minutes before the shop closed (6:00 pm for Saturdays). The price was a bit expensive but we felt lucky to find one shop. The town was tiny: in Luhanka center there were one shop, two restaurants, one gas station, and a parking space for around 10 cars. When we were leaving, one guy in the restaurant waved goodbye and gave us a thumb up.

We had dinner somewhere beside Road 612 and moved on shortly, since there were mosquitoes. We did
another 10 km before we found a place to camp. We put up our tent beside a big lake and swam in it. The water was perfectly clean and the temperature was quite OK. It rained before we arrived at the place, as a result, almost no mosquitoes were found. When I was about to go into the tent, there was a motorbike fleet passing by on Road 610. There were almost 50 motorbikes. It seems that Finns are fond of noisy motorbikes.

7.3
Overcast/Rainy Temperature 15 – 25 °C

Route: Putkilahti to Korpilahti via Road 610 and Route E63, to Petäjävesi via Road 607 and Road 604, to Multia and Karstula via Route 58 (European Highway E18) , around 150 km

day3

The road became more bumping. There were a lot of slopes
and I reached my top speed in my biking career: around 60 km/h. We were diving more into the country side and around 20 km of Road 607 was not paved. This was the “take-me-home”-kinda country road. There was a lady walking her dogs with her apron on. There were a lot of sings warning uneven road. Gaëtan was half serious: “it’s funny that they don’t know what is flat”.

src=”images/stories/blog/BikeToLapland/uneven.png” alt=”uneven” width=”235″ height=”164″ />

We didn’t rest a bit after lunch because it was too cold. I was wearing my jacket and wasn’t sweating. We stopped at around 7:00 pm and put up the tent beside a field. It was so cold that we had dinner in the tent.

7.4 Overcast/Sunny Temperature 15 – 25 °C

Route: Karstula to Kivijärvi, Kinnula, Yli-Lesti Route 58 (European Highway E18), to Reisjärvi via Road 7594, to Sievi via Road 760, around 155 km

day4

It was still cold in the morning and I was wearing my jacket. We did around 85 km before lunch and arrived at Kinnula. This small city even has a small stadium
with less than 100 seats. Two high school girls were teaching a bunch of 5 year olds to play Finnish baseball. We had lunch watching them play and had a rest on the bench for half an hour after lunch. When we were about to leave, one girl came to talk with us. She told us there are roughly 1800 inhabitants in the city and they have a high school as well. Their high school has 55 students. She also told us Finnish baseball is more popular than football in Kinnula, when I asked why the seats
are arranged on the baseball field instead of the football field.

We changed our route to Road 7594 to Reisjärvi instead of following Route 58 to Lestijärvi since we thought that would be a shorter route. It was shorter, but Road 7594 was not paved. The road condition was better than Road 607 yesterday, but it was still a bit bumping. At some point my mattress fell off from my bike, fortunately a truck driver coming towards us saw it and notified Gaëtan with
gestures. Gaëtan didn’t know what the driver meant at first, but he followed back and found the mattress. I was lucky! We were in the country side but there were houses every half a kilometer. Most families have two cars and their houses are mostly made of wood. School buildings are made of concrete though.

Afraid of not being able to get to Sievi in time, we bought some food in Reisjärvi. They are paving roads with asphalt there, and there are people in the
intersections holding “STOP” signs in order to warn vehicles. We arrived at Sievi at around 8 pm and Gaëtan went to buy some more food. He was tired and didn’t want to go further. So we found a place to camp. When I stopped, I felt something on my legs. At first I thought it might be grass, so I moved my legs a bit. It was still there. I looked down and found around 20 mosquitoes on my legs and more were coming. We jumped onto the bikes again and stopped at another place.
There were still many mosquitoes. We were jumping while trying to get our mosquito protection spray. It was better after we had applied the spray. But it was really scaring to think about those crazy mosquitoes. They probably were able to kill someone!

Gaëtan said he was impressed because we were totally one day ahead of schedule and we were already close to Oulu.

7.5 Overcast/Sunny Temperature 25 – 35
°C

Route: Sievi to Ylivieska via Route 63, to Oulainen, Vihanti, and Liminka via Route 86, around 140 km

day5

We started at 8:00 in the morning and had lunch near a gas station in Vihanti. Route 86 was a bit dangerous since there were many cars and trucks on the road. They
generally ran somewhere 80 to 100 km/h. There were also many caravans in both direction to the north and the south. Maybe some people were heading for a vacation while others had finished their vacation. There were a lot of bus stops on every road. I almost ran over a squirrel, but it escaped from death by a 30 cm margin. However, there were usually dead squirrels, rabbits, or even birds on the road. Humans are a great thread to animals’ lives.

After lunch we had a
rest on the grass. It was sunny and warm and I fell asleep. I even had some dreams in my 30 minute sleep. We bought food in Liminka and planned to camp by the sea shore. However on our way we found a place indicating a swimming place in the other direction. Strangely, there were no lakes or rivers around. Gaëtan went there to figure what that was and came back very excited: “I found a paradise for camping!” I followed him there in Tupos and it turned out to be a swimming
pool. There was even artificial beach and a toilet! But when we arrived there were a lot of kids swimming there. We changed and jumped into the pool. I was too shy to take out my lotion to wash my body, but Gaëtan took his soap, went to the other side of the pool where no one was swimming, and washed himself and even his shirt.

tent

I wanted to wash
myself when no one was there. So I had dinner first. There were a lot of mosquitoes. In order to protect myself, I buried my legs in the sand. Gaëtan thought of something more novel: he had dinner standing in the water! Still there were mosquitoes trying to attack my arms and head. I killed around 50 mosquitoes in half an hour. I waited until almost everyone had left and the washed myself with lotion. It was already around 9 pm and it was a little cold.

style=”background-color: #ffff00;”>7.6 Overcast/Sunny/Cloudy/Rainy Temperature 25 – 35 °C

Route: Tupos to Oulu, Haukipudas, Ojakylä via Road 847, to Ii, Olhava, Simo via Highway 4/E8/E75, to Ranua via Road 924, around 160 km

day6

I woke up feeling uncomfortable in
my throat. We went through Oulu and it was difficult to find our way in the city. We went on Highway number 4 before Ojakylä. There was about 1 meter’s space left for us, but it was not safe since vehicles were running at 100 km/h.

highway

We entered Lapland from Simo and bought food there. After that we went on Road 924 towards Ranua. There
were not many people in Lapland. There was a part of the road where we biked more than 10 km without seeing any houses.

plane

There was a sign showing a plane that confused me. We were far away from any airports and I was like WTF when I saw the sign. After a while the road became extremely wide, to around 30 meters. Then I thought that they
might be building a new airport. (The Finnish sentence below the plane translates to “road will be closed shortly”)

airport

runway

We saw a triple rainbow at the “airport”, though in the
picture only two are apparent, the lower one is actually made up of two rainbows.

rainbow

We kept cycling because we are afraid of bears and wolves, since there were no people living by the road. We felt extremely tired when we finally found some houses. It started raining immediately after we got off our bikes.

7.7 Sunny Temperature 25 – 35 °C

Route: Ranua to Rovaniemi via Road 924 and Route 78, around 110 km

day7

My mattress was not inflated when I woke up. But fortunately today was the last day for me. I was planning to give it to Gaëtan since
his broke down in the first day of our trip.

My knees were painful but I had to move on. On Road 924 we saw some animal standing in the middle of the road about 200 meters away from us. It was not afraid when a car was coming to it. Finally when the car was just 20 meters from it and was trying to slow down, it slowly jumped off road. We rode forward and found out it to be a reindeer. What was she doing in the middle of the road? Sun-bathing? It was not afraid of us at all. By the
side of Route 78 we also saw many reindeers.

When I was about 50 km from Rovaniemi, I started thinking why I was doing this (biking to Lapland) in the first place. This was my typical behavior. What did this week bring to me? Has all of this been meaningful? Then I became sad, just as every time when I think about what I have been doing. However, as I thought and thought, I realized that there might not be meaning for everything one do, at least for the moment when he’s
doing that. The point is to try to finish the things I have started in a graceful way, regardless they’re meaningful or not. It does not take much to finish something when it’s 99% done. All you need to do is to keep fooling/believing yourself as what you have been doing before. Maybe this is the most important lesson I’ve learnt during this trip.

rovaniemi

We did 90 km in the morning and arrived at the railway station of Rovaniemi before lunch. I bought the ticket and paid. Then I realized I didn’t ask for a student discount. So I showed the lady my student card and she gave me back 40 euros. Maybe I was just too tired or too excited.

We had lunch on the grass beside the railway station. Then I handed over my tent, tools, and Gaëtan’s bottle to him. We went to Santa Clause Village
together and took some pictures beside the Arctic Circle – Mission almost accomplished, except that I was too tired to hunt Santa Clause anymore; maybe next time! Gaëtan continued further north. Wish him luck.

arctic

The whole route.

Leave a Comment

Back on bike

I haven’t cycled much since my previous bicycle was stolen in Stockholm last year, which ruined my plan of cycling from Stockholm to Helsinki. Now I’m planning something similar: I’m cycling from Helsinki to Lappland — not so big deal compared with the previous plan, but still better than nothing.

In order to prepare for the journey, a French friend and I went to Porvoo, a small city around 50
km to the east of Helsinki. It started well, the weather was not perfect but except for the drizzling part it was all right. Then it started raining heavily and we got somewhere in Helsinki. After we were finally able to locate our position it turned out a part of the route was closed due to construction. Fortunately we managed to find out another path and rode all the way to the destination. In total the 60 km journey took us 4 hours, including the time wasted in Helsinki, not bad at
all.

My friend’s new raincoat was in pieces one hour after he put it on. This may be too obvious: it was made in China.

Immediately after we arrived at a park near the city center of Porvoo, a young lady approached me and said ‘moi’. I ‘moi’ed back and then she started speaking Finnish to me. She talked for around one minute and stopped, looking at me. I replied, “Anteeksi, en puhu suomea.” She seemed embarrassed and asked if I speak English. It turned out she was
writing an article about the park and wanted to know my opinion on it. I felt flattered (come on, a journalist was interviewing me :D) and complimented on the park. We talked a bit about the park and she asked our names and took some pictures of us. I couldn’t help to be excited when I thought of I’d appear on some newspapers or magazines — first time indeed.

After lunch we spent half an hour visiting the old town. There’s not much to note down, except that I met an American
in the church and he speaks Chinese. Around 1:30 we got on our bikes again and headed back. It was much more difficult since we were riding too fast in the morning and felt tired once we got on the bike. Headwind made it harder. But I was motivated by a cyclist on the road. He stopped us asking the road to Porvoo. I gave him my map and asked where he was from. He said he was from Hanko and had been riding for 20 hours… How crazy was that? Anyway it took us more than 5 hours to get
back. And I couldn’t feel my ass after I arrived at home…

It was really quite an experience. We survived the rain, unfamiliar route, headwind and physical exhaustion. In the following weeks I’d do more exercises, if I want to survive the 1000 km journey.

PS. Porvoo is quite, as anyone would expect for a city with a population of 35,000 (source: the journalist).

porvoo

Leave a Comment

Bug in Waspmote API v0.15

I found a bug in Waspmote API v0.15 when I was trying to set XBee link keys. The API failed to set the key as specified in the code. The bug lies in function gen_data()” in lines 4355-4403. Details below. However, it was corrected in v0.18.

/*
 Function: Generates the API frame to send to the XBee module
 Parameters:
 	data : The string that contains part ofthe API frame
 	param : The param to set
 Returns: Nothing
 Values: Stores in 'command' variable the API frame to send to the XBee module
*/
void WaspXBeeCore::gen_data(const char* data, uint8_t* param)
{
	uint8_t inc=0;
	uint8_t inc2=0;
		
	clearCommand();
	it=0;
	while(data[it] != '\0') {
		inc++;
		it++;
	}
	inc/=2;
	
	while(inc211) 
	{
		for(it=0;it<8;it++)
		{
			command[inc-9+it]=param[it];
		}
	}
	else if(inc==11)
	{
		for(it=0;it<3;it++)
		{
			command[inc-4+it]=param[it];
		}
	}
	else if(inc==10)
	{
		for(it=0;it<2;it++)
		{
			command[inc-3+it]=param[it];
		}
	}
	else command[inc-2]=param[0];
}

The function in v0.18 is as follows:

/*
 Function: Generates the API frame to send to the XBee module
 Parameters:
 	data : The string that contains part of the API frame
 	param : The param to set
 Returns: Nothing
 Values: Stores in 'command' variable the API frame to send to the XBee module
*/
void WaspXBeeCore::gen_data(const char* data, uint8_t* param)
{
    uint8_t    inc=0;
    uint8_t inc2=0;
		
    clearCommand();
    it=0;
    while(data[it] != '\0') {
        inc++;
        it++;
    }
    inc/=2;
	
    while(inc2

Leave a Comment

Generating UML diagram from Java source code

Sometimes we may need to generate UML diagrams from source codes. Here’s what I do for Java code: graphviz + ant + UMLGraph. Details below:

1. Install graphviz and ant, download UMLGraph from http://www.umlgraph.org/

2. Place UMLGraph.jar in your project, for example, under
lib/

3. Write or modify your ant script, for example:


   
   The specification for the Java-based umlgraph build processes.

 
   
   
   
   
   
   
   
 
   
       
       
       
       
       
       
  
 
   
       
           
               
               
                   
               
          
           
       
   
 
   
       
           
               
               
                
               
               
               
               
               
               
               
          
       
  
 

4. Run this ant script.

ant javadocs

5. You will get the UML class diagram as expected in the generated Java docs. Here’s one example (click to enlarge):

com.andryy.hccdroid

Leave a Comment

A walk on the sea

Just took a walk literally “ON” the sea since the water was completely frozen.

It was my third time walking on ice.

The first time was in Kiruna, a small town in the arctic circle in northern Sweden. We were walking on a lake and the guide told us to keep a distance from each other, so as not to break the ice and get ourselves frozen in the lake. It made us all nervous but in the
end I found him to be kidding. You can even drive trucks on that. On the way back the guide drove the van onto a lake and showed us how it was like to drift on ice.

The second time I was walking on the shore around Otaniemi and found many Finns skiing or ice fishing on the sea. So I walked on it with great care, and found out it was quite safe to walk there.

This morning I was originally planning to take a walk along the coast line. But then again I found some guys
playing on the sea. So I stepped out on it. At first I was a bit afraid, after all we were getting positive temperatures in the past few days. But after a while I was sure that there was nothing to be afraid of. I jumped on the sea and nothing happened. Besides, walking on the sea is much easier than walking on the road. Walking on the sea is like struggling in a swamp, as snow could be very thick at some points; while walking on the road was like dancing Waltz on a mirror, because the roads
are covered with ice and a very thin layer of fresh snow. And this time I used GPS to track my location and ended up with the following trail.

sea_walk_2

The whole trail is 7 kilometers and my average speed was 4.39 km/h. But the top speed was 13.36 km/h because I was chasing by a shark. LOL.

Another picture:

Leave a Comment

Take a break

Only three months to go before I have to deliver my thesis. It’s supposed to be 9-month work but I have to complete in less than five months; otherwise I’ll have to pay expensive tuition and enroll for the next academic year. When you receive something you need to give away some at the same time.

We have EU founding to support our studies; in return we have to stick with one study program and
complete the study in time. For these kinds of programs there’s not so much flexibility compared with other self-founding programs. At KTH I had the most boring courses in my life. All I had to do there is to configure routers. It would be fun when you have one of these courses; but having more than half of the curriculum trying to teach you to design a network was like forcing soldiers to stay in lecture halls listening to all kinds of theories all day long. It’s sick; it’s not what
you are expecting.

But anyhow technical stuff in school life should not be the most important. It’s a whole new world and I wouldn’t force myself into something one can learn anywhere. Apart from the boring studies, life in Sweden and Finland is better than anyone could expect. There’s beautiful nature, multicultural environment and nice folks everywhere. One of the most important reasons I love here is how people enjoy life. No one seems to be pushing you
forward; no one tries to persuade you into doing something;
 you don’t have much pressure saving money in order to buy an apartment; you are away from people’s nagging of what you should do and what you shouldn’t. It is just comfortable, cozy and easy to have a life as such.

Eat when you are hungry; drink when thirsty; rest when tired. Simple rules often work best. Seize the day.

I don’t need to worry about anything since I know somehow
I’ll finish the thesis in time. And I even don’t care how exactly I’m gonna do that. But I will.

Enjoy as much as possible, even if you are doing research. 🙂

node_smiley

2 Comments

We need a talk

Weird, I’ve been thinking talking with people isn’t actually a waste of time. During the past few days I’ve been talking with people and it turned out to be quite pleasant experiences. You get to know people when you start a discussion.

I didn’t know Bangladesh was called East Pakistan 30 years ago. Yea I knew India, Pakistan and Bangladesh used to be one whole country under the
jurisdiction of Great Britain. I got to know India was divided into three when I was discussing with some classmates last year. But I never realized Pakistan and Bangladesh used to be one country. It was refreshing to know that when I was talking with one Pakistani today during lunch.

Earlier I’ve heard of rumors on how Jews are ruling America and why Obama was chosen to ease the anger or suspect of the people; I’ve heard of how Mao Xinyu has been pretending to be a fool
so as not to be banished or killed; I’ve heard legends of how masters of Mahjong observe on the table and connect players’ behaviours to their fates…

I’m not sure if all of those still stand against existing evidence or just logically correct, still it doesn’t stop me enjoying these rumors. They open my eyes and enable me to think from different perspectives. As I see it, this is one of the most beneficial factors one could have out of China, besides the
accessibility of YouTube, Twitter, Facebook and porn videos. In China people tend to think the same and behave the same. “One (unrealistic) dream, one (occlusive) world.” Uniformity is always the rule of thumb. But here, at least in Europe, you feel individuals bear vastly different opinions over the same issue. Most importantly they are not afraid of speaking out their minds. You understand them better; the communications with Europeans are easier than with Asians for me. In some
occasions I’m just fascinated with their thoughts; their ideas are sometimes peculiar but always refreshing.

Frequent exchanging of ideas helps us to be understood better. The other day the French guy asked me if it’s a joke when we say we don’t have access to Facebook. When I replied yes he seemed shocked. It could be difficult for him to figure out why, but having this in mind may help him understand how terrified of the external world.

I was feeling weird because I
always thought talking and communicating with people is useless, or not so efficient at best, compared with reading. Now I’ve got a new figure. It’s nice to talk with people. It’s necessary to get a picture of others’ thoughts and make yourself understood. So let’s talk.

Leave a Comment

Beautiful world

Now we are starting to have positive temperatures here. The weather is just gorgeous everyday. The breeze is fresh; the sky is clear; the sun is shining. You feel warm inside out. You can clearly see how people are smiling: their brows flying upward and eyes narrowed — that’s how you smile under the sunshine, isn’t it? You could even see reflection of bright teeth once in a while. It’s just as cozy
as one could possibly imagine.

The snow starts to melt but the roads are still slippery and reflexive. Even so it doesn’t stop people coming out doing exercises and enjoying life. All kinds of people, old or young, chubby or skinny, are jogging or doing Nordic walking in tights. Though at times you can notice white steam coming out of people’s mouths, it doesn’t make you feel chilly. Instead you get a burning feeling as if you have joint them doing exercises; it’s like
there’s a flow of energy inside you trying very hard to burst out.

The French guy across the corridor has already started wearing shorts. The first thing he said when he saw me was: “Its hot!” As a matter of fact, it is, since inside the office it was around 30 degrees. And as the sunshine flows inside, you feel it’s already summer time.

I opened the window, fresh air pours in. Closing my eyes, I could feel the cool air moving from my cheek to the neck. It’s just
amazing.

All of a sudden you hear birds singing; they are not owls; it’s like canaries’ chirps up from paradise. I looked out trying to figure out where the little spirits were, but with no success. Maybe they are in paradise; you never know. I’ll just leave them alone, enjoying their divine melodies with a grateful heart.

What a wonderful world. 

P.S. I have to admit it’s damn hard to write a descriptive essay; this is the best I could come up
with right now.

P.S.2. I love Louis Armstrong’s “What a wonderful world”.

Leave a Comment

Mobile fantasies

This morning I was going to work with Rasib and we had a little chat on mobile phones. He told me that people in Bangladesh would be willing to pay months’ salary to buy fancy cell phones. Some dudes are so insanely crazy that they have good shiny mobiles, but they cannot even afford to pay subscriptions. It’s funny to picture someone carrying an iPhone while not being able to talk over it, instead he
goes to public telephones to make a call…

Earlier I’ve read similar stories with Vietnamese. They spend a fortune on mobile phones that may bring them self-assurance. To think a bit, maybe people are not so irrational when we look upon ourselves. As a matter of fact we all do the same thing every now and then. Buying fancy clothes and boots than one should; attending not-so-affordable high-class universities; humiliating oneself so as to get in some community,
etc.

The common thing behind the scene is that we spent more than we could afford to get such a feeling that we are important, or at least as important as others, if not more important. We are eager to get ourselves recognized all the time by pretending to be more respectful than others. Failing doing that, we may at least try to tell ourselves apart from the ‘losers’.

But what’s a loser anyway? Paying more than one could possibly afford doesn’t look like a winner’s
behaviour for me. One may look great doing that, taking away the fact he may be feeling miserable at the same time. People are always pretending to be someone else, at last they are confused and insecure and lost in others’ images. Isn’t that pathetic?

Using iPad doesn’t make you Steve Jobs; wearing black frame glasses doesn’t make you an art director, no matter how hard you try. You’re just yourself and no one else.

Leave a Comment