Solved

PhP Bar Code Reader

Posted on 2006-07-23
25
539 Views
Last Modified: 2008-01-09
Hi,

Is it possible to use a bar code reader to input a string into a textbox in a form and hit the submit button or have an "on blur" event that automatically submits the form ?  

Would this interaction of the bar code reader and the form be feasible?

Thanks
0
Comment
Question by:sleekmedspa
  • 9
  • 5
  • 3
  • +2
25 Comments
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
ID: 17165938
My previous employment was developing EPOS systems. As part of my current employment, I am creating a touch screen web-based system that uses barcodes.

Most barcode readers are connected to a terminal (be it a PC or a thin client) by either the keyboard interface using a y-splitter (known as a keyboard wedge) or to a serial port.

When connected to the keyboard interface, the data from the barcode scanner is, at the bare minimum, the same as pressing the keys on the keyboard.

This can be enhanced to include an automatic cr/lf so it looks like you've typed the data and then pressed enter.

For a web form, the pressing enter may or may not be what you want.

You can further enhance the barcode data to include other "markers". Say the marker was 0xFE, data, 0xFF.

Now, using JS and the __window__ or __document__ onkeypress event handler, you could watch for 0xFE. When you received this, you know that the rest of the data coming , upto an 0xFF, is from the barcode. So, store it and do what you want with it. Place it in the form field.

One of the user issues with barcode scanning is that if a user accidentally scans a code at the wrong point in the application, the data is sent just as if it was typed.

Early on in my work when I just "assumed" the users knew what they were doing (I don't make that mistake any more), the number of of times someone paid 50 trillion+ pounds for an item at the EPOS system ....

By using data suffix and prefix markers, you can distinguish where the data has come from.


For those connected via a serial port, the issue is a little more complicated. If the host system supports the ability to convert the serial data to keypresses, then you are OK. Otherwise (and I've had to do this), you have to write your own serial data capture software. This is NOT really feasible for a web app.

If you are yet to buy a scanner, then I would strongly recommend a scanner which connects via the keyboard interface. No s/w installation required, completely transparent to the host and works with AT and PS/2 connections. I don't know about MAC or *ix connections, though I assume if the machine is intel based, then the motherboard will be supporting a PS/2 (or an AT if old) connection.

The serial connecting scanners were quite old when I first used them (probably 15 years ago). Since then, only keyboard based ones.

If you are generating your own barcodes, then choose one which is suitable to the data being contained within it.


Code 39 / Code 128 are the most popular for alpha numeric content.

Interleave 2 of 5 is purely numeric.
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17165972
@RQuadling
Interesting info!
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17165977
Thanks.
0
 
LVL 12

Expert Comment

by:AmigoJack
ID: 17166019
yes it is. but a barcode reader is nothing more than an input device, like a keyboard or a mouse. normally its been plugged along with the keyboard. normal barcode readers send WM_CHAR messages for each character plus #13 two times.

but all this has nothing to do with php at all...
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17166034
I've worked with MANY different barcode readers - some cabled (AT/PS2/Serial), others (and currently) RF.

They don't generate "WM_CHAR" messages - that is what you see because they are attached to the keyboard interface. I'm sure MAC and Linux would wonder what was going on if they receive WM_CHAR messages!!! And DOS has no messaging!

The CR/LF may SEEM to be #13 twice, but that is NOT normal. Most likely your scanner is programmed that way. As I've said, all the Symbol scanners I've used I can program to have more or less any prefix or suffix as I need for the application.

Currently I have a project where each RF based scanner is commissioned to include a prefix of a terminal location so we know for which terminal the scanner is generating data. No CRs in sight. As the scanners are not cabled the receiving base station needs to know which terminal the data has to be sent to. And only 1 base station for all the scanners.

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17166040
But, AJ is right. Not really a PHP question. Maybe a hardware quetion? Or at a minimum a JS one.

If your form has 1 input field then you can set focus on load and use the onchange event.

I would recommend changing the scanner's suffix to be a TAB rather than a CR/LF as some browsers will not submit automatically on a CR.

But a TAB will force a loss of focus which onchange can use.

0
 

Author Comment

by:sleekmedspa
ID: 17167488
very interesting. can you please tell me how the bar code stickers are generated usually? If I have products in the store and the product SKU is  PRO09092090K93L
than is this the code that would be created when the barcode sticker is created?

thanks
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17167829
Maybe. Maybe not.

The encoded data is normally printed in hrf (Human Readable Format) under the barcode.

But the data COULD theoretically be anything.

I assume you are only using 1d barcodes? (not fancy 2d).

Barcodes on things like a tin of baked beans are supplied to the beans manufacturer in blocks by the local numbering authority (like EAN - European Article Numbering). The authority gives a block of numbers to the manuafacturer to use how they wish. The manufacturer will often supply a list of codes and the descriptions to be used by shops etc. It tends to be bigger multi-shop companies that get these, though most manufacturers will be quite amenable to supplying the list.

In terms of generating your own barcoded labels, then you need appropriate software and hardware.

Things like the Epson TM-L60 Mark II is a great little cheap thermal label printer. Can also be used as a receipt printer, but not at the same time or just by changing paper. Others exist. You COULD use a normal office laser printer and print sheets of labels, but higher cost and you REALLY don't want the labels coming off the paper as it moves through the printer!!!!

For the application, then you can use something like word or excel with an appropriate barcode font (some barcode formats can be printed like text!! Very useful).

Or use a label printing app.

I have my own app written in Delphi. It has a label designer. Supports 1 to many up (so can print on sheets of labels). Supports about 20 different barcode formats.

Supports colour if your printer does.

Requires an external data file for the data to print.  You can also run the whole thing from the command line, so perfect for a web app wanting to print barcoded labels.



In my application "products" had many identifiers. The DB's internal row ID (unique), many different product codes (superceeded and redirected codes) each of which are unique and many barcodes (to allow for wrappers on those with discounts - same product but with a different price) again all unique.




0
 
LVL 12

Expert Comment

by:AmigoJack
ID: 17168428
RQuadling: when i answered i didnt see any comments yet, sorry :)

i didnt come that much in touch with scanners. here an application uses a special font (i think something like *850*.TTF) to make up a barcode instead letters and numbers. this is then printed and can be read by the barcode scanner. works flawless. but just to make sure if sleekmedspa thinks about that: barcode scanners can NOT be held on the screen to read barcodes (at least those i know).

barcoding everything for the case of archiving or catalogue-ing can become a handy thing - but it requires to be able to print a barcode into the physical world (i thought about using that for cd-archiving, but how do you print barcodes on the discs itself?? no im not talking about "...there are discs out there which can be colored by printers...") im drifting off :) sorry
0
 
LVL 7

Expert Comment

by:maUru
ID: 17170307
>> the number of of times someone paid 50 trillion+ pounds for an item at the EPOS system ....

Electronic Piece Of Shit system? :)
0
 

Author Comment

by:sleekmedspa
ID: 17178575
what tools can I use to print the stickers that I would stick on my products?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 29

Expert Comment

by:TeRReF
ID: 17179819
If you are looking for a barcode generator that's free, look here (it generates, prints and more...):
http://www.nonags.com/nonags/printer.html
0
 
LVL 12

Expert Comment

by:AmigoJack
ID: 17181780
if you want examples in various languages and a free TTF watch this:
http://grandzebu.net/informatique/codbar-en/code128.htm
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17182513
maUru - which is why, when a scanner is attached to the keyboard, you need do differentiate data coming from the scanner and data coming from the keyboard. The problem lasted for only a few days whilst the code was upgraded - no one had scanned a barcode when the screen was asking for the operator to enter the amount of cash being used to pay. It was a DOS app and is VERY VERY old now. But is still running in some places around the world.



I've got several barcode TTF fonts. You can use them in a mail merge to create a page of labels for a laser printer, or buy a dedicated barcode label printer (Epson TM-L60 Mark II - around £250 I think).

And the new Symbol Scanners which use photographic scanning techniques CAN read a barcode from a screen.

Older style (CCD and laser) cannot as they work on reflected contrasts. As a screen is actually glass, it cannot be "scanned" in that fashion.

We were looking at the ruggedized photographic scanners for our factory to be used to take photos as well as barcode scanning, but the scanner can only operate in 1 of the modes without reprogramming. We wanted an interleaved option - scan the product's serial number (as a barcode), take photograph of damage (optional).

0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17584046
Shouldn't RQuadling get the points?
0
 
LVL 7

Expert Comment

by:maUru
ID: 17585606
i second that
0
 
LVL 7

Expert Comment

by:maUru
ID: 17585608
(rQuadling gets points)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17590310
Thank you. It is interesting that with all the advances in technology, something that is as old as barcodes are still used.
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17590326
Think of the investments it would take to upgrade to a different technology :)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17590372
This is something we are looking at right now.

I work for a truck tyre remoulder (one of the largest in the Europe). We would really LOVE to get RFID tags, but not all products are stable enough either in themselves or their environment to support them. When a tyre comes to the end of the road (har har), and it is undamaged, the tag could be read, but when it explodes at 80mph on a motorway, there is very little you can do to track it to get it history.

Also, the tyre may not come back to us. Tyre starts as say a Goodyear, goes on a lorry. We manage that fleet and we expect to get the tyre when it is ready to be remoulded. Between us and the truck there are a LOT of people who can make money by doing their job badly. A tyre with a significant amount of tread on it can be worth several hundred pounds to them. It is all very dishonest.

No matter what you do to a tyre, there is no guarantee that ANY identifying marks will remain once the tyre comes off a truck.  RFID would very much help here. Not a 100% solution, but for tyres that come back and are acceptable for remoulding, then we can maintain a valid history. This then becomes about better fleet husbandry.

Hopefully, when the cost per unit of RFID tags comes down, we will be able to flood the tyre with tags. That way, as long as PART of the tyre can be returned to us when it fails in use, then we can track it against its known history and other unexepected failures.

For us barcodes are useless on the final product but completely essential now within our production system.

The investment is NOT insignificat, you are right.

RFID in shops though may be an issue. I know RFID CAN be used to track everything within a store (product leaving a shelf and entering a basket/trolley and leaving the store. Movement of trolley/basket around the store.

As someone who has worked on EPOS software, customer profiling is a REALLY interesting field of software development. Periodic trend analysis, seasonal changes/adjustments. Things like sporting events and weather all influence the customers buying pattern. Whilst is is obvious that you need to get the England flags in when England are about to play in the world cup, knowing how many, where to place them in the store, what other products to sell with them, etc are all supported though customer profiling.

0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17590433
Again, very interesting info!
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17590442
<grin />
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now