Question

Within my iOS App I am using a 3rd party scanning library for scanning Code39 barcodes. This software sometimes gets the scan wrong (e.g. a value of "13415566" comes back as "U *"). Sometimes the same barcode works ok, then scan the same code again and it is wrong.

The 3rd party software vendor reports that Code39 isn't a 'reliable' format, and that 'it has no error protection and it is often possible to get false reads'.

This seems ridiculous to me. The codes in question have no check-digit, but even so, surely this is simply a bug in the scanning software? Is Code39 known for this sort of thing? How can it possibly be an adopted format if it 'gets it wrong' sometimes!

Thanks.

Was it helpful?

Solution

There should be no major issues with Code 39 readability. When used in applications where reliable scanning is important Code 39 is normally deployed with protection against misreads in the form a modulo 43 check digit that the scanner is configured to verify prior to passing the code on to the system. Any half-decent barcode generator or barcode reader will support Code 39 check digits.

As I haven't seen the print quality of the Code 39 barcodes that your are scanning it is impossible to be certain however I would certainly suggest that you are using reader software that has very poor quality Code 39 scanning.

Your barcode library is probably confused for the following reason, but it is impossible to be sure without extensive debugging of the device...

Below I have aligned two Code 39 images that were created using the online barcode generator based on Barcode Writer in Pure PostScript. On top is a horizontally flipped image containing "U" and beneath is an image containing "13415566".

Two code 39 barcodes aligned

Reading the top image from right-to-left you can see that there is a degree of similarity with some portion of the bottom image.

A scanner might be forgiven for the misread of this unprotected Code 39 except that it has following against it:

  • It should be expecting a quite zone (whitespace) before the leading start bars sequence.
  • It should be expecting a quite zone after the trailing stop bars sequence.
  • The bar pattern for "U" is not entirely correct.
  • The assumed stop bar sequence is not entirely correct.

OTHER TIPS

Many barcode scanners read black and white sections on a single line. They have no clue as to whether the line is horizontal, vertical, or diagonal, and have no inherent means of knowing if the line "enters" a barcode on one side and leaves at the other, or if it enters via the top, crosses the barcode diagonally, and exits via the bottom.

Some barcode formats like Interleaved 2 of 5 start and end with patterns which can commonly occur within a barcode [I2of5 starts with BwBw and ends with BBwB], and it is possible for a partial scan which slips off the top or bottom to be misread as though it were a valid scan of a shorter code. Some other barcode formats start and end with patterns that are chosen so that there is no way a partial scan can read as valid data. Code 39 is somewhere between.

Every valid code 39 barcode starts with BwBBwBBwwBw and ends with wBwBBwBBwwB. It is possible to have the sequence wBwBB to appear at the end of one character and BBwwBw to appear at the start of the next, with a single "w" between them. If two such pairs of characters appear within a barcode, a limited variety of characters appear between them, and the scan exits the first pair at just the right place and likewise exits the second pair at just the right place, it is possible that the scanner would see a legitimately-formed barcode whose content bore no apparent resemblance to the original. Someone who deliberately chose barcode data that met the necessary criteria and tried to scan it at an angle to generate a false read would have little trouble getting false reads from many scanners, but both the data and scanning angle would have to be "just right" in order to cause problems.

If one is concerned about the possibility of such misreads, it is possible to print barcodes in such a way as to guarantee that a scan which leaves the code will not be seen as valid. A simple way of doing this is to print black above and below the barcode, so that any scan which enters and/or exits via the top or bottom will perceive the code as starting and/or ending with an exceptionally thick black bar. In many places where one sees "stacked" barcodes, they will be separated by a pattern of dots which do not hold information, but are instead designed to ensure that a scan which crosses from one row to another cannot be perceived as valid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top