Daemon that read barcodes and sends them over HTTP to a php script
-
28-10-2019 - |
Question
I am looking forward to build a prototype, which should be running completely headless and without user interaction, system should be able to start a barcode reader, send it over the internet to a php as file.php?code=var ...
Which is the simplest way to do this?
I am thinking off:
- windows-console app, some sort of ping...
- linux-console app, some sort of wget or stuff like that
Does anyone have a better approach.
System should be completely autonomous, plug it in, scan barcode, send code, repeat...
Solution
Your job can be divided into three main tasks:
- Get the Bar-Code value (not just a nice picture of it)
- Transfer the Code-Value to a remote PHP-Application
- process the data on the target. Out of scope.
There are lot of different possible ways to achieve this. But keep always in mind, that you don't have to re-invent the wheel:
- Bar-Code readers usually behave like an ordinary keyboard. A scanned code will be treated as an ordinary user input from the keyboard. A good Bar-code Reader can be configured to finalize its input with an enter-key (\r).
As already mentioned: Use the programming language you have good in command or you're curious about. You mentioned that the target system will be a PHP-Script, so the transfer console application could also be realized with PHP .
do while(true) { // wait for bar-code reader input $code = readline(); // transfer code to transfer($code); }
See PHP-Manual Readline-functiond for more details.