Sun Microsystems released their Small Programmable Object Technology (SPOT) as open source earlier this year. SPOT fits in the same category as the Bug Labs BUG that I’ve previously blogged about. SPOT seems to be less modular than the BUG. Both platforms are Java based (SPOT is J2ME) and they also feature some of the same type of hardware. The Sun SPOT device measures 70 x 41 x 23 mm and contains features the following hardware sweetness:

  • IEEE 802.15.4 (forms the basis for ZigBee) with integrated antenna
  • 3-axis accelerometer (with two range settings: 2G or 6G)
  • Temperature sensor
  • Light sensor
  • Tri-color LEDs
  • 6 analog inputs readable by an ADC
  • 2 momentary switches
  • 5 general purpose I/O pins and 4 high current output pins

SPOT’s main advantage over the BUG is that it has built-in communication. Bug Labs are probably hard at work to build a communication module as well to make it more desirable.

Edit (2008-07-19): Clarified the relation between IEEE 802.15.4 and ZigBee.

Lego bug

Bug Labs has developed a modular mini-computer running on open source software. I first read about it in the O’Reilly Radar blog. Bug Labs has promised to make all the source code for the platform available. The main BUGbase module is 10×5 cm big and can accommodate four other modules, each 5×5 cm big.

The system isn’t completely finished, but soon it will be possible to buy the base module and other modules like:

  • BUGlocate – GPS receiver.
  • BUGcam2MP – 2 megapixel digital camera.
  • BUGview – 2.46″ 320×240 pixels LCD screen.
  • BUGmotion – A combined motion detector and accelerometer.

The base module will eventually have built-in WiFi and hopefully they will also make a UMTS (3G) communication module. Applications are developed using Java together with an Eclipse based IDE. I’m very interested to see what kind of applications people might come up with for this thing.

It’s like Lego for grownups.

New guy

The new title of this blog was slightly inspired by Jeff Dunham‘s performance in this video (impatient people may skip to 07:04):

Eclipse CDT and shared libraries

I had some trouble getting Eclipse CDT (C/C++ Development Toolkit) to work across separate projects. My setup is Eclipse 3.3.1 with CDT 4.0.1 on Windows with the MinGW toolchain. I have two separate projects in Eclipse: One is a shared library and the other is an executable. The executable uses the shared library so naturally it needs to read the header files from the other project in order to sucessfully compile and link. It would also be nice if it was possible to use the Run As Local C/C++ Application feature without the need to copy the shared library file to the directory where the executable file is. I set out on a quest to find the answers.

The first thing you have to do is right-click on the executable project in the Project Explorer, and then go to Properties -> Project References. There you have to select the shared or static library project you want to link to. Then click OK. If you try to build the project it still won’t work because it cannot find the required files.

Let’s open the project properties window again, but this time go to C/C++ General -> Paths and symbols -> References. Make sure that you select the shared/static library under all your configurations. The standard setup contains the Debug and Release configurations which you can switch between with the dropdown list at the top of the window. To make sure that you always link against the Release version of the library when you build the Release version of your executable you can expand the library reference node and select Release instead of the default [Active] selection. The same thing goes for building against the Debug version of the library when you’re building the Debug version of the executable. Click Apply when you’re done.

You might think that everything should be good to go by now, but we have a bit more to do first. In the project properties window go to C/C++ Build -> Settings -> Tool settings -> MinGW C++ Linker -> Libraries. Click the document with the green plus sign (Add button) right next to where it says Libraries (-l). In the input box that appears you should type the name of the library without its file extension. If your library file is “useful.dll” or “” then you should only type “useful”. Don’t forget that you have to do this for both the Release and Debug configurations if you don’t want any nasty surprises later on. Click OK when you’re done.

At least now it should compile, but you would maybe like to run it from within Eclipse as well? First you have to create a so called run configuration for your executable. Right-click on the executable in the Project Explorer and go to Run As… -> Local C/C++ Application. This will actually launch the program, but it will also automatically create a run configuration for it. The program will terminate without any error messages because it couldn’t find the library file. On the top menu go to Run -> Open Run Dialog…, select the run configuration for your program (if it isn’t already selected, obviously) and go to the Environment tab. Click New…, name the new environment variable “Path” and give it the value “${env_var:Path};${workspace_loc:/useful/Debug}”. Substitute “useful” for the name of your shared library. This will modify the system environment “Path” variable by adding the full path to the library so that the executable will find it.

If you want to use the Release version of the library then just substitute “Debug” from the environment value with “Release”. Unfortunately I haven’t found a way to detect which build configuration is active so you have to manually change this value if you switch between Debug and Release. An alternative is to create a separate run configuration for Debug and Release. This can easily be done by right-clicking on the run configuration and clicking Duplicate.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Guns and ammo

In C, you merely shoot yourself in the foot.

In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can’t tell which are bitwise copies and which are just pointing at others and saying, “That’s me, over there.”

Borrowed from: Const Correctness in C++

NOTE: This post has been imported from my old it’s learning ePortfolio blog.


I’ve been trying to setup AWStats in Windows, but it was a real pain in the butt. A lot of packages had to be fetched manually to get the functionality I wanted. I also needed a way to automate the updating of the statistics website by periodically downloading an Apache log file from an FTP server, append it to the main log and run the AWStats update procedure. And let’s not forget the need to publish the webpages created by AWStats. Ironically enough the easiest way I know how to do this is by bringing Linux to the Windows platform by installing Cygwin (a Linux emulation layer).

At this point I was well aware of the amount of unnecessary complexity this system would have. It would be a pain to ensure it’s long term reliability, and a house of cards like this would likely crumble under the lack of maintainability. If somebody had to recreate the entire setup there would be way too many steps where things could go wrong.

My final solution was to take a few steps back and install VMWare Server and create a new virtual machine with Ubuntu Server 7.04 with the LAMP (Linux, Apache, MySQL, PHP) option. After the Ubuntu Server installation was complete I ran “apt-get update”, “apt-get install awstats”, “apt-get install libnet-ip-perl” and edited the awstats.conf file. Then I wrote a simple cron script where wget will fetch the log from the remote server and the AWStats web pages will be updated automatically.

With Ubuntu Server and VMWare already downloaded it took me about one hour to install and configure the whole thing. If the entire system needs to be moved to another machine this can easily be accomplished. Simply install VMWare Player on the other machine and move the virtual machine folder and you’re done. It’s fast and simple, and with the successful Debian package management system used by Ubuntu we have built one sexy package.

NOTE: This post has been imported from my old it’s learning ePortfolio blog.

Probabilities for an extended ticket lottery – revised

This paper updates the original with a section on expected winnings, a conclusion, simplified Equation 3 and a lot of rewriting through the whole thing to make it more consistent.

NOTE: This post has been imported from my old it’s learning ePortfolio readables blog.