Squoze Your Data

I have a confession to make. I enjoy the challenge of squeezing software into a tiny space or trying to cut a few more cycles out of a loop. It is like an intricate puzzle. Today, of course, there isn’t nearly as much call for that as there used to be. Today even a “small” microcontroller has a ton of memory and resources.

Even so, there’s still a few cases where you need to squeeze those last few bytes out of memory. Maybe you are trying to maximize memory available for some purpose. Maybe you are anticipating mass production and you are using the smallest microcontroller you can find. Or maybe you’re doing the 1 kB Challenge and just want some advice.

One way to find techniques to maximize resources is to look at what people did “in the old days.” Digital Equipment computers once had a special character set called Squoze (or sometimes DEC Radix-50). This technique can be useful when you need to get a lot of strings into memory. The good news is that you can reliably get 3 characters into 2 bytes (or, as DEC did, 6 characters into 4 bytes). The bad news is that you have to pick a limited character set that you can use. However, that’s not always a big problem.

Continue reading “Squoze Your Data”

Jenkins and Slack Report Build Failure! Light the Beacons!

When you have a large software development team working on a project, monitoring the build server is an important part of the process. When a message comes in from your build servers, you need to take time away from what you’re doing to make sure the build’s not broken and, if it’s broken because of something you did, you have to stop what you’re doing, start fixing it and let people know that you’re on it.

[ridingintraffic]’s team uses Jenkins to automatically build their project and if there’s a problem, it sends a message to a Slack channel. This means the team needs to be monitoring the Slack channel, which can lead to some delays. [ridingintraffic] wanted immediate knowledge of a build problem, so with some software, IoT hardware, and a rotating hazard warning light, the team now gets a visible message that there’s a build problem.

An Adafruit Huzzah ESP8266 board is used as the controller, connected to some RF controlled power outlets via a 434MHz radio module. To prototype the system, [ridingintraffic] used an Arduino hooked up to one of the RF modules to sniff out the codes for turning the power outlets on and off from their remotes. With the codes in hand, work on the Huzzah board began.

An MQTT broker is used to let the Huzzah know when there’s been a build failure. If there is, the Huzzah turns the light beacon on via the power outlets. A bot running on the Slack channel listens for a message from one of the developers saying that problem is being worked on, and when it gets it, it sends the MQTT broker a message to turn the beacon off.

There’s also some separation between the internal network, the Huzzahs, and the Slack server on the internet, and [ridingintraffic] goes over the methods used to communicate between the layers in a more detailed blog post. Now, the developers in [ridingintraffic]’s office don’t need to be glued to the Slack channel, they will not miss the beacon when it signals to start panicking!

Think You Know C? Find Out

I’ve had the fortune or misfortune of interviewing a lot of job candidates over the years. It amazes me how often someone will claim to know something, sound reasonable, but then if you quiz them on it, it becomes really obvious that they don’t know much. To flush this out, we had a three-question test that would tell you a lot. People who got the right answer were ahead of the game, of course, but even looking at how people approached the answer (right or wrong) would tell you a lot, too.

I remember one case where the answer involved casting a value. A candidate had impressed me until faced with the question to which he said (more or less): “Well, there’s this function. I think it is called ‘cast’…” I think the look on my face told him that I actually knew the answer (not surprising, since I was giving the test) and that wasn’t it.

[Oleksandr Kaleniuk] has a C quiz of only five simple questions. They reminded me of at least one of my old company’s three-question quiz. I don’t want to say too much about the character of the test because I don’t want to give away the answers, but if you think you are a C wizard, go check it out. Then come back in the comments and tell us how you did. Just try to avoid posting spoilers (although you should probably avoid the comment section until you come back).

Continue reading “Think You Know C? Find Out”

Codebender Shuts Down

Codebender.cc was a cloud based IDE for Arduino development. It was made for hackers by a few fellows in Greece. Unfortunately, while they saw some serious success, they were never able to convert it all the way into a viable business.

By November 31st Codebender.cc will be completely shut down. They assure users that the site will be in read-only mode for as long as the end of the year, but longer if the traffic justifies it. Codebender made it all the way to 10,000 monthly active users, but hosting and administration overshadowed this success to the tune of 25,000 dollars a month. Not so much as far as businesses go, but without revenue it’s more than enough to shut down a site. Their business plan aimed to tailor their services for specific chip manufacturers and other companies but those deals never came together.

It’s a pity, we were excited to see if Codebender could continue to grow. They were certainly doing some really interesting stuff like remote code upload. As the comments on the site show, many users, especially educators and Chromebook users, loved Codebender — your code isn’t stuck on one computer and where there was a browser there was an IDE.

Two paid services will remain (starting at $10/month) at addresses with different TLDs. But the post does mention that the Codebender project started as Open Source. Their GitHub repo isn’t a clear path for rolling your own, but if you do manage to hack together a working Codebender implementation we’d love to hear about it.

RadarCat Gives Computers A Sense of Touch

So far, humans have had the edge in the ability to identify objects by touch. but not for long. Using Google’s Project Soli, a miniature radar that detects the subtlest of gesture inputs, the [St. Andrews Computer Human Interaction group (SACHI)] at the University of St. Andrews have developed a new platform, named RadarCat, that uses the chip to identify materials, as if by touch.

Realizing that different materials return unique radar signals to the chip, the [SACHI] team combined it with their recognition software and machine learning processes that enables RadarCat to identify a range of materials with accuracy in real time! It can also display additional information about the object, such as nutritional information in the case of food, or product information for consumer electronics. The video displays how RadarCat has already learned an impressive range of materials, and even specific body parts. Can Skynet be far behind?

Continue reading “RadarCat Gives Computers A Sense of Touch”

This EAGLE Script Gets Quotes For Your Boards

Weary of manually entering manufacturing parameters into PCBShopper’s web form, [Jeremy Ruhland] created an awesome shortcut: His ULP script lets you obtain quotes from 26 PCB manufacturers around the world directly from your EAGLE board layout.

The script extracts all relevant data from your layout, including board size, the layer count, minimum trace widths and hole diameters. It then let’s you specify a few more in a tidy dialogue before sending you to the PCB manufacturing price comparison site PCBShopper.com with a custom query for board quotes.

It works like a charm, and [Jeremy] also plans to add a shortcut button to the EAGLE layout editor’s toolbar. Since the script implements the entire PCBShopper API, for which [Jeremy] cooperates with PCBShopper.com owner [Bob Alexander], it’s also a great starting point for the development of scripts that work with other board layout tools.

Thanks to [Matthew Venn] for the title photo (via Flickr)!

Code Craft – Embedding C++: Multitasking

We’re quite used to multitasking computer systems today. Our desktops run email, a couple of browsers in different workspaces, a word processor, and a few other applications, apparently all at once. Looking behind the scenes using a system monitor or task manager program reveals a multitude of other programs running in support of our activities. Of course, any given CPU is running a maximum of one program at a time. Multitasking is simply the practice of switching between active processes fast enough to give the illusion of simultaneity.

The roots of multiasking go way back. In the early days, when computers cost tons of money, the thought of an idle system was anathema. Teletype IO was slow compared to the processor, and leaving the processor waiting idle for a card reader to slurp in the next card was outrageous. The gurus of the time worked to fill that idle time with productive work. That eventually led to systems that would run multiple programs at one time, and eventually to more finely grained multitasking within a program.

Modern multitasking depends on support from the underlying API of an operating system. Each OS uses its own techniques, making it difficult to write portable code. The C++ 2011 standard increased the portability of the language by adding concurrency routines to the Standard Template Library (STL). These routines use the API of the OS. For instance, the Linux version uses the POSIX threading library, pthread. The result is a minimal, but useful, capability for building upon in later standards. The C++ 2017 standard development activities include work on parallelism and concurrency.

In this article, I’ll work through some of the facilities for and pitfalls in writing threaded code in C++.

Continue reading “Code Craft – Embedding C++: Multitasking”