[Rxtx] error getting InputStream
Keith Thorne
hambyiii at hotmail.com
Fri Aug 4 07:52:11 MDT 2006
The physical serial port is actually a USB connection that is then changed
to a "virtual serial port", so I can use the serial port protocols to
connect to it. The other end of the connection is a hardware device that is
constantly turned on. I am not sure about the port 'vanishing'...we have
another piece of software that came with the hardware device, which we can
test the device (and with it the virtual serial port) with. This has no
problem connecting to the serial port or writing to/reading from the device.
It is only when my software is run, that the error occurs. Like I have said,
my software (using rxtx) is connecting to the serial port successfully, but
it is when I try and write to the serial port that I get the error.
Although to be truthful, I am not absolutely certain if the error is
happening on the oStream.write() or the oStream.flush(). I only think it is
the write(), because that is where the writeArray() function is called.
thanks
Keith
>From: Trent Jarvi <tjarvi at qbang.org>
>Reply-To: RXTX Developers and Users <rxtx at qbang.org>
>To: RXTX Developers and Users <rxtx at qbang.org>
>Subject: Re: [Rxtx] error getting InputStream
>Date: Fri, 4 Aug 2006 07:26:10 -0600 (MDT)
>
>
>Hi Keith
>
>Can you tell us more about the physical serial port? Might it be
>'vanishing?'
>
>On Fri, 4 Aug 2006, Keith Thorne wrote:
>
> > 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
> >
> >
> > _______________________________________________
> > 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