Block Linux from sending usb barcode scanner chars to the console

Go To StackoverFlow.com

2

For a customer, i wrote an middleware to let him access the serial port, or serial port over network using an ethernet adapter, and read data using a webservice.

He recently asked to add too support for reading data from a barcode scanner, stuff that i've implemented reading events directly from the device (/dev/input/eventX or /dev/input/by-id/xyz).

The barcode scanner is attached directly to the server and data are being readed through a webservice exposed by my webserver.

All works fine, except that barcodes are recived by the linux console!

How can i "block" (stop) the system from sending stuff to the console?

NOTE: no X11/Xorg or nothing else, the server is a console only machine! Barcodes are readed by javascript (jsonp) executed on an android tablet

2012-04-04 21:59
by Daniele Salvatore Albano
It may be helpful if there is a bit more code to work with. However, let me suggest an obvious solution: Did you try closing the stdout file descriptor [close(0)] - Bhaskar 2012-04-04 22:05
@BhaskarUpadhyayula stdout is fd 1 - FatalError 2012-04-04 22:09
@FatalError thanks for pointing out the mistake - Bhaskar 2012-04-04 23:52
@BhaskarUpadhyayula you can edit your earlier comment. - blueshift 2012-04-05 00:48
Maybe i badly explained the problem. The barcode scanner works as an usb hid, as an usb keyboard, and is the system itself that write on the console. My application read input events from /dev/input devices to catch chars and, obviously, it doesn't print out anything because it's a webserver and this works fine. I need to block the operative system from sending barcode keys (usb keyboard) to the active console - Daniele Salvatore Albano 2012-04-05 07:30


1

Check /etc/inittab to see if a getty is running on that serial port. If it is, comment out the line by inserting a # as the first character.

2012-04-04 22:09
by Adam Liss
LOL, doing this i'll kill my only way to access the system in case of problems (i'm working on alix boards). No way : - Daniele Salvatore Albano 2012-04-05 07:32
Good plan. No fair adding constraints after you've asked the question! :- - Adam Liss 2012-04-05 11:01
well, it isn't a new constraint :) if you kill getty you can't access the system :) However, in the end, probably i'll disable auth loggin - Daniele Salvatore Albano 2012-04-05 13:46


0

It depends on your Linux distro. On Redhat/Centos, you can turn off or filter console messages by editing /etc/syslog.conf and /etc/sysconfig/syslog.

2012-04-04 22:08
by qux
thank you for the suggestion, in this way i can skip failed auth logs, but i want to avoid them at all : - Daniele Salvatore Albano 2012-04-05 07:31


0

Presumably the barcodes are getting to the console either because you are running the server process from a startup script and it is outputting to stdout/stderr, or they are some kind of system log or kernel messages.

Assuming they are standard output, find where the server is run in your startup scripts, and redirect the output to file or /dev/null, e.g.:

noisy-server-cmd >/dev/null 2>&1 &
2012-04-05 00:51
by blueshift
Barcodes gets to the console only because it's seen as an usb keyboad and it's the system itself that send the barcodes chars to the active console. I want to disable this - Daniele Salvatore Albano 2012-04-05 07:34
Ads