Scanning barcodes on Linux
7 posts • Page 1 of 1
Scanning barcodes on Linux
If it isn't offtopic...
Does anybody have expirience on reading barcodes on Linux?
A little introduction.
Everything is pretty simple (on a first sight).
We have barcode scanner connected to serial port.
The device is accessible as file '/dev/ttyS0' or '/dev/ttyS1', so all that you need is open this pseudo-file and read data from it.
like this (perl source):
===8<===
open(SERIAL,"</dev/ttyS1") or die "can't open port\n";
while (<SERIAL>)
{
print "$_"
}
===8<===
but, of course, port does need some configuration before opening. 'stty' is a command to do this, and it has a lot of options. This seems to fit our needs:
'stty -F /dev/ttyS1 9600 -parenb -parodd clocal raw'
(set baud rate to 9600, disable all translations)
And now the problem.
Everything OK for ASCII data.
And everything OK with binary data.
Unless that binary data is spread across number of Macro PDF417 symbols.
Even in this case 90% barcodes are read OK, but remaining 10% make scanner stop responding.
It seems to me that stty settings aren't just all right, but I cannot figure out what I've missed...
Does anybody have expirience on reading barcodes on Linux?
A little introduction.
Everything is pretty simple (on a first sight).
We have barcode scanner connected to serial port.
The device is accessible as file '/dev/ttyS0' or '/dev/ttyS1', so all that you need is open this pseudo-file and read data from it.
like this (perl source):
===8<===
open(SERIAL,"</dev/ttyS1") or die "can't open port\n";
while (<SERIAL>)
{
print "$_"
}
===8<===
but, of course, port does need some configuration before opening. 'stty' is a command to do this, and it has a lot of options. This seems to fit our needs:
'stty -F /dev/ttyS1 9600 -parenb -parodd clocal raw'
(set baud rate to 9600, disable all translations)
And now the problem.
Everything OK for ASCII data.
And everything OK with binary data.
Unless that binary data is spread across number of Macro PDF417 symbols.
Even in this case 90% barcodes are read OK, but remaining 10% make scanner stop responding.
It seems to me that stty settings aren't just all right, but I cannot figure out what I've missed...
- vnaum(Legacy Member)
Re: Scanning barcodes on Linux
Well, everything was pretty simple.
Port options were ok, the problem was in terminal settings.
(In Linux serial ports are terminal lines).
Turning echo off ("-echo") does the right things.
So, my final stty settings are:
stty -F /dev/ttyS0 9600 raw -parenb -parodd clocal -echo
(Just guess) It seems like one of "interrupt, quit, and suspend special characters" was echoed back to port when scanner was unready (between PDF segments).
Port options were ok, the problem was in terminal settings.
(In Linux serial ports are terminal lines).
Turning echo off ("-echo") does the right things.
So, my final stty settings are:
stty -F /dev/ttyS0 9600 raw -parenb -parodd clocal -echo
(Just guess) It seems like one of "interrupt, quit, and suspend special characters" was echoed back to port when scanner was unready (between PDF segments).
- vnaum(Legacy Member)
Re: Scanning barcodes on Linux
Hi,
I am interested in your perl/barcode solution, kind of confused as to how to implement it. Could you give some more information,
Thanks in Advance,
M
I am interested in your perl/barcode solution, kind of confused as to how to implement it. Could you give some more information,
Thanks in Advance,
M
- kingmonty(Legacy Member)
Re: Scanning barcodes on Linux
Well, it isn't too much of a solution
It's mostly an example of how you can do this. But here you are:
http://www.lab321.ru/~nvy/barcode/download/autoscan.zip
Yes, you are free to use it as you want - it's GPL
Of course, patches, additions and fixes are welcome.
It's mostly an example of how you can do this. But here you are:
http://www.lab321.ru/~nvy/barcode/download/autoscan.zip
Yes, you are free to use it as you want - it's GPL
Of course, patches, additions and fixes are welcome.
- vnaum(Legacy Member)
Re: Scanning barcodes on Linux
Hi Vnaum,
thank you very much
It works perfectly. I will send you an example of how we implemented it.
Ta,
M
thank you very much
It works perfectly. I will send you an example of how we implemented it.
Ta,
M
- kingmonty(Legacy Member)
Re: Scanning barcodes on Linux
Why do I read the following message while I am trying to access the URL -
http://lab321.ru/~nvy/barcode/download/autoscan.zip wrote:
vnaum wrote:
Is it still open to the public ?
Thanks
http://lab321.ru/~nvy/barcode/download/autoscan.zip wrote:
Forbidden
You don't have permission to access /~nvy/barcode/download/autoscan.zip on this server.
--------------------------------------------------------------------------------
Apache/1.3.26 Server at www.lab321.ru Port 80
vnaum wrote:
Well, it isn't too much of a solution
It's mostly an example of how you can do this. But here you are:
http://www.lab321.ru/~nvy/barcode/download/autoscan.zip
Yes, you are free to use it as you want - it's GPL
Of course, patches, additions and fixes are welcome.
Is it still open to the public ?
Thanks
- Guest
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests