I got into a new hobby recently: Amateur (a.k.a. Ham) Radio. This article will be a collection of resources I believe are worth sharing in that context: YouTube channels, books, and links to study material. I will also present some things I’ve experimented with in the last few months.
[Read More]
Cross-compiling for Raspberry Pi: QEMU User Emulation and Dynamic Linking
This is a follow-up to an article I wrote back in 2019 that was about linking statically against libc. This time we are going to take a look at an alternative way: dynamic linking.
[Read More]
Controlling a Wallbox via Modbus-RTU
When operating a photovoltaic (PV) system at home in 2022, we usually want to make good use of the electrical energy harvested by the system – instead of feeding too much excess energy back into the grid. While this is definitely true for the setup we’re operating here (in Germany),...
[Read More]
ARM Assembly hands-on: Transmitting serial frames in software
We’re going to be taking a look at a (transmit-only) UART implementation in pure assembly language. We will use this as an example to walk through some basics of the ARM instruction set, and also to show some concepts of the architecture.
[Read More]
Prototyping with MicroPython
A recent toy project of mine involves controlling SPI devices through an STM32 MCU. Right from the beginning, I expected a lot of prototyping-style back-and-forth so I thought this would be a great opportunity to get to know MicroPython.
[Read More]
Git diff colliding with the shell: special characters
It sounds simple enough: You would like git to show local changes, but considering certain file types only. Something like git diff *.h usually does the job but in some cases yields unexpected results. We’re going to find out what this is about in this article.
[Read More]
Lingering Services -- How to prevent systemd from killing my processes after I log off?
This is about some recent experience I had with systemd on the Raspberry Pi. The idea was to set up a process to continuously run in the background as user ‘pi’, so I decided to give systemd’s user services a try (as opposed to the system ones). It turns out...
[Read More]
How to Deal with a 4-bit Wrapping Counter
Today’s article will be about integers and twos’ complement representation. It feels a bit like a follow-up on the previous one, where we did some experimenting with twos’ complements on narrow integer types. This time we are going to think more about how twos’ complement may help us handling counter...
[Read More]
Tinkering with signed integers in C
Recently I came across 4-bit signed integers. While I just wanted to make sense of them somehow in the first place, I thought that’s a nice opportunity to dig deeper.
[Read More]
SPI bus: Clock Polarity and Clock Phase by example
After some months, here’s finally an article about a truly Embedded topic! We are going to take a quick look at the two basic parameters you want to carefully adjust when setting up an SPI bus: Clock Polarity (CPOL) and Clock Phase (CPHA).
[Read More]
Git Snapshots Revisited
A great way to approach Git, I believe, is to explore its inner workings. To do that, let’s take a closer look at an analogy I made up previously, and create some useful graphs from real repositories.
[Read More]
KNX Link-Layer Ack: A brief analysis.
KNX is a two-wire bus for building automation. It operates at a pretty low bitrate, which makes it a good candidate for analyzing communications using a cheap logic analyzer. This article is about the Acknowlegement procedure at the KNX Link Layer.
[Read More]
Raspberry Pi: How to cross-compile against third-party libraries
Cross-Compiling for Raspberry Pi can become pretty challenging as soon as third-party libraries get involved. Using the sysroot concept together with rsync, it’s easy to keep those libraries synchronized between your host and target system.
[Read More]
Software Design Challenges: Embedded vs. Web
Sometimes, Embedded is considered a very special field of Software Engineering. It’s all about microcontrollers and complex devices, connected via a plethora of different bus systems – carefully orchestrated using only the C programming language. Let’s go and find out what’s so special about Embedded, and what our discipline has...
[Read More]
Git in a nutshell: Commit, Checkout, Reset
We’re going to talk about three basic git commands in this episode: commit, checkout and reset. Instead of making up any abstractions or metaphors, we will focus straight on how these commands modify your repository’s internal state.
[Read More]
3 Practical Uses of void Pointers in the C Language (part 3/3)
Part 2 was all about encapsulation, Abstract Data Types and how void pointers may help you implement these concepts. In this third and last part, we are going to see yet another use of them. After that, we will go and find out how void pointers are used in popular...
[Read More]
3 Practical Uses of void Pointers in the C Language (part 2/3)
In Part 1, we talked about how to use void pointers for implementing generic interface functions. Now we’re going to see how to take advantage of them to hide implementation details.
[Read More]
3 Practical Uses of void Pointers in the C Language (part 1/3)
Probably every beginner’s book on C programming has a section on pointers. Usually, there are also one or two paragraphs on the topic of void pointers. Have you ever asked yourself what they can actually be used for? In this article, we will explore some practical uses for pointers of...
[Read More]
How to Cross-Compile for Raspberry Pi on Ubuntu Linux in 5 Steps
This is about how to set up a cross compiler for the Raspberry Pi and use it for building target executables from C source code. Additionally, we are going to talk about how to set up userspace emulation – enabling you to execute target binaries on your host system transparently....
[Read More]
Embedded Programming: Loose Coupling Best Practices (Part 3/3)
After talking about decoupling units at the linker level in part 2, this last part of the series is going to be about achieving the same goal, but at the preprocessing stage of the build process. At the end of the article, you will find a comparison of all three...
[Read More]
Embedded Programming: Loose Coupling Best Practices (Part 2/3)
After talking about decoupling at the object level in part 1 of this series, we are going to explore another method in this article. This will be based on yet another stage of the software build process – the linking.
[Read More]
Embedded Programming: Loose Coupling Best Practices (Part 1/3)
When creating Embedded Software, system complexity that grows over lifetime makes it increasingly harder to reason about certain behaviors of the program. As always in engineering, it helps to divide one big problem into several smaller problems in order to be able to eventually solve it. This is what this...
[Read More]
Git: Compare feature branches to master (Part 2/2)
In the previous article we’ve seen how to ask Git for changes introduced by a particular branch. This time, instead of changes, we would like to know which commits were introduced by a branch – that is, the hashes assigned to them.
[Read More]
Git: Compare feature branches to master (Part 1/2)
This article shows how to display changes in Git feature branches that are not yet merged into master.
We are going to find a simple answer for that simple question, starting off with basic git diff commands.
[Read More]
Debugging on the Command Line
Do you use a GUI debugger? Chances are that it is backed by the GNU Debugger, gdb, somehow. Wouldn’t it be great to use that backend directly? In this article, we are going to highlight some strengths of gdb’s command-line interface over GUI frontends.
[Read More]
Worse Than Duplication
Here are some thoughts on refactoring, especially on how to deal with duplicate code.
[Read More]
Stand-alone TDD monitor using 'entr'
Have you ever thought of something that continuously monitors your project’s source tree and triggers a unit test build upon file changes? You want it to be independent of the editor or IDE you use? Then maybe this is for you.
[Read More]
Fixing Typos while Writing -- Two Ideas
Here are some thoughts on text editing. No matter what kind of text you write – source code, articles, to-do lists, books – there’s always a chance you get a single letter wrong at one point. Depending on your touch typing skills, this might not happen very often. But when...
[Read More]
C Bitshift Operator Revisited
Recently someone asked me about C’s bitwise shift operator, specifically about what it does to signed integers. To be honest, until then I haven’t even considered applying the left or right shift operator to anything else than unsigned numbers. So let’s figure out what this is about.
[Read More]
Undo Feature Using Git Plumbing Commands
Have you ever thought about adding an undo feature to your application? This blog article is an attempt to approach that task by utilizing some internals of the Git version control system together with the Memento design pattern. But please, don’t take this too seriously :-).
[Read More]
Hex Parser
This article is about creating a parser for HEX files, a format that is often used as an intermediate step for programming microcontrollers. Although there are – of course – implementations out there already, I would like to use this as a welcome opportunity to play around with some interesting...
[Read More]
From Subversion to Git: Snapshots
What does it mean that we talk about snapshots of our Git repository, while in Subversion we think in terms of file changes? For me at least, the key to understanding Git is that every commit is, in fact, a snapshot of the entire project. Not a list of patches....
[Read More]
Bash Job Control
When working on the command line, you may sometimes find yourself in a situation where you’d like to start a new program while another long-running process (e.g. an editor) is blocking the current terminal. In the course of this article we are going to find out how to achieve quick...
[Read More]
Introduction To Readline
When developing command line applications, you will most certainly want to have bash-like line-editing features. For that, an excellent choice is the GNU readline library. We will see in this article how to use its features from out own programs in order to provide a user experience similar to that...
[Read More]
Non-Interactive Text Editing in Vim
The Vim text editor has its roots in the traditional line-based editors of the early days. Due to that heritage, it supports a set of impressively powerful Ex commands that act on individual lines. In this article, we will see how to create a script composed of these commands and...
[Read More]
Vim Errorformat Challenge
The Vim text editor provides built-in support for parsing compiler output. It has quite a broad understanding of the concept of a compiler though: You can call just any command and let the editor parse its output. For this to work correctly, format strings need to be specified, matching the...
[Read More]
Discovering Refactoring Needs
This article is about creating a plot of complexity over change rate for a given set of source code files. According to an idea I’ve seen on twitter last week, this might help us finding spots in the code that have an influence on how well a project goes. Here...
[Read More]
Maintaining A Clean History In Centralized Git Workflows
Git is a powerful tool for versioning (not only) source code files. It is decentralized by design but also works perfectly for setups that rely on a central server. By using a standard pull/push workflow though, the central history can grow complex pretty fast. In this article we will look...
[Read More]
Linux Shebang Insights
In Linux, you can execute an interpreted script file in exactly the same way as you would execute a compiled binary: by setting the ‘executable’ attribute and just run it. A special sequence of characters at the beginning of the script makes this possible. In this article we will explore...
[Read More]
The Shell And The Whitespace
When writing conditionals in shell scripts, have you ever wondered whether that whitespace right after the opening bracket is really necessary for the expression to evaluate correctly? You might be surprised by the answer we’ll discover in the course of this short article.
[Read More]
What Makes A Unit Of Code Falsifiable
In his recent book about Software Architecture, Robert C. Martin a.k.a. Uncle Bob describes programming as a discipline of science, rather than mathematics. In one of the first chapters of the book he talks about Structured Programming and how it enables us to produce – according to the scientific method...
[Read More]
Thoughts on Python from a C++ developer’s viewpoint: Style
This article is about Python style. Compared to the C++ world, there are pretty rigid conventions implemented in the language itself as well as in the Python ecosystem. That makes this topic kind of surprising and worth writing some lines about.
[Read More]
Thoughts on Python from a C++ developer’s viewpoint: Interfaces
In this episode I‘d like to highlight yet another Python fact I find
particularly surprising. This article is about the design tool in Software Engineering: interfaces.
[Read More]
Thoughts on Python from a C++ developer's viewpoint: Inside the interpreter
In this second article of the series on Python we're going to cover some really great features of the interactive interpreter. We'll see that a full-fledged debugger may not even be necessary to get serious work done in Python.
[Read More]
Thoughts on Python from a C++ developer's viewpoint: Class members
In this series of articles I will present some random things I've noticed when I started studying the Python programming language a while ago. I'm actually not very experienced in the language yet, as I don't get in touch with it that often. But I think if you also do...
[Read More]
Test-driven 7-Segment Decoder
This article is about creating a 7-segment display decoder in software. While this is probably considered a rather trivial task, it will serve as a good example for the discipline of Test-Driven Development (TDD). The motivation for a test-driven approach in this case is simple: being able to refactor later...
[Read More]
The bash debugger: an example
Sometimes you may find yourself in a situation where you need to actually debug a shell script you're currently writing. Especially in the initial phase of development, features like single-stepping feel quite handy. I this article we are going to look at two situations where the bash debugger (bashdb) is...
[Read More]
AVR sleep mode for fun and profit (part 2)
In the first part of this article we managed to put the AVR into power-down mode and were thereby able to lower the current consumption in idle mode to 0.0 mA. While this is great compared to the 22 mA before any optimization, there is no way to wake up...
[Read More]
AVR sleep mode for fun and profit
Today's blog article is about how to optimize the power consumption of an AVR microcontroller running on batteries. We're going to explore one of the ATmega32's sleep modes and how it affects power consumption. We will eventually reach a state where it actually makes sense to power the device from...
[Read More]
TDD - Should I mock or should I not?
Today I'm going to share an observation I made recently, related to Test-Driven Development (TDD).
[Read More]
Test-driving the MCP2515 CAN Controller (Part 3): Taking a look at the SPI bus
In this episode of the series we are going to focus a bit more on the target hardware. The driver code created during the previous two episodes is going to be compiled for the target microcontroller and programmed into flash memory. While it's only the reset functionality of the MCP2515...
[Read More]
Passing heavy C++ objects by value
Big objects are traditionally passed to methods by reference. Some weeks ago I talked to a colleague about that and decided to investigate a bit further. As a result of my research I must admit that, starting with C++11, things have indeed changed. Depending on what happens inside the body...
[Read More]
Background make execution in Vim 8
Version 8 of the Vim text editor introduced a great new feature for executing processes asynchronously. In this article I'm going to show you a plugin that makes use of these async jobs and how I utilize them to build a C++ project in the background.
[Read More]
Test-driving the MCP2515 CAN Controller (Part 2)
It turns out the device driver design established previously has a serious drawback. While the SpiDriver interface enables unit testing, the cost of polymorphism has to be paid also in production code. In this article you are going to see how high that cost is, i.e. how much extra code...
[Read More]
Test-driving the MCP2515 CAN Controller (Part 1)
So you are pretty much into Test-Driven Development (TDD)? You love to practice it on your development machine but think it might be quite a hassle when it comes to writing code for small microcontrollers? In this blog article we are going to take a journey to Embedded TDD using...
[Read More]