Re: Reading from barcode scanner
Posted by
ctrueden on
Feb 07, 2008; 6:48pm
URL: http://imagej.273.s1.nabble.com/Reading-from-barcode-scanner-tp3697230p3697231.html
Hi Emilio,
You're using System.in to read from a USB barcode scanner? Don't you need
some kind of Java USB library like javax.usb (
http://javax-usb.org/) or jUSB
(
http://jusb.sourceforge.net/)?
There is no reason it shouldn't work pretty much the same from ImageJ as
from your standalone program. I doubt System.in works out of the box in
ImageJ, since ImageJ runs without a console and you would need to map some
other means of input like a text area to standard input. But I would be
surprised if you need to use standard input at all.
-Curtis
On Feb 6, 2008 5:58 PM, Emilio Miguelanez <
[hidden email]> wrote:
> Hello,
>
> I want to incorporate the reading of a barcode scanner into a plugin. The
> barcode scanner is connected through a USB connection.
>
> In a standalone program, I can acquire the reading by
>
> public static void main(String[] args) throws Exception{
> InputStream in = System.in;
> int b;
> while (true)
> {
> b = in.read();
> if (b==-1) break;
> // do something...
> System.out.println((char)b);
> }
>
> }
>
> But when I code it in imageJ plugin, it doesn't work. Basically, imageJ
> gets
> completely stuck (Not responding).
>
> Any ideas how to solve it?
>
> Thanks in advance,
>
> Emilio
>