Reading STM32 unique device ID using OpenOCD

When working with the STM32 family of microcontrollers, it can be useful to evaluate the factory-programmed 96-bit UUID using JTAG. On all major operating systems, OpenOCD provides a simple yet highly compatible and free solution in order to do this.

In this example, we’ll use a JLink adapter together with the Olimex E407 evalation board. Both the adapter and the board are interchangable, provided you have working OpenOCD configurations available.

Continue reading →

Posted by Uli Köhler in Embedded

Extracting open library author names using Haskell Conduits

Almost anyone productively using Haskell has already stumbled upon Michael Snoyman’s Conduit library.

In this post I will show how to leverage the power of Conduit interleaved IO in order to parse author’s names from the Open Library data dumps.

Using traditional languages like Java or C, it would be significantly more difficult and error-prone to interleave the processing pipeline actions of

  • Downloading the file ol_dump_authors_latest.txt.gz using HTTP
  • Decompressing using a gunzip-like function
  • Splitting into lines and discarding everything but the JSON from said lines
  • Appropriately decoding the JSON and extracing the name field, or ignoring the line if parsing is not possible
  • Writing all said names into a files (authors.txt in this example), one per line.

Continue reading →

Posted by Uli Köhler in Haskell

Yet another Atom Arduino blinker

While experimenting with Atom I produced a minimal example for making my old Arduino Uno blink its LED periodically.

Although there are plenty of examples out there (some of them even work!) I didn’t want to introduce any dependency to the Arduino libraries. Besides making it harder to build (even if arscons is quite nice) it increases the object size and Arduino only supports a limited range of processors. I need the flexibility to use the code on controlles like the ATTiny45

Continue reading →

Posted by Uli Köhler in Allgemein, Embedded

Using QuasiQuotation for more readable Atom code

Lately I’ve been experimenting with using Atom to generate intrinsically reliable embedded software.

In contrast to alternatives like Copilot in Atom you include the surrounding C code as Haskell strings whereas other concepts just generate a set of C files to include in your main code.

Continue reading →

Posted by Uli Köhler in Haskell

How I solved my Toshiba Linux backlight issues


I have both the Toshiba Z830 and R850 for a couple of years now. On both, I’m using the current LTS versions of KUbuntu (at the time of writing this, 14.04). Although, I’m absolutely satisfied with them, there’s a little issue regarding the backlight:

On startup, the backlight works perfectly well. I can change the settings using FN+F6/F7 without any issues. However, after putting the device into standby and waking it up again, pressing said hotkeys shows the backlight percentage dialog, but does not change the brightness.

Because Ubuntu’s SSD reboots are pretty fast Iimply didn’t care about the issue for the past few years. However, out of curiosity, I successfully fixed the issue today.

Continue reading →

Posted by Uli Köhler in Linux

Parsing the OUI database in Haskell

In this post, we will show a method and provide a Haskell module capable of parsing both the IEEE OUI list and the IEEE IAB list.

While our code only parses the databases into an object form and doesn’t insert them into a tree capable of fast MAC address -> vendor lookup, it is based on Attoparsec, providing good performance and high flexibility for changes.

Continue reading →

Posted by Uli Köhler in Haskell

How to resolve ‘Can’t perform this operation for unregistered loader type’


Recently I started to add unit tests using setuptools to one of my packages.

In order to do this, I added a test directory containing was properly setup using the



However, when running

python test

I got this error message:

running test
running egg_info
writing MyPackage.egg-info/PKG-INFO
writing top-level names to MyPackage.egg-info/top_level.txt
writing dependency_links to MyPackage.egg-info/dependency_links.txt
reading manifest file 'MyPackage.egg-info/SOURCES.txt'
reading manifest template ''
writing manifest file 'MyPackage.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "", line 29, in <module>
    'Topic :: Scientific/Engineering :: Information Analysis'
  File "/usr/lib/python3.4/distutils/", line 148, in setup
  File "/usr/lib/python3.4/distutils/", line 955, in run_commands
  File "/usr/lib/python3.4/distutils/", line 974, in run_command
  File "/usr/lib/python3/dist-packages/setuptools/command/", line 135, in run
  File "/usr/lib/python3/dist-packages/setuptools/command/", line 116, in with_project_on_sys_path
  File "/usr/lib/python3/dist-packages/setuptools/command/", line 160, in run_tests
    testLoader = cks
  File "/usr/lib/python3.4/unittest/", line 92, in __init__
  File "/usr/lib/python3.4/unittest/", line 139, in parseArgs
  File "/usr/lib/python3.4/unittest/", line 146, in createTests
  File "/usr/lib/python3.4/unittest/", line 146, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.4/unittest/", line 146, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.4/unittest/", line 117, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/lib/python3/dist-packages/setuptools/command/", line 26, in loadTestsFromModule
    for file in resource_listdir(module.__name__, ''):
  File "/usr/lib/python3/dist-packages/", line 954, in resource_listdir
  File "/usr/lib/python3/dist-packages/", line 1378, in resource_listdir
    return self._listdir(self._fn(self.module_path,resource_name))
  File "/usr/lib/python3/dist-packages/", line 1415, in _listdir
    "Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type

Continue reading →

Posted by Uli Köhler in Python

Haskell: Invert filter predicate

Problem: In Haskell, you intend to filter with an inverted filter operator.

For example, your code is (GHCi):

Prelude> import Data.List
Prelude Data.List> filter ( isPrefixOf "a" ) ["a","ab","cd","abcd","xyz"]

The list you need is ["cd","yz"]. In some cases, the easiest solution would be to use for example <= instead of >, but there isn’t a literal complement for all functions, like for example isPrefixOf, which is being used in the example.

Continue reading →

Posted by Uli Köhler in Haskell

Buffer-overflow safe readlink() in C++


You want to use readlink() to get the file or directory a symbolic link points to, but you don’t know the buffer size that is required to store the symlink destination. You don’t want to allocate an incredibly large amount of memory (whatever amount you choose, it could always be insufficient), but you won’t risk buffer overflows.

Continue reading →

Posted by Uli Köhler in C/C++

Accessing NCBI FTP via rsync

A little-known way of accessing data on the NCBI FTP servers is by using rsync. This method was first mentioned in this mailing list post in 2004.

Using rsync instead of ftp has a few key advantages

  • Fully incremental downloads
  • Resumable downloads
  • Faster than FTP
  • Only a single connection, no problems with FTP active/passive ports (e.g. important for dual-stack lite, e.g. see this excellent post in german )

Continue reading →

Posted by Uli Köhler in Bioinformatics

Solving ‘invalid multibyte escape: /^\xFE\xFF/’ in ruby vpim


When using Ruby 2.0/2.1 with the vpim gem (tested with version 0.695), you get an error message similar to this:

/usr/local/rvm/gems/ruby-2.1.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': /usr/local/rvm/gems/ruby-2.1.0/gems/vpim-0.695/lib/vpim/vcard.rb:678: invalid multibyte escape: /^\xFE\xFF/ (SyntaxError)

Continue reading →

Posted by Uli Köhler in Allgemein