Sunday, November 5, 2017

A smart watering system built on IBM Bluemix

In the last months, I spent some time building a prototype of a smart watering system. I had the idea while building a watering system for my plants, because the current technology has few drawbacks, like:
  • inability to remotely monitor the status of the plants;
  • inability to remotely configure the watering cycles (possibly basing the configuration on the current weather and the forecasts);
  • impossibility to remotely check if the system is delivering too much water (leakage) or too few (bottleneck).
These kind of problems can be quickly solved through an internet connected watering device. I just decided to build a prototype using some commercial components, an control board I developed, and a software stack built on the IBM Bluemix platform.

Sunday, September 11, 2016

The Watson trainer

These days everybody is busy training Pokemons. But, because of a challenge, I had to spend few hours training something different: Watson. It has been real fun and this is why I decided to share my experience.

Tuesday, December 29, 2015

Developer friendly debugging in gdb

Limits of the basic GDB interface

The main user's complain about gdb is the lack of a friendly interface. The basic interface is command line based, alternating just one line of information with the command entering prompt.
While debugging complex source code, it is quite annoying to be able to see only one line of source, without any context. The list command allows to print few lines of source code around the currently executing line, but alternating the next command with the list one is, again, not very productive. Graphical debuggers, like ddd, offer a more rich interface to gdb, but I'm used to debug over a terminal connection and ddd requires an X server.
The solution is an additional gdb built-in interface that offers a better debugging experience: TUI (text user interface).

Sunday, December 27, 2015

Select on Linux is really dangerous

Why is it dangerous?

The select system call can be used to check if a file descriptor (usually a socket) is ready for reading or writing. The function accepts as an input three sets, each one containing the file descriptors of the entities (pipes, sockets, ...) to test for readability, writability or an error state.
The largest file descriptor that can be stored in these sets is limited by the FD_SETSIZE constant, that is usually equal to 1024. If a file descriptor having a value larger than FD_SETSIZE is "stored" in one of such arrays, the effects is undetermined: but generally that operation results in an invalid memory access.

So if your program can potentially use many file descriptors, it is possible that select and its sets will make it fail. The remainder of this blog shows how to replace select with poll, that is not limited by the value of the file descriptors it can handle.

Wednesday, October 28, 2015

A web based interface for my ESXi home lab

Managing ESXi

The free VMware ESXi hypervisor is very good for creating a virtual lab at home. But its main limitation is the lack of a web based management interface.
Administering ESXi requires installing the VMware vSphere Client, that has two drawbacks:
  • It requires a Windows PC to run
  • It is no longer improved by VMware
In fact the VMware strategic management interface is the web based interface that is included in the full vSphere infrastructure. But there is no free license for it.
No longer being the strategic direction, the vSphere Client development has slowed down. As a consequence it now has some limitations, like the inability of editing few parameters of the latest VMware virtual hardware.

But VMware has release a beta version of a new web interface that can be installed directly on ESXi.

Wednesday, August 19, 2015

Debugging memory errors using Application Verifier

Debugging memory management errors

Few days ago, one of my applications started crashing both on Linux and Windows because of a memory corruption. Many tools are available to debug such issues; I usually use the open source valgrind on Linux, while I prefer instrumentation based tools on Windows.
But the application I had to debug was so large that the instrumentation based tools either failed to instrument it or succeeded in instrumenting the binary but then failed quite soon at runtime. Valgrind was successful in running my application, but generated such a large number of false positives that it was really difficult to locate the source of the error I was interested at.
I finally found information about Application Verifier and tried it for the first time: and it was really successful in helping me finding the memory issue, by pinpointing the line of code that executed the wrong memory access.
The reminder of this article shows how to use Application Verifier to debug memory issues, using a simple example.

Sunday, July 26, 2015

Adding ssh support to the Visual Studio 2015 Git plug-in

Some background


Visual Studio 2015 includes a Git plug-in that allows to version control software using Git. The plug-in allows to publish/clone from a shared Git repository, but is currently limited to repositories that support the http/https protocol.

Many users are requesting support for the ssh protocol, but the requirement is still under evaluation:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3801342-add-support-for-ssh-keys-as-alternate-authenticati

Anyhow the plug-in is based on libgit2, which optionally supports the ssh protocol. The next section describes how to rebuild libgit2 in order to enable ssh support.