Linux Fu: Scripting For Binary Files

If you ever need to write a binary file from a traditional language like C, it isn’t all that hard to do. About the worst thing you might have to deal with is attempts to fake line endings across Windows and Linux, but there’s usually a way to turn that off if it is on by default. However, if you are using some type of scripting language, binary file support might be a bit more difficult. One answer is to use a tool like xxd or t2b (text-to-binary) to handle the details. You can find the code for t2b on GitHub including prebuilt binaries for many platforms. You should be able to install xxd from your system repository.

These tools take very different approaches. You might be familiar with tools like od or hexdump for producing readable representations of binary files. The xxd tool can actually do the same thing — although it is not as flexible. What xxd can even reverse itself so that it can rebuild a binary file from a hex dump it creates (something other tools can’t do). The t2b tool takes a much different approach. You issue commands to it that causes it to write an original hex file.

Both of these approaches have some merit. If you are editing a binary file in a scripting language, xxd makes perfect sense. You can convert the file to text, process it, and then roll it back to binary using one program. On the other hand, if you are creating a binary file from scratch, the t2b program has some advantages, too.

I decided to write a few test scripts using bash to show how it all works. These aren’t production scripts so they won’t be as hardened as they could be, but there is no reason they couldn’t be made as robust as you were willing to make them.

Continue reading “Linux Fu: Scripting For Binary Files”

A LIDAR Scanner Build In Glorious Detail

LIDAR is a very exciting technology that is only just now starting to become accessible to the DIY market. Think radar, but with lasers. There’s a few different modules starting to pop up for just a few hundred dollars. But what is one to do with a LIDAR module? Well, [David] decided to build a room scanner with his Garmin LIDAR Lite, and it’s a wonderful sight to behold.

The scanner consists of a rotating platform, which is driven by a stepper motor. The platform then contains a second motor which runs a tilt axis, upon which the LIDAR is mounted. By aiming the LIDAR in various directions, and recording the detected range, it’s possible to build a point cloud representation of the surrounding area.

The build uses a couple of STM32 chips to do motor control and interface with the LIDAR, but where this build really shines is the mechanical side of things. [David] goes into serious detail about the machining of the parts that make up the rotating system, and there’s plenty of cool bits and pieces like slip rings to make it all work. There’s even some home casting going on here! Be warned, though: there’s some rather juicy close-ups of lathes in action, so put the kids to bed before watching this one all the way through.

We love to see a well-executed build, and even more so when we get to watch the intricate details of how it came together. If you’re still looking for some more inspiration, we’ve seen other LIDAR room scanners before, too.

Box Joint Jig Does Barcodes

Woodworking is the fine art of turning dead tree carcasses into precision instruments. That means breaking out the saws and chisels and making many, many precise cuts over and over. If you have a table saw, every problem becomes a piece of wood, or something like that, and we’ve seen some fantastic jigs that make these precision cuts even easier. We’ve never seen something like this, though. It’s a box joint jig for a table saw, it’s automated, and it puts barcodes on boxes.

[Ben] built this box joint jig a few years ago as a computer-controlled device that slowly advances a piece of wood on a sled, allowing him to create precise, programmable box joints. The design is heavily influenced from [Matthias Wandel]’s screw advance box joint jig, but instead of wood gears (heh), [Ben] is using the Internet of Things. Or a Raspberry Pi, stepper motor, and a few LEDs. Same difference.

Although [Ben]’s previous box joints were all the same size, a programmable box joint jig can do some weird-looking joints. That’s where [Ben] got the idea to encode a barcode in walnut. After using a web app to create a barcode that encodes the number 255 — this is important for later — [Ben] programmed his jig to cut a few slots.

The box was finished as you would expect, but there’s a neat addition to the top. It’s a combination lock that opens when the combination is set to 255. It’s brilliant, and something that could be done with some handsaws and chisels, but this jig makes it so easy it’s hard to think the jig wasn’t explicitly designed for this project.

Carousel Of Cereals Mixes And Matches Custom Breakfast Blends

There are those who reckon the humble bowl of breakfast cereal to be the height of culinary achievement. Look askance if you must, but cereal junkies are a thing, and they have a point. The magic comes not from just filling a bowl and adding a splash of milk, but by knowing which cereals to mix together.

Who needs all that fussy mixing, though, when you can automate and customize your cereal dispensing chores? That’s the approach [Kevin Obermann] and [Adrian Bernhart] took with their Cereal Dispensing Machine, even if they went a little further than necessary. Laser-cut plywood forms a four-station carousel for off-the-shelf dry-good dispensers, each of which got a stepper motor to replace the wrist-twisting. The original motors were a bit too wimpy to handle the more rugged morning selections and were eventually upgraded to gear motors. The platform that supports the dispensers also holds all the electronics, including an ESP32 to run everything and host the web app needed to choose your poison. Plus RGB LEDs, because breakfast should look like a rave. Sadly, the team ran out of GPIO pins and were unable to run the peristaltic pump needed to add the milk. There will always be version 2.0, though.

If cereal isn’t your automated breakfast of choice, we understand. Perhaps a more [Wallace] and [Gromit] style breakfast machine would do, or a robotic peanut butter sandwich any time of day is a treat.

Continue reading “Carousel Of Cereals Mixes And Matches Custom Breakfast Blends”

Vlogging With Vintage 1980s Equipment

[Dan Mace] decided to try vlogging 1980s style. To do this, he built Pram Cam — a one-man mobile video recording setup using vintage gear. [Dan] is a YouTuber from Cape Town, South Africa. His goal for this project was to motivate people to get out there and make videos. Smartphones, action cams, and modern video equipment all have made it incredibly easy to create content.

[Dan] reminds us of this by grabbing a vintage 1984 video camera – a Grundig vs150 VHS recorder. He couples the camera with a sturdy video tripod, blimp microphone, CRT TV as a monitor, and everything else needed for a period-accurate recording setup.

In a build sequence even the A-Team would appreciate, [Dan] tears down a rusty old three wheel pram, or baby carriage for the Americans out there. He then mounts the video setup to the pram frame using duct tape, zip ties, and a few odd pieces of wood. The result is a proper hacked off-road rolling video studio.

He then uses Pram Cam to film some of the great scenery in Cape Town — beaches, rocky cliffs, and even a helicopter ride. To say the pram was a bit more cumbersome than a cell phone would be the understatement of the year.

The video quality from the camera looks quite a bit worse than we would expect. Some of this may be due to Dan’s digitizing system though the chances are it’s from the camera itself. The Grundig captured video using a Saticon, which was Hitachi’s version of the video camera tube. That’s right, this is a tube based camera – no CMOS sensor, nor CCD. Tubes might not have Jello effect, but they do have all the blooming, motion blur, and other problems one might expect from a 34-year-old device.

What becomes of the Pram Cam? You’ll have to watch the video below to find out. Dan’s message is clear though: get out there and film something. Of course this is Hackaday, so if we’ll add that you should build something — then film it!

Continue reading “Vlogging With Vintage 1980s Equipment”

This Year, Badges Get Blockchains

This year’s hottest new advance in electronics comes through wearable badges. You can’t have failed to notice another technology that’s getting really hot. It’s the blockchain. What is a blockchain? It’s a linked list where every item in the list contains a cryptographic hash of the previous item in the list. What is a blockchain in English? It’s the most revolutionary technology that’s going to solve every problem on the planet, somehow. It’s the basis for crypto (no not that one, the other one). The blockchain is how you add more Lamborghinis to your Lamborghini account. Even though we’re still trying to figure out how it solves a single problem, one thing is certain: blockchains solve every problem. We were born too late to explore the Earth, born too early to explore the Universe, but just in time for blockchain.

Independent badges are always looking at the latest technology, and perhaps this was inevitable. It’s a badge built on the blockchain. It’s a wearable sneakernet of mining. It’s a game with collaborative proof of work.

The blockchain badge from [Mr Blinky Bling] is an independent badge for this year’s Defcon, and like most independent badges it’s loaded up with RGB LEDs, microcontrollers, and exquisitely crafted FR4. What makes this badge different is the add-ons, or ‘blocks’ that attach to the main badge through 1/8″ phono jacks. These blocks form the basis of the social game, where two badge holders trade blocks for a while, allow their badges to perform a proof of work on each block, and finally, each block is hashed and the score increased. Yes, this is a blockchain, but it’s more of a block-tree, and it runs on sneakernet instead of the Internet.

Yes, this does indeed all sound like a joke. Make no mistake, though: this is real. This is a hardware game built on blockchain technology, that some lucky badge holders will be playing at this year’s Defcon. It’s filled with blinky and blockchain. It’s awesome.

[Mr. Blinky Bling] has already started a project for this badge over on hackaday.io, and right now they’re running a Kickstarter campaign for this badge with delivery at Defcon. This is one of the more interesting badges that will be floating around the con this year, and it has blockchain. This really isn’t one to miss.

A Lightgun For LCDs – Thanks To Maths!

Light guns were a fun way to learn to shoot things on consoles, enjoying their heyday in the 80s and 90s. The original designs largely relied on the unique characteristics of CRT televisions and the timing involved in the drawing of their frames. Unfortunately, due to a variety of reasons (dependent on the exact techniques used), they typically do not work at all with modern LCD & plasma screens.

The light gun contains a camera, and reportedly works by using the distortion of the rectangular image of the screen to calculate the position of the light gun itself.

Recently, there has emerged a new project called the Sinden Lightgun. In the How It Works video, it seems to use a fairly standard 30fps camera inside the gun to image the television screen being used by the game. The display is then rendered in 4:3, letterboxed on a 16:9 aspect ratio display, within a rectangular bezel. The image from the camera is then processed, and the distortion of the game image is used to calculate the position of the gun and the direction of its aim. Processing is handled by the host computer running MAME and the requisite coordinates are fed back in to the game code.

The basic concept seems sound, though as always, there’s a healthy amount of skepticism around the project. We’d love to hear your take, on whether the concept is plausible, and whether the lag figures stated are cromulent. We’re always excited to see new developments in the lightgun space! Video after the break.

Our own [Will Sweatman] penned an excellent piece on a variety of ways one could resurrect the venerable game of Duck Hunt, too.
Continue reading “A Lightgun For LCDs – Thanks To Maths!”