[Rxtx] error getting InputStream
Keith Thorne
hambyiii at hotmail.com
Fri Aug 4 07:08:11 MDT 2006
Hi,
I know I am replying to myself a lot at the moment, but more information has
come to light (These errors are actually happening on a client machine, on
software that has worked for the past month, and only now has started to
fail, which is why I am a little slow finding things out)
The errors I have already written about are only symptoms of an orignal
error. The original error occurs the first time I try to WRITE thte
OutputStream:
OutputStream oStream = serialPort.getOutputStream();
serialPort.notifyOnOutputEmpty(true);
byte[] bs = encodeMessage(configString.toString());
oStream.write(bs);
oStream.flush();
The error occurs on oStream.write(bs); and is:
Input/output error in writeArray
Now writeArray is native code, so I have no idea what is going on there. Any
help would be appreciated
Thanks
Keith
>From: "Keith Thorne" <hambyiii at hotmail.com>
>Reply-To: RXTX Developers and Users <rxtx at qbang.org>
>To: rxtx at qbang.org
>Subject: Re: [Rxtx] error getting InputStream
>Date: Fri, 04 Aug 2006 11:42:21 +0000
>
>Okay, I made a little mistake in my last message.
>
>The error is not occuring where I thought it was. Instead it is occuring
>when I do the following:
>
>byte[] readBuffer = new byte[128];
>
>try {
>
> int numBytes = 0;
> try {
> Thread.sleep(500);
> }
> catch (InterruptedException e)
> {}
>
> while (inputStream.available() > 0)
> {
> numBytes = inputStream.read(readBuffer);
> }
>
> processReceivedData(readBuffer, numBytes);
>}
>catch (IOException e)
>{
> System.out.println(e.getMessage());
>}
>
>So I guess the error is happening on the inputStream.read(readBuffer)
>
>again, any help is appreciated and again, thanks in advance
>Keith
>
> >From: "Keith Thorne" <hambyiii at hotmail.com>
> >Reply-To: RXTX Developers and Users <rxtx at qbang.org>
> >To: rxtx at qbang.org
> >Subject: [Rxtx] error getting InputStream
> >Date: Fri, 04 Aug 2006 10:52:47 +0000
> >
> >Hi,
> >
> >I have written a program in Java for Windows xp using RXTX (which is why
>I
> >am using this mailing list :). However, I am getting a problem. I am
> >connecting to a serial port, like so:
> > private CommPortIdentifier portID;
> >
> > private boolean openPort(String selectedPort)
> > {
> > boolean portFound = false;
> > Enumeration portList;
> >
> > portList = CommPortIdentifier.getPortIdentifiers();
> >
> > while (portList.hasMoreElements())
> > {
> > portID = (CommPortIdentifier) portList.nextElement();
> > if (portID.getPortType() == CommPortIdentifier.PORT_SERIAL)
> > {
> > if (portID.getName().equals(selectedPort))
> > {
> > portFound = true;
> > break;
> > }
> > }
> > }
> >
> > return portFound;
> > }
> >
> >and then I try and get the serial port input stream (leaving out the try
> >and
> >catch for the sake of space):
> >
> >SerialPort serialPort = (SerialPort) portID.open("RFIDReaderComm", 2000);
> >InputStream inputStream = serialPort.getInputStream();
> >
> >but on the getInputStream() I get the following error message:
> >
> >Bad file descriptor in nativeavailable
> >
> >I cannot figure out where it is going wrong...anyone any ideas. A quick
> >answer would be wonderful, as I am kinda under the hammer to get this
>fixed
> >quickly
> >
> >Thanks in Advance
> >Keith
> >
> >
> >_______________________________________________
> >Rxtx mailing list
> >Rxtx at qbang.org
> >http://mailman.qbang.org/mailman/listinfo/rxtx
>
>
>_______________________________________________
>Rxtx mailing list
>Rxtx at qbang.org
>http://mailman.qbang.org/mailman/listinfo/rxtx
More information about the Rxtx
mailing list