BowlerKernel
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
com.neuronrobotics.sdk.serial.SerialConnection Class Reference
Inheritance diagram for com.neuronrobotics.sdk.serial.SerialConnection:
Inheritance graph
[legend]
Collaboration diagram for com.neuronrobotics.sdk.serial.SerialConnection:
Collaboration graph
[legend]

Public Member Functions

 SerialConnection ()
 
 SerialConnection (String port)
 
 SerialConnection (String port, int baud)
 
void setPort (String port)
 
String getPort ()
 
void setBaud (int baud)
 
boolean connect ()
 
void disconnect ()
 
String toString ()
 
boolean waitingForConnection ()
 
- Public Member Functions inherited from com.neuronrobotics.sdk.common.BowlerAbstractConnection
void setThreadedUpstreamPackets (boolean up)
 
BowlerDatagram sendSynchronusly (BowlerDatagram sendable)
 
synchronized BowlerDatagram sendSynchronusly (BowlerDatagram sendable, boolean switchParser)
 
void sendAsync (BowlerDatagram sendable) throws IOException
 
void setSynchronusPacketTimeoutTime (int sleepTime)
 
int getSleepTime ()
 
long msSinceLastSend ()
 
synchronized void setConnected (boolean c)
 
boolean isConnected ()
 
void clearLastSyncronousResponse ()
 
BowlerDatagram getLastSyncronousResponse ()
 
void onDataReceived (BowlerDatagram data)
 
void addDatagramListener (IBowlerDatagramListener listener)
 
void removeDatagramListener (IBowlerDatagramListener listener)
 
void setDataIns (DataInputStream dataIns)
 
DataInputStream getDataIns () throws NullPointerException
 
void setDataOuts (DataOutputStream dataOuts)
 
DataOutputStream getDataOuts () throws NullPointerException
 
void setChunkSize (int chunkSize)
 
int getChunkSize ()
 
void setAsyncQueue (QueueManager asyncQueue)
 
void setSyncQueue (QueueManager syncQueue)
 
QueueManager getAsyncQueue ()
 
QueueManager getSyncQueue ()
 
void addConnectionEventListener (IConnectionEventListener l)
 
void removeConnectionEventListener (IConnectionEventListener l)
 
void setSynchronousDatagramListener (ISynchronousDatagramListener l)
 
void removeSynchronousDatagramListener (ISynchronousDatagramListener l)
 
RpcEncapsulation locateRpc (String namespace, BowlerMethod method, String rpcString)
 
Object[] parseResponse (String namespace, BowlerMethod method, String rpcString, BowlerDatagram dg)
 
Object[] send (MACAddress addr, String namespace, BowlerMethod method, String rpcString, Object[] arguments, int retry) throws DeviceConnectionException
 
boolean isInitializedNamespaces ()
 
ArrayList< String > getNamespaces (MACAddress addr)
 
boolean hasNamespace (String string, MACAddress addr)
 
ArrayList< RpcEncapsulationgetRpcList (String namespace, MACAddress addr)
 
BowlerDatagram send (BowlerAbstractCommand command, MACAddress addr, int retry) throws NoConnectionAvailableException, InvalidResponseException
 
BowlerDatagram send (BowlerAbstractCommand command, MACAddress addr, int retry, boolean switchParser) throws NoConnectionAvailableException, InvalidResponseException
 
BowlerDatagram send (BowlerAbstractCommand command, MACAddress addr) throws NoConnectionAvailableException, InvalidResponseException
 
BowlerDatagram send (BowlerAbstractCommand command, MACAddress addr, boolean switchParser) throws NoConnectionAvailableException, InvalidResponseException
 
boolean ping (MACAddress mac)
 
boolean ping (MACAddress mac, boolean switchParser)
 
void startHeartBeat ()
 
void startHeartBeat (long msHeartBeatTime)
 
void stopHeartBeat ()
 
double getPercentagePrint ()
 
void setPercentagePrint (double percentagePrint)
 
long getLastWrite ()
 
void setLastWrite (long lastWrite)
 
boolean isUseThreadedStack ()
 
void setUseThreadedStack (boolean useThreadedStack)
 
boolean isBeater ()
 
void setBeater (boolean beater)
 
BowlerDatagram loadPacketFromPhy (ByteList bytesToPacketBuffer) throws NullPointerException, IOException
 
void write (byte[] data) throws IOException
 

Static Public Member Functions

static SerialConnection getConnectionByMacAddress (MACAddress mac)
 
static List< String > getAvailableSerialPorts ()
 
- Static Public Member Functions inherited from com.neuronrobotics.sdk.common.BowlerAbstractConnection
static BowlerAbstractCommand getCommand (String namespace, BowlerMethod method, String rpcString, Object[] arguments, RpcEncapsulation rpc)
 

Private Attributes

int sleepTime = 1000
 
int pollTimeoutTime = 5
 
String port =null
 
int baud = 115200
 
NRSerialPort serial
 

Additional Inherited Members

- Protected Member Functions inherited from com.neuronrobotics.sdk.common.BowlerAbstractConnection
BowlerDatagram fireSyncOnReceive (BowlerDatagram datagram)
 
void fireAsyncOnResponse (BowlerDatagram datagram)
 
void waitForConnectioToBeReady ()
 

Detailed Description

SerialConnection manages a connection to a serial port on the host system. This class is responsible for abstracting all of the aspects of a serial connection including:

SerialConnection extends SerialPortEventListener to use the RXTX framework for receiving serial communications efficiently. Remember to disconnect whenever reading and writing to the connection is not necessary as a this class will continue to run a thread to wait for incoming data.

Definition at line 47 of file SerialConnection.java.

Constructor & Destructor Documentation

◆ SerialConnection() [1/3]

com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection ( )

Default Constructor.

Using this constructor will require that at least the port be set later on.

The baudrate will default to 115200bps.

Definition at line 72 of file SerialConnection.java.

References com.neuronrobotics.sdk.common.BowlerAbstractConnection.setSynchronusPacketTimeoutTime(), and com.neuronrobotics.sdk.serial.SerialConnection.sleepTime.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.getConnectionByMacAddress().

Here is the call graph for this function:

◆ SerialConnection() [2/3]

com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection ( String  port)

Class Constructor for a SerialConnection with a given port.

The baudrate will default to 115200bps.

Parameters
portthe port to connect to (i.e. COM6 or /dev/ttyUSB0)

Definition at line 83 of file SerialConnection.java.

References com.neuronrobotics.sdk.serial.SerialConnection.port, com.neuronrobotics.sdk.serial.SerialConnection.setPort(), com.neuronrobotics.sdk.common.BowlerAbstractConnection.setSynchronusPacketTimeoutTime(), and com.neuronrobotics.sdk.serial.SerialConnection.sleepTime.

Here is the call graph for this function:

◆ SerialConnection() [3/3]

com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection ( String  port,
int  baud 
)

Class Constructor for a SerialConnection with a given port and baudrate.

Parameters
portthe port to connect to (i.e. COM6 or /dev/ttyUSB0)
baudthe baudrate to use (i.e. 9600 or 115200)

Definition at line 94 of file SerialConnection.java.

References com.neuronrobotics.sdk.serial.SerialConnection.baud, com.neuronrobotics.sdk.serial.SerialConnection.port, com.neuronrobotics.sdk.serial.SerialConnection.setBaud(), com.neuronrobotics.sdk.serial.SerialConnection.setPort(), com.neuronrobotics.sdk.common.BowlerAbstractConnection.setSynchronusPacketTimeoutTime(), and com.neuronrobotics.sdk.serial.SerialConnection.sleepTime.

Here is the call graph for this function:

Member Function Documentation

◆ connect()

boolean com.neuronrobotics.sdk.serial.SerialConnection.connect ( )

◆ disconnect()

void com.neuronrobotics.sdk.serial.SerialConnection.disconnect ( )

◆ getAvailableSerialPorts()

static List<String> com.neuronrobotics.sdk.serial.SerialConnection.getAvailableSerialPorts ( )
static

Gets the available serial ports.

Returns
the available serial ports

Definition at line 255 of file SerialConnection.java.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.getConnectionByMacAddress(), and com.neuronrobotics.sdk.ui.SerialConnectionPanel.refresh().

◆ getConnectionByMacAddress()

static SerialConnection com.neuronrobotics.sdk.serial.SerialConnection.getConnectionByMacAddress ( MACAddress  mac)
static

◆ getPort()

String com.neuronrobotics.sdk.serial.SerialConnection.getPort ( )

Get the port to use (i.e. COM6 or /dev/ttyUSB0)

Returns
the port

Definition at line 114 of file SerialConnection.java.

References com.neuronrobotics.sdk.serial.SerialConnection.port.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.connect().

◆ setBaud()

void com.neuronrobotics.sdk.serial.SerialConnection.setBaud ( int  baud)

Set the baudrate for communications with the serial port. Standard baudrates should be used typically unless otherwise specififed by the device. The default system baudrate is 115200

Typical baudrates

  • 110
  • 300
  • 600
  • 1200
  • 2400
  • 4800
  • 9600
  • 14400
  • 19200
  • 28800
  • 38400
  • 56000
  • 57600
  • 115200
Parameters
baudthe new baud

Definition at line 142 of file SerialConnection.java.

References com.neuronrobotics.sdk.serial.SerialConnection.baud.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection().

◆ setPort()

void com.neuronrobotics.sdk.serial.SerialConnection.setPort ( String  port)

Set the port to use (i.e. COM6 or /dev/ttyUSB0)

Parameters
portthe serial port to use

Definition at line 105 of file SerialConnection.java.

References com.neuronrobotics.sdk.serial.SerialConnection.port.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection().

◆ toString()

String com.neuronrobotics.sdk.serial.SerialConnection.toString ( )

◆ waitingForConnection()

boolean com.neuronrobotics.sdk.serial.SerialConnection.waitingForConnection ( )

Attempt to re-establish a connection. Return if the attempt was successful.

Returns
true, if successful Attempt to re-establish a connection. Return if the attempt was successful.
true, if successful

Reimplemented from com.neuronrobotics.sdk.common.BowlerAbstractConnection.

Definition at line 278 of file SerialConnection.java.

Member Data Documentation

◆ baud

int com.neuronrobotics.sdk.serial.SerialConnection.baud = 115200
private

◆ pollTimeoutTime

int com.neuronrobotics.sdk.serial.SerialConnection.pollTimeoutTime = 5
private

The poll timeout time.

Definition at line 53 of file SerialConnection.java.

◆ port

String com.neuronrobotics.sdk.serial.SerialConnection.port =null
private

◆ serial

NRSerialPort com.neuronrobotics.sdk.serial.SerialConnection.serial
private

◆ sleepTime

int com.neuronrobotics.sdk.serial.SerialConnection.sleepTime = 1000
private

The sleep time.

Definition at line 50 of file SerialConnection.java.

Referenced by com.neuronrobotics.sdk.serial.SerialConnection.SerialConnection().


The documentation for this class was generated from the following file: