Archive for the 'C/C++' Category

Creating Time-Consistent Loops for Embedded Systems

In an embedded system there are typically four main ways to architect the code: Simple loop, foreground-background, cyclic executive, and RTOS. In this article I will look at how to create a simple main loop with a time-consistent execution period, similar to what a cyclic executive does.

Continue reading ‘Creating Time-Consistent Loops for Embedded Systems’

Ardunio Programming: C++ and Embedded Systems

Ideally we would use assembly language to wring the last drop of performance from small microcontrollers, and at one time that really was the only way to do it. But assembly language programming is tedious and error-prone, and if I never have to wrestle with another assembly language program that would be fine with me.

With the advent of C, things got a lot easier in the embedded systems world. As its creators stated, C is essentially a close relative of an assembler, rather like a macro assembler (there’s a good Google/Wikipedia topic, if you don’t know what a macro assembler is). A C program can be compiled into very tight and efficient code, with an almost one-to-one correspondence to the underlying assembly language that the compiler generates.

But times change, and things are extended, improved, and expanded, and thus C++ arose from C. Over time C++ has become one of the dominant languages in programming, but there are challenges when attempting to use it with a microcontroller. Continue reading ‘Ardunio Programming: C++ and Embedded Systems’

Fear of the Unknown

Humans are strange creatures. In general we like things to be nice and predictable; the same tomorrow as today, and the same as yesterday. I don’t have any hard data to reference, but I suspect that, overall, the human race is rather conservative. We don’t like new things that challenge our current beliefs and knowledge. This is ironic, considering that we now live in a time where change is about the only reliable constant, and new things are appearing at an astounding pace. Continue reading ‘Fear of the Unknown’

Wrestling with Visual Studio

A few months ago I had a relatively large C++ source code set for a suite of applications dropped into my lap. Well, that’s OK, I don’t mind C++, but what I did mind was that it was all written using Visual Studio.

It’s been a long time since I had to work with Windows code, and now that I’ve waded through line after line of code and  wrestled with Visual Studio along the way, I’ve recalled now why I don’t like working with Windows.

Continue reading ‘Wrestling with Visual Studio’

Visual Debuggers

A visual debugger is a like an addictive mental drug. It’s fascinating to look at, very helpful at times, and it can become a crutch. Just as with alcohol or other drugs, a little bit can be fun and help get you to where you want to be, but too much can derail you. Allow me to explain.

I do most of my development on Linux (OK, I actually do ALL of my development on Linux or something similar like Solaris or BSD–I don’t do Windows) in C, C++, or Python. When the need arises to be able to peer into the code and see what, exactly, is causing an annoying fault I use gdb or DDD (a GUI front-end for gdb) for C and C++. For Python I use tools like winpdb or Eclipse with the Python IDE plug-in.

Continue reading ‘Visual Debuggers’

C++, CUDA, Python, and Really Big Cameras

I can’t believe this blog is still here. Amazing. I figured WordPress would close it down by now.

A lot has happened since the last entry. My book was released by O’Reilly (and it’s been doing OK), I came down with a severe case of food poisoning (and ended up in the ICU), and some months later had triple-bypass open-heart surgery (and another stay at the Hotel ICU). Fun times.

Here’s a link to the book, if you’re interested (shameless self-promotion):

http://shop.oreilly.com/product/9780596809577.do

and of course it’s also available on Amazon.

Continue reading ‘C++, CUDA, Python, and Really Big Cameras’

INI Files

So-called “INI” files are ubiquitous. You can find them on Unix systems, Windows platforms, and even in the flash memory of embedded systems. I even once wrote my own INI parser for some software on a embedded diskless VME control system running WindRiver’s VxWorks. It allowed us to upload new configuration and control parameters on-the-fly in a human-readable format. Very handy.

Continue reading ‘INI Files’

Free PNG Book Available On-Line

I recently stumbled across this whilst sifting through the Weird Wild Web:

PNG
The Definitive Guide
Greg Roelofs
O’Reilly 1999

pngbook-cover-1.jpg

Released under the GNU Free Documentation License, V1.1.
http://www.libpng.org/pub/png/book/

If you deal with image processing software then you really need to know about PNG. Superior to JPEG for images containing sharp edges and step gradients (i.e. line art and such), PNG uses a non-patented lossless data compression method. While it won’t compress down as much as JEPG, it also doesn’t suffer from high-frequency signal loss, generation loss and compression artifacts (checkerboarding and such). Also see the Wikipedia article on PNG:
http://en.wikipedia.org/wiki/Portable_Network_Graphics

Some Thoughts On Software Testing and Software Test Engineering

Software testing is an artform, and, make no mistake about it, a good software test engineer is an artist.

Software testing often gets a bad rap as being “dull”, “boring” or something that the goofy wonk down the hall does, but that the hotshot developers don’t bother themselves with. I used to view testing as an evil necessity as well, until I discovered how challenging it could be.

Continue reading ‘Some Thoughts On Software Testing and Software Test Engineering’

Building Better Device Interfaces

I recently encountered an interesting example how not to implement a control interface for an external device. The devices in question here are two laser products from the same company that do essentially the same thing. The problem is that the software for each of the controller units seems to have been developed in sealed rooms with little or no cross-communication between them. I’m not going to name any names, mainly because other than the command set silliness these are good products, but I’ve suffered enough at the hands of some unknown yahoo (or group of yahoos) that I felt compelled to write up a quick “lessons learned”. I will refer to these two products as controller A and controller B.

Continue reading ‘Building Better Device Interfaces’


Follow Crankycode on WordPress.com

Little Buddy

An awesome little friend

Jordi the Sheltie passed away in 2008 at the ripe old age of 14. He was the most awesome dog I've ever known.