Posted by Tim
Filed under: Geek
To sleep or not to sleep
Today looked for a problem for about an hour which I thought might be worth sharing. The following (most likely common) scenario was to be implemented: one process wants to start another and be notified if something happens to the child process. The proper way to achieve this is to fork()
, then execl()
the new program in the child, and have the parent call wait()
to check for state changes of children.
Now, in I'd guess likewise common is to start with a test program that incorporates sleep(). Fail! After an hour it turns out that the sleep() call will block the SIGCHLD
signal (cf. sleep.c). But it does not unblock the signal afterwards. Since the wait()
call depends on SIGCHLD
, no event would be received
and wait()
would starve.
So either you need to unblock the signal after calling sleep()
, or better call usleep()
which does not suffer this problem (cf. usleep.c).
Posted by Tim
Filed under: Geek
Dead routers which did not die
In the last few months three routers I maintained died on me. All where little home routers. Two of them Asus WL-500GP, and recently a Fonera (first generation). The routers appeared to be live, but could not be reached, neither over Wifi nor Ethernet. The LEDs were lit or sometimes flashing. On the second router, one of the Asus ones, on a closer look it had some strange look, where all LEDs were off shortly, then back to seemingly normal. Sniffing on the Ethernet revealed some strange packages which contained the hex string 0xDEADDEAD and a message to boot into failsafe mode.
Now, to make a long story short: all the routers were just fine, what was indeed broken were the power supplies - on all of those three. Replacing the power supply brought the device back to normal in all three cases. I haven't made an effort to measure what caused this problem, but it seems to be insufficient current.
So next time a (home) router dies on you, consider borrowing a compatible power supply first and test the device again, it might save some money and effort, besides reducing the electronic scrap on the planet.
Posted by Tim
Filed under: Geek
Setup git tracking branch for existing branch
Something that I did many web searches is how to setup up tracking of a remote git branch for an existing local branch. That regularly happens for example if I start with a local topic branch, and then push it to the central repository. Now, git does neither automatically setup that this (new) remote branch should be tracked for the local branch nor did I find a convenient command or argument to do so. So here is what is required, assuming that the remote repository is named origin, the local branch is topicbr, and the remote branch is timn/topicbr, and you are in the local git repository:
git config branch.topicbr.remote origin
git config branch.topicbr.merge refs/heads/timn/topicbr
.
It's that easy and now I have a place to look it up next time I need it...
Posted by Tim
Filed under: RoboCup
Aldebaran Workshop 2010
I'm currently attending the Aldebaran RoboCup Workshop. It has its interesting points but obviously there is a lot of old stuff for new teams. You can follow me on twitter for fresh info on the new version of the Nao.
Currently there is a talk about the Nao motion module. Besides that I'm setting up the OpenEmbedded tool chain, again.
Posted by Tim
Filed under: Geek
Conquering the N900
Last week just at the end of the last decade (happy new year everybody btw) I got a Nokia N900 with the Linux-based Maemo 5 operating system. I have had an N810 for more than a year and was very pleased with the device, especially because I can write "normal" programs, i.e. programs running on Linux with the APIs I already knew from desktop apps. For example Fawkes is running just
fine on the device!
My first impressions after using the N900 are positive. It is still beta around the edges but it gives you full control over your device, including root access which just feels right. Here are some notes which might be useful and which I might need again.
Content Transfer from old Symbian (N76 -> N900)
My last cell phone was a Nokia N76. It has agglomerated quite some data like contacts and calendaring info over the last couple of years. So how to transfer? On the last Windows installation we have in the household (a partition on a laptop we usually boot once a year for reporting taxes), from the
last transition there was still a Nokia PC Suite installation. I figured I should upgrade it to work with the N900. Nokia nowadays recommends the Ovi Suite so I thought I'd give it a try. It failed already with the N76. After successfully connecting it would say that some operation was still running no matter what I tried to do. The N900 was not even recognized. So back to the PC Suite. It copied the content from the N76 just fine with the Content Copier (which I used last time for transferring from the 6230 to the N76). But for the N900 this is not supported. The only thing it can do is synchronization - and to synchronize the calendar you need either Microsoft Outlook or Lotus
Notes. That sucks! So the only thing I could transfer were the contacts using this method.
Later the day I remembered that there was some synchronization feature directly in the phone. I looked it up in the N76 and with this I was able to copy my calendaring data to the N900! This might work with other models also having the Switch application. Here is how if you want to do this as well. First open the application in the menu Tools -> Utilities -> Switch (on German phones: Programme -> Dienstprogr. -> Austausch). Then select Options -> Synchronize and follow the instructions on the screen. Turn on Bluetooth on your N900 and make it visible and allow pairing with your old phone.
You should be able to initiate this from the N900 in the Settings -> Transfer & sync. app. I haven't tried it this way around though.
Extras repositories
Additional software can easily be installed from the Maemo Extras repository, which is enabled by default. It already contains many interesting applications, but especially at the moment there is quite some software still waiting in the Extras-testing and Extras-devel repos.
Although officially discouraged, I have enabled the devel repo (I hope I kinda know what I'm doing, we'll see). It contains quite some packages that haven't made it through the full testing, yet. Among these are the Bluetooth Dial-Up Networking profile to dial-in with the phone from my laptop, a nice flashlight app, the Personal Data Plan (show amount of transferred data) and Personal IP Address (show current IP) widget and the packages for (developer) PC connectivity.
Cisco VPN GUI
Our university provides a Cisco VPN. To use this I have installed vpnc and vpngui from the Extras-devel repository (packages). After a small patch (bug #4184) it works like a charm and I can use the VPN.
Changing the host name
Since I'm using mDNS-SD via Avahi a lot to communicate with the robots I wanted to change the host name to something more personal. The host name announced via Bluetooth can be changed easily, but I didn't find a way to change the real host name. So I used the root access to set a new host name in /etc/hostname. Note that you also need to modify /etc/hosts to add the new host name as name for the localhost address. Otherwise the N900 gets too slow to do anything with it. Then a reboot and the new name is active.
Creating a connection from a laptop
For Bluetooth DUN support you need to install the "Bluetooth Dial-Up Networking" package (requires Extras-devel repository at the moment, reboot after installation to finish installation). Afterwards creating a connection from a laptop via the N900 works as with any other phone. On Linux (Fedora 11 in particular here) you can use the Bluetooth Manager (package name is blueman) to setup the device as DUN Adapter (right click and choose "Setup"). Afterwards you can create a broadband connection via the NetworkManager (right-click, edit connections, create mobile broadband connection). If you are as lucky as me your provider data is already available for selection. Afterwards click on the NetworkManager icon and the connection name to establish the connection. Next time in the Bluetooth Manager you just need to right-click on the N900 and select "Connect to: Dial-Up Networking" and then the connection in the NetworkManager. The only thing that I'm missing is that the N900 will not indicate the laptop connection in the status bar, which I find irritating.
And now after some days off back to real work...