Tuesday, May 5, 2015

The Code: Story of Linux documentary

The Code: Story of Linux documentary is a very nice documentary about Linux.  You will see the early days of Linux and young 'Linus' and all the important people for the development of it. ^_^

Monday, May 4, 2015

Building Ada promgramming enviroment for Slackware

Slackware has finally upgraded the system GCC to 4.9.2 in current. Here I presented my work to compile GPS using FSF's GCC 4.9.2. It is based on my previous attempt to build the environment with GCC 4.7.0. This time lots of things have changed, new GCC and GNAT GPL released and they make the attempt much more easier than previous one. GCC 5.1 has just been released, but Slackware use 4.9.2 in the current branch for now, so we stick with 4.9.2.

The Compiler

There is no need to change the build script any more, but we need some of the compiler internal files. So run the standard build script for GCC.

XMLAda

For this one, I am using the xmlada-for-gps-6.0.1-src.tgz from GNAT GPL 2014, in stead of xmlada-gpl-2014-src.tar.gz. They are almost exactly the same with minor changes.

GPRbuild

I am using the gprbuild-gpl-2014-src.tar.gz. GPRbuild expected some support functions that are not in the FSF GNAT compiler. Namely the "GNAT.Rewrite_Data" package and some low level support functions in os_lib.c. I gather the missing functions from the GNAT GPL 2014 version and make up some packages for it. Then it builds without problem.

GNAT_UTIL

This GNAT Util Library provides access to GNAT compiler internals for AdaCore utilities. It makes the previous effort of trying to mimic what Debian do redundant. In the build script, the source and build directory of the GCC compiler needs to be specified for it to work correctly.
I am using the 4.9.1 one from the sourceforge project. For there is no 4.9.2 version and there are basically no differences for the generation of gnat_util.

GTKAda

With the standard gtkada-gpl-3.8.2-src.tgz, there is nothing special, it builds without problem. One may have to note that currently it does not support GL.

Aunit

Aunit GPL 2014 also builds without too much problem.

GNATcoll

GNATcoll compile without problem with some patches.

GPS

Oh, finally, we could build the IDE. It depends on pygobject3, which could be build using SlackBuilds.org's supply script.

Florist, ASIS, GNATMEM, Ahven

The rests are relatively easy and build fine with the build script. For gnatmem, we need to rebuild the binutils and specified the directory in gnatmem build script.

Other experimental scripts

I have tried to build the Ada-RM, GNAT RM, GNAT user guide to integrated with GPS, it seems working for me.

Where are the build scripts

All build scripts are available at GitHub.

Monday, April 27, 2015

A built in Javascript code beautifier in Firefox

From time to time, I need to look at Javascript code from some web site.  As most of the script files have been minimized to a form that is unreadable by human being.  A good Javascript code beautifier is needed. There are various tools I found in the web, some are local some are on the web. But sometime I forgot the URL or could not find the tools in the system.

Then I came a cross this Scratchpad built into Firefox itself. I was not aware of this tool for all the time I am using FireBug for debugging. And I found this Scratchpad has a "Pretty Print" button. ^_^ How nice, a code beautifier is right there!


The output is good and I don't need to remember anything, except the shortcut "Shift+F4", I think I will use it a lot!

Friday, April 10, 2015

Creating a muli-processes DTLS server.

I need to create an UDP server working with multiple clients over DTLS.  I found one note about net-snmp's DTLS Implementation Notes which almost has the same requirement as mime.  But it seems it falls back to use memory BIO and cache the data, and Campgnol VPN's solution is making use of NAT traversal technique that open each new connection with a new UDP port, which does not fit my requirement to only use one UDP port for server.

From the notes, I notice the author is almost succeeded with peeking the incoming traffic except the "Packets Pile Up" problem.  I think that is the right direction for me.

I tried on a single process server first. With recvmsg() with MSG_PEEK, I could get the client's address and port number, from which I could select the right context for the DTLS link.  I realized that I need a custom BIO module to avoid the"Packets Pile Up" problem.

I made a copy of crypto/bio/bss_dgram.c from OpenSSL's source and renamed it to my_udp.c, then stripped away anything unrelated to my usage, basically removed all platform specific and SCTP code except for Linux.  Then further removed all code related to connected filed flag.  Then changed the reading function to peek the packet first and compare the source IP and port number to the current one.  If it is not the current one, then fake an EAGAIN error.

Since server is listening on multiple interfaces, when sending data out, it needs to set its source address correspondingly.  But UDP does not directly give the local address used for the data.  With socket option IP_PKTINFO turn on for UDP server socket, local server address could be found with recvmsg() together with MSG_PEEK.  It is then set in my custom UDP BIO to be used when sending out data.  This seems to work fine with single server process.

But then I was facing the challenge to serve client on multiple processes on the same UDP port. After some tried and errors, I settled on the following method:

The parent creates socketpair() with each child for communication.  For the start, only the first child would listen on the UDP server port.  After peeking from the incoming data, calculate a child index from the client address and port. If the child index is its own, it proceeds to process the data, if not, it stops monitoring the server port for incoming data and send a command to parent and inform parent that the other child should handle the incoming data.  When parent receives the command, it will send the information to the other child, the other child gets the message and start monitoring server port and process incoming data and so on.

It seems working, but have not test out the performance, whether it is worth the trouble to have multiple processes.

Monday, March 9, 2015

MIT open course for Ada

MIT offers one open course for Ada programming (it is based on Ada 95):
Unified Engineering I, II, III, & IV » Comps./Programming

Tuesday, January 20, 2015

Ref: Git: Using Different User Emails for Different Repositories

A good solution for the problem is here.

Simply by putting "(none") under .gitconfig.

[user]
 name = Your Name
 email = "(none)"
Then git config user.email in each repository.

Thursday, November 20, 2014

3 days using Android Lollipop on Nexus 5

Have heard all the good things about Andriod Lollipop, and eagerly waiting for the released. When the factory image was out, I was going to install the image on my Nexus 5 myself, but latter found that the platform tools of the SDK has only 32-bit binaries, although I had downloaded a 64-bit version of the SDK. It seems this is a known problem and ignored by Google, saying install a 32-bit compatible layer should do the trick. I don't want to install megabytes of 32-bit layer on top of my pure 64-bit installation system!

Well, I waited not long after, the OTA came and I quickly installed the upgrade (Nov 18). The new GUI does not really impress me, but so long as it does it job, I am fine with it. But compare with the older one from KitKat, I like the KitKat one more.

The new clock application use current time to change its background color, that annoying me greatly, and it has no option to turn that off! It may look nice on the presentation, but it give no value to me. I like to look at the clock on a black background! The layout of the international clock changes to a list from the 2 column layout in KitKat. I think the 2 column layout give me a better presentation.

Browser tabs, I could not find the handle of tabs in the browser, I did not recall I had allowed the browser to merged tabs with apps. Well, at least this time I have a setting to turn "Merge tabs and apps" to off.

The battery saver mode is fine. But why should it insist to change the status and home buttons bar to orange background? With the battery saver icon on the status bar, it is already obvious, why on earth change those background color? I know what I am doing, and does not need such thing to remind me I am in battery saver mode. And no option to turn the color change off.

For media video playing, the volume control button no longer work as expected, instead, I have to click on the button, then tap on the speaker symbol to get sound changes, and dragging on the sound meter bar no longer work. This is really bad engineering.

Skype could not login any more after upgrade to Lollipop, even upgrade to the latest version. One commenter said it needs to be removed and re-install, I follow suite, it could log in again and skype test call works ok, I haven't try the video call yet, will see.

Lollipop defaults to use white background, it hurt my eyes. The color theme of KitKat looks more comfortable to the eyes.

Except those complains, so far so good, the battery usage maybe improve a little, but hard to tell for I am a light user, will see for a longer period of usage.