[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rxtx
Subject:    Re: [Rxtx] One serial port object for both sending and receiving ?
From:       Trent Jarvi <tjarvi () qbang ! org>
Date:       2006-02-13 4:03:30
Message-ID: Pine.LNX.4.61.0602122102130.5193 () www
[Download RAW message or body]

On Fri, 10 Feb 2006, Kim Lux wrote:

>
> Is it OK to use one SerialPort ojbect (ex Serial Port serialPort;) and
> use it for both sending and receiving ?
>
> For example:
>
> ========================================================================
> static SerialPort serialPort = null;
> static OutputStream serialOut = null;
> static InputStream serialIn = null;
>
> <find the port desired and set up serialPort here>
>
>
> 	// assign it to an outputStream for use
> 	try{
> 		serialOut = serialPort.getOutputStream();
> 		System.out.println("Serial output stream has been assigned.");
> 		}//try
> 	catch(IOException e)
> 		{
> 		System.out.println("Error: Couldn't assign output stream to serial
> port.");
> 		}//catch
>
>
> 	//assign it to an inputStream for use
> 	try{
> 		serialIn = serialPort.getInputStream();
> 		System.out.println("Serial input stream has been assigned.");
> 		}//try
> 	catch(IOException e)
> 		{
> 		System.out.println("Error: Couldn't assign input stream to serial
> port.");
> 		}//catch

This should be fine.  In fact trying to do it another way will probably 
not work as you will run into lockfile issues.

--
Trent Jarvi
tjarvi@qbang.org
_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic