lejos.pc.charting
Class LoggerComms

java.lang.Object
  extended by lejos.pc.charting.LoggerComms

public class LoggerComms
extends java.lang.Object

Provides a general connection manager on the PC that provides an InputStream and OutputStream from/to the NXTDataLogger running on the NXT.

The InputStream flavor used is a CachingInputStream which buffers the byte stream from the NXT to minimize blocking on the NXT writes. The OutputStream is standard.

The connect() method will attempt to connect via USB first, then Bluetooth via the NXTConnector class.

Author:
Kirk P. Thompson
See Also:
DataLogger, lejos.util.NXTDataLogger, NXTConnector, CachingInputStream

Constructor Summary
LoggerComms()
          Create a LoggerComms instance
 
Method Summary
 void closeConnection()
          Flush the streams, close the connection and clean up.
 boolean connect(java.lang.String NXT)
          Connect to a listening NXT.
 java.lang.String getConnectedNXTName()
          Return the name of the NXT last successfully connected to.
 java.io.InputStream getInputStream()
          Return the InputStream from the NXT.
 java.io.OutputStream getOutputStream()
          Return the OutputStream to the NXT.
 boolean isConnected()
          Is there a current valid connection?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerComms

public LoggerComms()
Create a LoggerComms instance

Method Detail

connect

public boolean connect(java.lang.String NXT)
Connect to a listening NXT. The NXT must be running NXTDataLogger with the waitForConnection() method called.

Parameters:
NXT - The name or address of the NXT to connect to. Be aware that NXT names are case-sensitive.
Returns:
true if successful connection with Data input/output streams established. false if the connection failed.
See Also:
lejos.util.NXTDataLogger

isConnected

public boolean isConnected()
Is there a current valid connection?

Returns:
true if so

getConnectedNXTName

public java.lang.String getConnectedNXTName()
Return the name of the NXT last successfully connected to.

Returns:
name of the NXT

getInputStream

public java.io.InputStream getInputStream()
Return the InputStream from the NXT.

Returns:
the InputStream

getOutputStream

public java.io.OutputStream getOutputStream()
Return the OutputStream to the NXT.

Returns:
the OutputStream

closeConnection

public void closeConnection()
Flush the streams, close the connection and clean up.

See Also:
connect(java.lang.String)