Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

serial barcode scanner + perl

by BigGuy (Friar)
on Oct 05, 2001 at 01:25 UTC ( [id://116838]=perlquestion: print w/replies, xml ) Need Help??

BigGuy has asked for the wisdom of the Perl Monks concerning the following question:

Greetings all,
I am having trouble with a little project i am working on I have a serial barcoder, on /dev/ttyS0, which i can read
from fine from a little perl program or by just using cat on the port. My problem is that i need to direct the output
of the serial port to the keyboard, so anything you barcode goes to the active window in either KDE or gnome. Has anyone
done anything like this before our EE guy here suggested writing an xwindows event handler that would watch the port
but I just keep thinking i gotta be able to do this with perl somehow or another. I have looked around the web and
anytime you search for barcode scanner all you get back is about hacking your cuecat :-( any ideas appreciated

BigGuy "One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler

Replies are listed 'Best First'.
Re: serial barcode scanner + perl
by tommyw (Hermit) on Oct 05, 2001 at 03:42 UTC

    Can you just redirect STDIN from the port? So instead of myapp, you invoke myapp < /dev/ttyS0?

    Assuming that works, but you want merge the keyboard and barcode reader (so you can use either as an input device), you could write a small program which reads a character from whichever device offers a character first, and then throw that at STDOUT (a reverse version of tee), then pipe this into your program: eet /dev/ttyS0|myapp.

    Just a thought... Might well not work

Re: serial barcode scanner + perl
by jlongino (Parson) on Oct 05, 2001 at 04:27 UTC
    I'm not sure exactly what you want, but your task is similar to a few programs I've written in Basic and Pascal (not in Perl yet). You'll probably want to modify your program that reads the port to redirect that output to a file (use "\n" to define one swipe as one file record). Better yet write to a database of some sort that also stores date/time of swipe and some autonumber key (whatever you need). This process runs 24/7 if necessary.

    Write another program that monitors the file/database for new/unprocessed records (keep a log of the records that you've successfully read/processed, or include a flag for that in each database record as well). You can run this at whatever terminal you want and echo the raw/processed results to the screen.

    As far as the monitor program is concerned, it doesn't know/care whether the input is coming straight from a port or file.

    Hope this helps.

    "Make everything as simple as possible, but not simpler." -- Albert Einstein

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://116838]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found