• Uncategorized

    Blockchains, istruzioni per l’uso

    Il seguente articolo è stato pubblicato nel numero 1/2-2019 del Notiziario dell’Ordine degli Ingegneri della Provincia di Verona.Viene pubblicato qui grazie alla gentile concessione della Redazione. Come funzionano le criptovalute, l’e-voting e le altre applicazioni di un sistema informatico ancora poco conosciuto Negli ultimi tempi non trascorre giorno senza che un articolo, un programma televisivo o un comizio citi le “blockchain” come soluzione ultima di un qualche problema tecnico od organizzativo. Tali promesse in realtà fanno sollevare più di qualche sopracciglio nel settore degli esperti di questa tecnologia. Pare quasi che la blockchain sia una cosiddetta oracle machine che genera verità e certezze indipendentemente dal suo uso e dai suoi…

  • Embedded,  Linux

    Adding a user space “power switch” to your embedded linux

    Is is always amazing to see how some very obvious features are missing from the linux kernel. Yesterday, for a project I am developing for a Dutch firm, I come across one of these “very obvious feature”: the option to switch on and off a device in the embedded linux board we’re using. The problem seemed to be quite frequent: you have a device connected to the internal USB bus (a wifi module, maybe?) and you want to switch it off completely when not in use. It is the only USB connection in that bus, a single power line is powering that device, and still you need to power the…

  • Android,  cybersecurity

    La vulnerabilità di WhatsApp spiegata a mia figlia

    A chi non è capitato di dover riempire un modulo i cui spazi da riempire sono troppo stretti per il testo da inserire? Il classico caso in cui l’indirizzo è davvero troppo lungo per lo spazio previsto e ci si arrangia scrivendo negli altri spazi, oppure sovrapponendosi al testo stampato, e rendendo il modulo praticamente illeggibile? Una cosa simile accade quando in un software o una App riceve dei dati da internet (un server, o magari dalla stessa app installata su un altro smartphone) ma il programmatore non ha effettuato correttamente i controlli sulla lunghezza e il programma copia i dati su uno spazio troppo stretto. In questo modo i…

  • Embedded,  Linux,  uboot,  ubuntu

    Configuring Ubuntu to deal with an ARM board with U-Boot via USB

    Abstract We have a board on which an AllWinner ARM processor is running Linux. The bootloader is U-boot and we have to use the USB port to flash it. When flashing the device for the first time, after loading the bootloader via FEL protocol, we need to use tftp to load the SPL (Secondary program Loader) image and the uboot version for use with the spl. Unfortunately, a couple of issues in the default Ubuntu configuration prevent us from doing this apparently simple operation in a straight way, and we need to tweak some system configuration file. The issue After using the sunxi-fel tool to run the bootloader in memory,…

  • c++,  Code

    Strong Typing PODs

    Identifiying object by a numerical integer is an almost trivial task. In DISPLACE, a very complex simulator I am involved with, there are many of different categories of objects that model different categoris of agents in the simulator, like vessels, marine locations, ships, ports, and so on. Each object has an Id, and it was very natural, at the start of the project, to implement it using an int. Problems started when we decided, for optimization purpose, to shrink the memory footprint, to use smaller int instead. Indeed, there could be at most 65535 nodes, and at most 256 node types, and each was modeled with an int. The mess started when we…

  • Uncategorized

    A C++ Smart Pointer wrapper for use with JNI

    Introduction In this article, I'll propose a solution for managing native C++ resources from JNI using smart pointers. While Smart Pointers can't be useful from Java, because of the limits of the Java memory management, it may be required by the native library to maintain allocated resources through shared_ptr or unique_ptr, for example because classes derive from std::enable_from_this. Since there is a fixed pattern to maintain native objects in Java classes, a utility C++ class is proposed. The problem of memory management when integrating Java and C++ code Recently, I had to port a library I wrote for Linux to Android. For instance, the library is aimed at implementing an…

  • Linux,  vmware,  Windows

    Vmware Player is slow under Ubuntu 16 host, Part 2.

    So it seems the issue I talked about some week ago, wasn't fixed. Windows is still slow, the hard disk always working at 100% load. Not so slow, because the fix explained in my previous post seems to mitigate the problem, but still slow. Since I was using many Virtual Machines on that box without any problem since longtime, well before my upgrade to Ubuntu 16.04, I guessed the problem was the kernel. So I rolled back to 3.16. And… tada! now the machine works flawlessly. Seems incredible, because I looked around to see if anyone had similar issues, without any luck. So, if you're running kernel 4.4 and VmWare…

  • Linux,  vmware,  Windows

    Vmware Player is slow under Ubuntu 16 host

    So you just upgraded your Ubuntu box and found that all your VmWare Windows Boxes are extremely slow? The symptom is your Windows task manager showning 100% usage of your disk, and the WIndows Instrumentation showing very long lags, says, up to 2.5seconds (yes, seconds) to respond to a disk request. This makes the box practically unusable. Perhaps your vmware logs are shoing a lot of lines like scsi0:0: Command READ(10) took 2.748 seconds (ok) scsi0:0: Command WRITE(10) took 3.224 seconds (ok) and so on… Well, this is a well known issue. A quick search with google will point you to the vblank_mode=0 fix.  Indeed I already fixed that on my…

  • c++,  Metaprogramming

    A compact CSV parser using C++ TMP

    How many times have you implemented a CSV parser to fill a list of stucts from a text file? Personally, it happens to me about every time I have new project. Though it is a simple task that requires no more than half an hour to build and debug, it is boring, error prone and repetitive. The algorithm is quite trivial, read each line, split it in a vector of string using some separator (about always a comma, hence the "Comma Separated" name), use something to convert each field in a PoD (int, double, whatever) and fill a struct.  Here's a general solution that makes use of Metaprogramming to implement a parser…

  • c++,  Code,  Linux,  Uncategorized

    The dbus-cpp Library, introduction

    While working on a bluetooth based embedded device, I needed to deal with the somehow infamous dbus. DBus and Bluez5 have a very steep learning curve, and if you are don't have access to either Qt framework or glib framework, you have indeed a problem. Glib are very complex C libraries that mimick some of the built-in feature of the C++ language, while on the other hand, Qt are very vast and sometime a big overkill. The stunning news is that it seems there aren't many options if you need a C++ only lightweight solution. It is not true, indeed. Somehow well hidden in the creases of the web, I…