Writing SBIO backend in Python

Dear community,

all of the example I've found about writing SBIO backends using C.

Even if C is the most commonly used language in embedded development, we're facing some users that don't have big C expertise but have a good knowledge of Python.

For sure we can call SBIO C libraries from Python, but I'm wondering if you already have some example or, even better, Python binding to handle communication with sbengine

Kind Regards and TIA




  • Official comment

    Hi Andrea,

    What Corey mentions is the recommended approach today and from time to time we work with customers who want to use Python with Storyboard for various reasons.

    It is of course possible to create a Python extension that wraps our SBIO library.  I have been working on a prototype implementation that uses Python 3.7 and dictionary objects to represent Storyboard IO events.

    The primary objective for this was to enable users to do rapid prototyping of 'back-end' applications for Storyboard applications which are particularly useful for creating test scripts using Python.

    It is a work in progress and not yet ready for official release however below is an archive that includes a readme and a simple example of a test script that sends and receives events (it uses the same channel to send and receive as a loopback test).

    Python SBIO.zip

    There is still work to do on this wrapper library however if it is useful to you then I can share what I have currently on an unsupported basis and welcome your feedback and suggestions. In my experiments, I used this on a Raspberry Pi 4 for convenience.

    I would like to make this available through our public Github repository once it has been tested more effectively and is ready for release.

    I'll reach out to you separately to discuss the next steps.



  • Hi Andrea,

    I have worked with Python on several projects and while I've considered generating bindings for optimization purposes, it may be unnecessary for most use cases.  You can use the iogen command line utility (provided with Storyboard Engine, in the same bin/ directory as sbengine) to generate any IO event you need.  By writing a Python wrapper class (assembling events kind of like you would an SQL statement, then executing the iogen command) around this utility, which provides an interface appropriate to your project, I think you might find that works well enough.  You lose the convenience of using the autogenerated header file, but it is not necessary to use this in order to communicate with your application over SBIO.

    If optimization is a concern (ie. you expect a lot of events), then writing Python bindings might be a bit better approach than this, but ultimately will still incur a heavy cost vs generating your IO activity purely in C.  If you have Python devs and implementation convenience is your goal, the above suggestion should get you going in a few minutes.  Let me know if you'd benefit from a quick example script.

  • Dear Corey,

    thanks for you fast feedback!

    I'll suggest using iogen to our users. If you have any code example to share here, I think it may be useful for others too (this is the first and only hit in this community when searching "python" keyword ;-) )

    Kind Regards,


  • Hi Andrea,

    I have used the Storyboard API from within python using the the ctypes module to directly use the greio library from Crank.
    The only drawback is that you need a shared library for that. So hopefully at some point, crank can provide the shared library by default.

    If there is any interest, I can provide my code and an example of how I use it.

    Regards, Martin

  • Hey Garry Clarkson

    I'm doing something similar here, did you ever get anywhere with the wrapper? It would be useful to see what you had.



  • Hi James,

    I have updated the original response with the latest archive.




Please sign in to leave a comment.

Didn't find what you were looking for?

New post