Crash your code – Lessons Learned From Debugging Things That Should Never Happen™

Let’s be honest, no one likes to see their program crash. It’s a clear sign that something is wrong with our code, and that’s a truth we don’t like to see. We try our best to avoid such a situation, and we’ve seen how compiler warnings and other static code analysis tools can help us to detect and prevent possible flaws in our code, which could otherwise lead to its demise. But what if I told you that crashing your program is actually a great way to improve its overall quality? Now, this obviously sounds a bit counterintuitive, after all we are talking about preventing our code from misbehaving, so why would we want to purposely break it?

Wandering around in an environment of ones and zeroes makes it easy to forget that reality is usually a lot less black and white. Yes, a program crash is bad — it hurts the ego, makes us look bad, and most of all, it is simply annoying. But is it really the worst that could happen? What if, say, some bad pointer handling doesn’t cause an instant segmentation fault, but instead happily introduces some garbage data to the system, widely opening the gates to virtually any outcome imaginable, from minor glitches to severe security vulnerabilities. Is this really a better option? And it doesn’t have to be pointers, or anything of C’s shortcomings in particular, we can end up with invalid data and unforeseen scenarios in virtually any language.

It doesn’t matter how often we hear that every piece of software is too complex to ever fully understand it, or how everything that can go wrong will go wrong. We are fully aware of all the wisdom and cliches, and completely ignore them or weasel our way out of it every time we put a /* this should never happen */ comment in our code.

So today, we are going to look into our options to deal with such unanticipated situations, how we can utilize a deliberate crash to improve our code in the future, and why the average error message is mostly useless.

Continue reading “Crash your code – Lessons Learned From Debugging Things That Should Never Happen™”

Anatomy Of A Cloned Piece Of Hardware

What would you think if you saw a bootleg of a product you design, manufacture, and sell pop up on eBay? For those of us who don’t make our livelihood this way, we might secretly hope our blinkenlight project ends up being so awesome that clones on AliExpress or TaoBao end up selling in the thousands . But of course anyone selling electronics as their business is going to be upset and wonder how this happened? It’s easy to fall into the trap of automatically assigning blame; if the legit boards were made in China would you assume that’s where the design was snagged to produce the bootlegs? There’s a saying about assumptions that applies to this tale.

Dave Curran from Tynemouth Software had one of his products cloned, and since he has been good enough to share all the details with us we’ve been able to take a look at the evidence. Dave’s detective work is top notch. What he found was surprising, his overseas manufacturer was blameless, and the bootleg board came from an entirely different source. Continue reading “Anatomy Of A Cloned Piece Of Hardware”

Oreo Construction: Hiding Your Components Inside The PCB

In recent months, the ability to hide components inside a circuit board has become an item of interest. We could trace this to the burgeoning badgelife movement, where engineers create beautiful works of electronic art. We can also attribute this interest to Bloomberg’s Big Hack, where Jordan Robertson and Michael Riley asserted Apple was the target of Chinese spying using components embedded inside a motherboard. The Big Hack story had legs, but so far no evidence of this hack’s existence has come to light, and the companies and governments involved have all issued denials that anything like this exists.

That said, embedding components inside a PCB is an interesting topic of discussion, and thanks to the dropping prices of PCB fabrication (this entire project cost $15 for the circuit boards), it’s now possible for hobbyists to experiment with the technique.

But first, it’s important to define what ‘stuffing components inside a piece of fiberglass’ is actually called. My research keeps coming back to the term ’embedded components’ which is utterly ungooglable, and a truly terrible name because ’embedded’ means something else entirely. You cannot call a PCB fabrication technique ’embedded components’ and expect people to find it on the Internet. For lack of a better term, I’m calling this ‘Oreo construction’, because of my predilection towards ‘stuf’, and because it needs to be called something. We’re all calling it ‘Oreo construction’ now, because the stuf is in the middle. This is how you do it with standard PCB design tools and cheap Chinese board houses.

Continue reading “Oreo Construction: Hiding Your Components Inside The PCB”

Hack Your Gmail: A Quick Start for Google App Scripting

For many people, Gmail is synonymous with e-mail. Some people like having cloud access to everything and some people hate having any personal data in the cloud. However you feel about it, one thing that was nice about having desktop software is that you could hack it relatively easily. If you didn’t like how your desktop mail client worked, you had a lot of options: use a different program, write your own, hack the executable of your current program, or in the case of open source just fork it and make any changes you are smart enough to make.

Google provides a lot of features with all of its products, but however you slice it, all the code runs on their servers out of your reach. Sort of. If you know JavaScript, you can use Google Apps Script to add features to many Google products including Gmail. If you’ve used Office scripting, the idea is the same, although obviously the implementation is very different.

With scripting you can make sophisticated filters that would be very hard to do otherwise. For example,  monitor for suspicious messages like those with more than 4 attachments, or that appear to come from a contact between the hours of 2AM and 5AM.

For our example today, I’m going to show you something that is easy but also highly useful.

Continue reading “Hack Your Gmail: A Quick Start for Google App Scripting”

Sharpest Color CRT Display is Monochrome Plus a Trick

I recently came across the most peculiar way to make a color CRT monitor. More than a few oscilloscopes have found their way on to my bench over the years, but I was particularly struck with a find from eBay. A quick look at the display reveals something a little alien. The sharpness is fantastic: each pixel is a perfect, uniform-colored little dot, a feat unequaled even by today’s best LCDs. The designers seem to have chosen a somewhat odd set of pastels for the UI though, and if you move your head just right, you can catch flashes of pure red, green, and blue. It turns out, this Tektronix TDS-754D sports a very peculiar display technology called NuColor — an evolutionary dead-end that was once touted as a superior alternative to traditional color CRTs.

Join me for a look inside to figure out what’s different from those old, heavy TVs that have gone the way of the dodo.

Continue reading “Sharpest Color CRT Display is Monochrome Plus a Trick”

Plastics: Acrylic

If anything ends up on the beds of hobbyist-grade laser cutters more often than birch plywood, it’s probably sheets of acrylic. There’s something strangely satisfying about watching a laser beam trace over a sheet of the crystal-clear stuff, vaporizing a hairs-breadth line while it goes, and (hopefully) leaving a flame-polished cut in its wake.

Acrylic, more properly known as poly(methyl methacrylate) or PMMA, is a wonder material that helped win a war before being developed for peacetime use. It has some interesting chemistry and properties that position it well for use in the home shop as everything from simple enclosures to laser-cut parts like gears and sprockets.

Continue reading “Plastics: Acrylic”

New Contest: 3D Printed Gears, Pulleys, and Cams

One of the killer apps of 3D printers is the ability to make custom gears, transmissions, and mechanisms. But there’s a learning curve. If you haven’t 3D printed your own gearbox or automaton, here’s a great reason to take the plunge. This morning Hackaday launched the 3D Printed Gears, Pulleys, and Cams contest, a challenge to make stuff move using 3D-printed mechanisms.

Adding movement to a project brings it to life. Often times we see projects where moving parts are connected directly to a servo or other motor, but you can do a lot more interesting things by adding some mechanical advantage between the source of the work, and the moving parts. We don’t care if it’s motorized or hand  cranked, water powered or driven by the wind, we just want to see what neat things you can accomplish by 3D printing some gears, pulleys, or cams!

No mechanism is too small — if you have never printed gears before and manage to get just two meshing with each other, we want to see it! (And of course no gear is literally too small either — who can print the smallest gearbox as their entry?) Automatons, toys, drive trains, string plotters, useless machines, clockworks, and baubles are all fair game. We want to be inspired by the story of how you design your entry, and what it took to get from filament to functional prototype.

Continue reading “New Contest: 3D Printed Gears, Pulleys, and Cams”