Barcode Scanner Settings for Uppsala English Bookshop

: Uppsala English Bookshop (my favorite bookstore, and former employer) got themselves a new barcode scanner.—This last happened when I was in their employ, and since I hacked that one to behave nicely, they now asked me to do it again. Nothing much needed, after each scan it should just enter tab-tab-tab to move to the next input field in the cash register system.

While the old scanner had a nice and easy setup for programming, this new one was sorta devilish. The manual says you should print the barcodes required set the options you need. (It also goes on to give terse cryptic descriptions of the options available, and much lengthier descriptions of various—perfectly googlable—barcode standards).

In the end, this is what my favorite bookstore needed:

String #1 – Termination Character – Three Tabs
FNC3 + 0202011000$09$09$09
String #1 – Disable Termination Character

In the end I managed to decipher the options tables, and barcode composition descriptions of the manual and produce the above custom Code 128 barcode.—Harder than it sounds, since the program barcode has to include an FNC 3 control code, which most barcode generators promptly refuse to generate (or make it impossible to insert). However, I found the Perl module Barcode::Code128 which—after some coercion—did the job intended.

To install the required stuff under Ubuntu/Debian use the command “aptitude install libgd-barcode-perl libbarcode-code128-perl”, then copy/paste the following little program which writes the above ‘Three Tabs’ barcode on standard out.

#!/usr/bin/perl
use Barcode::Code128 qw(:all);
my $barcode = new Barcode::Code128;
$barcode->border(0);
$barcode->transparent_text(1);
$barcode->show_text(0);
$barcode->height(70);

# In the string passed to encode() below, space means "00",
# exclamation mark means "01", double quote means "02", and
# asterisk means "10". See also the character table on the
# Wikipedia article on "Code 128".

# string #1 - termination char - 3 x tab
$barcode->encode(
    FNC3 . CodeC . '""!* ' . FNC4 . '$09$09$09',
    'B'
);
print $barcode->png();

Easy, peasy—right?