Soletta IoT Framework

Every once in a while there comes the will to blog again, and this is that time. Lots of things happened since the last post here, jeez, the first of them being I joined Intel ever since. It’s been fun to work there, by the way. The thing is all of my projects were work on proprietary (and non-disclosable) software for a time, thus the silence.

I had the opportunity of working on a whole visual identity for a Tizen-based smartphone stack, which was awesome. I also had the opportunity of working on an Android fork that implemented multi-windowing. It was not as awesome, because Java gives me the cramps, but I got to learn that system’s internals and learning is always fun.

The next project I jumped onto was really exciting, though (now open source!). I was involved since the very beginning in Soletta‘s design and coding. One thing we had in mind, when starting that in this already fragmented IoT ecosystem we got, is to really make a difference in completeness and ease of use for developers of all backgrounds. There are a lot of claimed IoT solutions out there, really. But what we see is that the majority of them are too focused on a small subset of what an IoT node should be able to accomplish (communications or I/O), but not on everything altogether. Also, the things we saw out there were not portable at all. We wanted porting Soletta to different platforms a breeze from the very beginning.

So, we started our journey. In order to accomplish the ease-of-use part of our proposal, Soletta based its API in a main loop, so that it’s easy for users to hook on events by simply giving callback functions and never having to deal with threads and the like. We started with glib’s main loop as a back-end, but now we got one of our own to share among POSIX systems and we made sure writing implementations for the main loop API is straight-forward for any system (glib is still selectable as a main loop implementation, by the way).

We started with one of the main parts an IoT API must have, then—I/O. We implemented the I/O nodes a program could have by having diverse I/O classes they would inherit from, and the user was supposed to connect nodes with compatible I/O classes together, so they would exchange data.

Early on that work we realized that what we were doing was very much alike J. Paul Morrison’s Flow-based Programming, and that we could benefit from that domain-specific language to have an even more straight-forward and easy way for developers to use Soletta. So we exchanged the APIs and models we got to totally support the FBP model (we now got nodes as in FBP “black boxes” and ports and connections of them). We built a FBP parser and, with that, there was now two ways in which a user could build and run Soletta programs:

  • By using the C API directly and compiling or
  • By writing their logic in FBP and using the new sol-fbp-runner tool to run it

We did not stop there, though. Thinking back of the portability promise, we made a sol-fbp-generator tool, which would take FBP input and output equivalent C code for that. This came to aid on real IoT platforms where runnable programs do not exist and everything must be compiled and linked into a final image. Average developers still don’t have to know very deeply any details of IoT operating systems that way with Soletta—they simply write their flow, with the nodes they need, and they are good to go. One important thing is that Soletta’s flow layer is not mandatory. If the constraints dictate so, one can always write Soletta applications using the rest of its C API directly and skipping the overhead (which is already really low) of the flow.

Here is what a FBP sample looks like. One declares nodes by giving them a name (timer is the name we chose for a timer node), followed by parenthesis, the node type’s name, and (optionally) colon and the node’s instance parameters. In that case, we got a timer with a 1000 milliseconds timeout. The next important things are port nodes. We must connect output ports (always written after a node’s reference) to input ports (written before node references). There, we connect the timer’s OUT port to a toggle’s IN port. The data that flows between nodes is called packets in Soletta. Ports’ supported packet types must match, so that their connection is possible. In that case, the timer outputs the empty packet type (which is just a “pulse”), while the IN port of the toggle node expects any packet type (again, it just needs a “pulse”), so they are good as a match for a connection. The toggle node belongs in the boolean family of nodes: it will keep an internal boolean state and ouput (and change) that state every time a pulse comes into its input port. Thus, the example will just print two boolean values that will change every 1 second.

By using FBP to develop with Soletta, one is able to even make use of node meta types, where there’s even more freedom of behavior customization. As of now, Soletta exposes the JavaScript meta type, where you declare a node’s input/output ports as well as the logic gluing the former to the latter all in JavaScript, directly in the FBP file. Also, there are the meta HTTP (both client and server) nodes, where one can serve and consume a custom packet they declare directly in the flow as well.

That boolean valuen to the console sample was just a dumb example of Soletta’s capabilities, naturally. Take a look at all the nodes it has, as of now. As you can see, we’re very far from that I/O-only beginning. We’ve got nodes doing all types of communication: bluetooth, CoAP, HTTP, LWM2M, MAVLink, MQTT, OIC, etc. On I/O we cover basically everything that’s relevant for IoT: analog to digital converters, GPIO, I²C, PWM, SPI, UART. We also handle persistence/storage on a various models (EFI variables, file systems and flash-memories), have Linux IIO sensors exposed and much more. Take a look at our API for yourself.

Our ease of porting effort has proved itself very good as well. Soletta will now run on any of the following systems:

It’s for real, any FBP program (with nodes having implementations on all of them) will work on each of those systems out of the box (also architecture independent). With around 100kb of final image (operating system included), we have functional OIC/OCF nodes running on very resource constrained SoCs, like the Arduino 101 or the Atmel SAM R21 Xplained Pro.

It’s been a fun journey (Soletta is one and a half years old now), and we’re finally calling it a version 1 soon! I hope all you developers in the search of solution for your IoT products have the chance to evaluate Soletta and give us feedback. There are a lot of things about Soletta and its infrastructure I did not talk about (it will be released as a behemoth already, it’s huge in what it encompasses!), so please take a look on all Soletta’s ecosystem as well.


Emacs-uncrustify updates

Emacs-uncrustify emacs extension had some small but cool contributions by Gordon Read (thanks, man!).

It has now a customization group with variables holding:

  • path to uncrustify’s configuration file
  • arguments to be passed to uncrustify
  • boolean flaging if uncrustify should be applyed on a buffer on save

We also have two different functions, now. The uncrustify one does the same — uncrustifies a region. There’s also uncrustify-buffer, now, as a shortcut for applying it to the whole buffer.

Finally, a c-mode-common-hook was added, which will apply uncrustify on the buffer if and only if that third variable is set.


Enlightenment Project’s Coding Style or “If you can’t beat ‘em, join ‘em”

This is a quick post for all of you Enlightenment developers and users (the latter also willing to adhere to that weird coding style). The named coding style, which seems to historically have come from Rasterman’s text editor, Jed, has been recently been called for a standardization/modification by means of an uncrustify configuration file.

While the file itself is still not perfect (there are “indentation bugs” yet), I wanted to have my editor — Emacs — to help me to adapt to that thing. So, I present you with a crude first attempt at it: Patches are obviously welcome.

By the way, exciting news are emerging from E-land, so stay tuned for hot hot new stuff, soon.

Gravando imagens de CD do CloneCD no Linux

Como rodei um bocado pra achar um jeito de fazer isto, fica aqui registrado, para ajudar em futuras buscas.


A bosta de se viver num mundo de software proprietário se torna mais visível quando palas destas acontecem. O formato de imagem de CD do citado aplicativo para Windows, por ser proprietário, não tem um equivalente livre para manejá-lo. Até existe uma ferramenta que faz um serviço experimental, mas meio porquinho, o ccd2iso. No entanto, a solução para fazer a coisa direito é recorrer à combinação Wine + UltraISO. Este último sabe como converter para o formato bin/cue, por exemplo, que o K3B grava “com o pé nas costas”, como diria um professor meu.

Bom, é isso aí. Se baixar algum torrent de jogo de Playstation por aí, não desanime mais, se a imagem tiver sido extraída por aquele programa escroto. Tem recurso 🙂

Emacs: cor no “M-x shell”

Já que está mofando isso aqui mesmo, um texto técnico-cópia.


Quem programa ou edita arquivos-texto com freqüência, já deve ter pelo menos ouvido falar do editor de textos extensível Emacs. Embora haja divergências no meio computeiro quanto à preferência de editor de texto, o Emacs têm muitos usuários, como eu. Grande parte de sua extensibilidade se dá pela interface criada para configuração e criação de novas funções: um dialeto da linguagem Lisp, o emacs-lisp. Ainda quero aprender o basicão dessa maravilha, coisa que farei devagar.

Indo para o ponto em que quero chegar: saca o shell buffer (interpretador de comandos chamado da interface do Emacs)? Você, como eu, é bem capaz de definir variáveis de prompt, por exemplo, com cores. O Emacs, por padrão, no entanto, não interpreta como quereríamos os códigos ANSI das cores, sendo que os mesmos são impressos literalmente na tela. Para deixar o bicho colorido, como se deve, adicione as seguintes linhas (de emacs-lisp) no seu arquivo ~/.emacs:

;; Correção para cores para um shell rodando sob emacs (‘M-x shell’)

(autoload ‘ansi-color-for-comint-mode-on “ansi-color” nil t)

(add-hook ‘shell-mode-hook ‘ansi-color-for-comint-mode-on)

Fica perfeito. Dica tirada daqui.