Posted by
Emilio Miguelanez Martin on
URL: http://imagej.273.s1.nabble.com/Reading-from-barcode-scanner-tp3697230p3697232.html
Curtis,
Thanks for your input, and I'll try on it using jusb.
However, I don't think I'll need an extra library. In the standalone
application, the standard input (System.in) works perfectly. Within
ImageJ, System.in does not work (as you pointed out), however if I open
a Text box or even generic dialog with a user input, it reads perfectly
from the barcode scanner, which it means that ImageJ gets the input from
the usb port. But I still need to be able to read the data directly from
the USB port (or maybe by scanning automatically the Text Box, and I do
not know how) so I can manipulate the data without the user walking back
to the computer to hit enter or click a button to tell the app its time
to grab the data.
Does it make sense to you?
Cheers,
Emilio
On Thu, 2008-02-07 at 12:48 -0600, Curtis Rueden wrote:
> 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
> >
--
Emilio Migueláñez Martín, PhD
Research Associate
Electrical, Electronic and Computing Engineering
School of Engineering and Physical Sciences
Heriot-Watt University
Riccarton
Edinburgh EH14 4AS
t: +44 (0) 131 4513357