SRA Lab Open Source Code


Feedback on GNOME 3.0

After 5 months with GNOME 3.0, I'm really happy with the experience. At the end of work day,
my mind is no more exhausted of windows placement fighting and application finding.

GNOME 3.0 is really stable, except with the Open Source driver on my Radeon 5870 (4 crashes in 2 months).

I really like the behavior of dual-head where the secondary screen has only one virtual screen.
For me, there are just 3 annoying points:

  • Ctrl + Del to remove a file in Nautilus, may be it's a Fedora settings but this change is just @!# I've already a Trash to undo my mistakes (
  • Alt key to shutdown, no I don't want to waste energy for days and my PC boots quickly.
  • only vertical virtual screens, I found a bit painful to move down two screens when the screen is reachable with one move with a 2x2 layout but I understand this layout doesn't fit well with the GNOME 3 design.

To have a good experience with GNOME 3, I use:

  • Windows key + type to launch everything
  • Ctrl + Shift + Alt + arrows to move the application between the virtual screen
  • Ctrl + click in the launcher when I really want a new instance (the default behavior is perfect)
  • snap à la Windows 7 is great
  • Alt + Tab then the arrow keys to select an app

Don't forget to read or the Help (System key + 'Help').

It's not specific to GNOME 3 but you can change the volume when your mouse is over the applet (don't click, think hover) and a mouse scroll.
With GTK+, do you know you can reach the end of scrolled area with a left click on the arrow and a specific position by middle click?

I'm impressed by the new features of GNOME 3.2 and I'm waiting for Fedora 17 to enjoy it!


coreutils is a really active project

I'm impressed by the activity of the coreutils project (unix commands such as ls, df, etc). At first glance, you might think command line tools are written for good and only few changes are applied to ensure compatibility with the platforms. With several releases a year and new features for each, it's really an active project indeed.

coreutils 8.13 release note.

You want to show the local time for 9AM next Friday on the west coast of the US, it's possible:

$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'

The maintainers/contributors (Pádraig Brady, Jim Meyering and Eric Blake) are nice and quick to commit your patches.
So don't be intimidated it's not the glibc project!

PS: I'm waiting for the tag on to be able to push the latest French translation.


Tip for python-mode with Emacs

If you expect 'Alt + d' wil only remove the first part 'foo_' of 'foo_bar' with the great python-mode, you can make this change to python-mode.el:

- (modify-syntax-entry ?\_ "w" py-mode-syntax-table)
+ (modify-syntax-entry ?\_ "_" py-mode-syntax-table)

Thank you Ivan.

Update with python-mode v6.0.4, add this line to python-mode-syntax-table (line 153):

(modify-syntax-entry ?\_ "_" table)


libmodbus v2.9.4 is out!

This minor release contains many new features with IPv6 support, documentation (man and HTML), error recovery modes and small API changes. I'm intend to release the version 3.0 so I need feeback from this release even more if you use libmodbus on Windows or MacOS X (check nanosleep support for example).

It's easy to test the library, just compile and run the unit tests! Don't forget to notify your success or failure (by mail, wiki or bug report), see the Call for Testers page or the mailing list for details.

There are already Debian and Fedora packages but I need help to submit them to the distributions, so all experience in this field is appreciated.

libmodbus 2.9.4 (2011-06-05)

  • IPv6 support  Make the TCP implementation "protocol independent" by Florian Forster  and Stéphane Raimbault.
  • Fix compilation on Windows 7 (x64) with MinGW/MSYS and GCC 4.
    Reported by Patsy Kaye.
  • Documentation of libmodbus functions with AsciiDoc (man and HTML) by Stéphane  Raimbault
  • Avoid an iteration in flush function
  • New functions to send and receive raw requests (modbus_send_raw_request,  modbus_receive_confirmation)
  • Fix flush function of TCP backend on Windows
  • API changes for server/slave:
    * modbus_receive doesn't take socket/fd argument anymore
    * new function modbus_set_socket to set socket/fd
  • API changes for timeout functions:
    * modbus_get_timeout_begin -> modbus_get_response_timeout
    * modbus_set_timeout_begin -> modbus_set_response_timeout
    * modbus_get_timeout_end -> modbus_get_byte_timeout
    * modbus_set_timeout_end -> modbus_set_byte_timeout
  • Fix longstanding limitation of server to wait forever
  • New functions modbus_set/get_serial_mode by Manfred Gruber and Stéphane  Raimbault for RS485 communications
  • Improved recovery mode (see modbus_set_error_recovery documentation) for  data link and protocol errors.
  • Fix compilation issue with Microsoft Visual Studio 2008.  Reported by Allan Cornet.

La DjangoCong 2011 est terminée

Grâce à Makina Corpus, j'ai pu assister à nouveau à la DjangoCong. C'est une occasion idéale pour retrouver l'équipe des Djangonautes de Makina au grand complet ;)

La nouvelle organisation du WE mettait l'accent sur la participation avec des mini-confs très courtes le matin (12 mn) et des ateliers à la barcamp, et encore une fois les organisateurs ont été irréprochables, bravo ! C'est un plaisir de retrouver des têtes connues et de rencontrer de nouveaux venus pleins de bonnes idées. Les entreprises étaient plus impliquées cette année (merci les sponsors) et l'écosystème autour de Django semble en bonne voie avec des produits tels Django SHOP et Django CMS,

Nous quittons Marseille avec quelques outils à utiliser au plus vite et de bonnes idées:

DjangoCong est la conférence Django francophone à suivre !

Quelques photos


The libmodbus documentation has landed

You've been numerous to ask for documentation and the work of gass with GTK-doc help me to prioritize it, so this month I've finally tackled this problem but not as expected!

At first, I loved the GTK-doc solution, I'm a GNOME lover after all, but GTK-doc can't generate man pages and the setup code is too cumbersome IMHO. To choose the best solution for libmodbus, I read a comparison matrix on Wikipedia, after some tests with GTK-doc, Doxygen and AsciiDoc, and I finally choose AsciiDoc.

However, there is a major difference between AsciiDoc and the other envisaged solutions, the documentation isn't included in the source code. I used to think it was good idea to keep the both at the same place to keep them in sync but:

  • it doesn't prevent you to code without updating the documentation
  • the documentation must be escaped by the language comment tags
  • I don't want to abuse my wheel mouse (to skip documentation) when I code

The 0MQ project, endless source of inspiration, was a very good starting point to learn some tricks with AsciiDoc.

Now, I'm looking for help to review and extend the documentation which has just landed in git (make doc to generate man pages). I've generated the documentation in HTML for the web site.


Dynamic OR’d Queryset Creation with Django

To complete posts and comments published on Elf Sternberg's blog, this is the method I found to create dynamic complex queryset with Django (Q and or):

field = 'toto'
qs = Q(**{field + '__slug': 'AL'})
qs |= Q(**{field + '__isnull': True})

PS: You can start with qs = Q() if you need a loop.

Tagged as: No Comments

libmodbus v2.9.3 is out!

During this development cycle, I've received more feedback than for any other releases. That's really cool, thank you! With this new release, you can consider to migrate from the previous 2.0.x series for your applications.

libmodbus v2.9.3 (2011-01-14)

  • Major rewriting of the message reading (no more timeouts on exception)
  • New function to reply to an indication with an exception message modbus_reply_exception()
  • New function modbus_get_header_length(modbus_t *ctx)
  • New functions to manipulate data:
  • Fix GH-2. Read/write were swapped in _FC_READ_AND_WRITE_REGISTERS
  • Install an ignore handler for SIGPIPE on *BSD.
    Original patch by Jason Oster.
  • Fix closing of Win32 socket.
    Reported by Petr Parýzek.
  • Fix unit identifier not copied by the TCP server.
    Reported by Antti Manninen
  • Fix missing modbus_flush() in unit tests.
  • Fixes for OpenBSD by Barry Grumbine and Jason Oster

This time, the release is not only availabe as tarball but also as Fedora and Ubuntu packages on the download page.

For the next release, I've already merged my ipv6 branch (based on the work of Florian Forster), the rtai branch of Chris Cole is waiting for review (ah, RTAI, like in the good old days :) and I hope to take care of the gtk-doc work done by Luis Matos.


libsoup and Django

If you need to interface C code with a Django app, you should consider to use libsoup. It's a nice HTTP client/server library based on GObject and integrated with the glib main loop.

This is the code I used to authenticate with libsoup against my Django application (and the code is similar for any forms):

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>

#include <libsoup/soup.h>
#include <libsoup/soup-auth.h>

static char* django_get_csrftoken_from_body(SoupMessage *msg)
    char *csrftoken = NULL;
    char *p_found;

    p_found = g_strrstr_len(msg->response_body->data,
    if (p_found != NULL) {
    csrftoken = g_strndup(p_found + strlen("csrfmiddlewaretoken' value='"),
    return csrftoken;

static int django_authenticate(SoupSession *session, const char *base_uri)
    char *uri;
    SoupMessage *msg;
    char *csrftoken;

    uri = g_strconcat(base_uri, "login/", NULL);
    msg = soup_message_new(SOUP_METHOD_GET, uri);
    soup_session_send_message(session, msg);
    printf("Login Status Code: %d\n", msg->status_code);
    if (msg->status_code != 200) {
    return -1;

    csrftoken = django_get_csrftoken_from_body(msg);

    printf("CSRF token %s\n", csrftoken);

    msg = soup_form_request_new("POST", uri,
                "username", "MYUSERNAME",
                "password", "MYPASSWORD",
                "csrfmiddlewaretoken", csrftoken,
    soup_session_send_message(session, msg);
    printf("POST Login Status Code: %d\n", msg->status_code);
    printf("Message %s\n", msg->response_body->data);


    return 0;

int main(int argc, char** argv)
    SoupSession *session;
    SoupCookieJar *jar;


    session = soup_session_sync_new();

    /* Accept all cookies */
    soup_session_add_feature_by_type(session, SOUP_TYPE_COOKIE_JAR);
    jar = SOUP_COOKIE_JAR(soup_session_get_feature(session,
    soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_ALWAYS);

    django_authenticate(session, "http://localhost:8000/");


    return 0;

New libmodbus 2.9.2 with win32 support and backends

OK, I don't care about Windows but I'm happy libmodbus offers a bit of Open Source to this platform so thank you to Tobias Doerffel for this contribution. The other major change is the use of an internal backend to isolate the transport layers (only serial RTU and TCP/IPv4 for now).

libmodbus 2.9.2 (2010-12-05)

  • Fix segfault in bandwidth-server-many-up on inet_ntoa() call
  • Fix unit test of report slave ID in RTU
  • Fix GH-3. Remove inclusion of config.h in modbus.h
  • Correctly detect if we are cross
  • compiling for win32 by Kirill Smelkov.
  • Rename modbus_[listen|accept] to modbus_tcp_[listen|accept]
  • Fix setting of the broadcast address
  • Remove slave argument from modbus_new_rtu()
  • Win32 support by Tobias Doerffel
  • Split source code around RTU and TCP (backends)
  • Check received function code

So let's run your MinGW!