In a non-stop Mardi Gras event of the upcoming Coding4Fun Redesign, I got the green light from the awesome Dan Fernandez to release a Coding4Fun post here on Hanselman.com. This quick article will soon be published on the newly upgraded website along with a “Coding with the FingerPrint Reader” post and possibly a super-secret IR/Robot/PowerShell post.
Grab your CueCat and enjoy.
Coding4Fun Hardware Boneyard – Using the CueCat with.NET
Summary: In this rogue installment of the “Some Assembly Required” column, Scott Hanselman gets Travis Illig‘s CueCat BarCode scanner and creates a plugin for Windows Live Writer that allows him to blog more efficiently about the books he’s reading. We translate the bar code information, convert UPCs into ISBNs, call Amazon’s Web Service through REST, and integrate with Windows Live Writer all in one article. Whew!
The CueCat BarCode Scanner
Here’s what Wikipedia has to say about the CueCat BarCode scanner:
The: CueCat is a cat-themed portable barcode reader developed in the late 1990s by the now-defunct DigitalConvergence Corporation, which connected to computers using the PS/2 keyboard port and later USB. The: CueCat allowed users to connect to an Internet URL by scanning a barcode appearing in an article, brochure, or on some other printed matter. In this way, a user could be directed to a web page containing related information. The system that supported this functionality is no longer in operation.
Ah, nothing like the smell of outdated hardware to get me thinking. You can get CueCats anywhere, there are thousands of them, including on eBay. I asked around, and my friend Travis Illig lent me his. It’s ripe for hacking.
Translating the CueCat Output
The CueCat speaks a unique encoded format that it “types” as if it were a keyboard. For all intents, it IS a keyboard, as the PS2 version we’re using is set up in series with your existing (if you have one) keyboard.
My copy of Neil Gaiman’s outstanding “Stardust” produces this output:
C3nZC3nZC3nZE3r0Chr3CNnY.cGf2.ENr7C3n1C3PWD3rYCxzYChnZ.
Which can be separated into a series of tokens, some are one character and some are two. The periods are delimiters, so we’ll ignore them for now.
C3 n Z C3 n Z C3 n Z E3 r 0 Ch r 3 CN n Y EN r 7 C3 n 1 C3 P W D3 r Y Cx z Y Ch n Z
The first part is the identification number of the CueCat itself, which alarmed a lot of privacy folks in the past. The scanned barcode is actually the last part after the third delimiter:
EN r 7 C3 n 1 C3 P W D3 r Y Cx z Y Ch n Z
Each of these tokens is a key to a lookup table.