Linux Reads Bar Codes
With the wand connected to the serial port of the PC, our kernel device driver code has only to raise DTR to high to turn on the power to the wand. We can then read the modem status line called Data Carrier Detect to sample the video signal being generated by the wand. Some circuit diagrams refer to this signal as Received Line Signal Detect (RLSD). Our driver module will turn the wand power on when we install the module and leave it on. Spurious data is created when the power is toggled, so we leave power on all the time whenever the device driver is installed. We turn the wand power off only when the driver module is removed by our ``cleanup'' routine. To keep the kernel side code ``too small to cause trouble'', the device driver read function of our kernel module, when called by user-side code, simply samples the state of the DCD line and returns that state to the calling program. While the 100Hz interrupt that takes control back to the kernel finds little or nothing to do there, the delay created is uniformly merged into the delay loop of our software timer, which then appears to work just fine.
On the back cover of most trade books these days you will find a Bookland bar code for the ISBN, followed usually by what is called a price extension that states a recommended retail price for the book. When we scan a Bookland bar code and its price extension, we should find exactly 91 bars: 46 black and 45 white. The first three bars are black, white, black; each of these bars is one unit wide. These are the so-called ``left guard bars''. The next 24 bars encode the left group of six digits. Four bars are used to encode each digit in a white, black, white, black, pattern. Each of these bars can be one, two, three or four width-units wide, but the total width of the four-bar digit pattern must be exactly seven width units. The first ISBN digit, by the way, usually a ``9'', and usually printed in the clear at the left of the bar code pattern, is not represented in the bar code.
Following the six digits of the left group we find the five ``middle guard bars''. These bars are white, black, white, black, white; each one unit wide. The next 24 bars encode the right group of six digits. Again, four bars encode each digit, this time in a black, white, black, white, pattern; just the opposite of the ink pattern used for digits in the left group of six digits. The right group of six digits is followed by three unit-width ``right guard bars'', black, white, black, that mark the end of the ISBN bar code.
Following the ISBN portion of the bar code there is a large white space that provides the ``quiet zone'' in front of the price code extension. This quiet zone will be read as one large white bar. Next we see a unit-width black bar, a unit-width white bar and then a black bar two units wide. These three bars are the price extension guard bars.
Following the price extension guard bars we find the price extension itself in the form of five encoded decimal digits. For example, a book with price digits 51695 means that the book has a recommended retail price of $16.95 US. (The first five indicates that the price is in US dollars. Prices over $100 would be impossible for the present scheme to handle.) Each digit is encoded with four bars (white, black, white, black, just as in the left group of the ISBN), but here, two additional unit-width bars (white, black) are inserted into each gap between digits. These are the so-called price code extension inter digit ``delineators''. In our software that decodes bar data, we pretty much ignore both the guard bars and the inter digit delineators. Possibly the redundant bars could be used to help calibrate a scanner if that turned out to be needed. The algorithm that we use here just steps over the guard bars and interdigit delineators and works with the groups of four measured bar times for each digit. Guard bars and delineators are, of course, assumed to be present in the captured data, and so in a sense they do provide framing information, somewhat like serial line start and stop bits.
The EAN ``symbology'' used by Bookland, encodes the decimal digits 0 through 9, using four bar widths. Each bar can be one, two, three or four units wide. Each encoded decimal digit occupies exactly seven units of bar space, so the sum of the four bar widths for any digit must be seven. Scanner software that decodes the bar code will make use of that. In terms of bar widths, the code looks like that shown in Table 1.
The left group of six digits uses bar patterns from groups A and B; the right group of six digits uses patterns from group C. A bar width pattern uniquely identifies a decimal digit. In terms of bar width, as we can see here, there are just 20 distinct bar-width patterns.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Petros Koutoupis' RapidDisk
- ServersCheck's Thermal Imaging Camera Sensor
- The Italian Army Switches to LibreOffice
- Linux Mint 18
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Varnish Software's Varnish Massive Storage Engine
- Firefox 46.0 Released
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide