com.thingmagic
Class SerialTransportTCP

java.lang.Object
  extended by com.thingmagic.SerialTransportTCP
All Implemented Interfaces:
SerialTransport

public class SerialTransportTCP
extends java.lang.Object
implements SerialTransport


Nested Class Summary
static class SerialTransportTCP.Factory
           
 
Constructor Summary
SerialTransportTCP()
           
 
Method Summary
 void flush()
          Take any actions necessary (possibly none) to remove unsent data from the output path.
 int getBaudRate()
          Get the current baud rate of the communication channel.
 void open()
          Causes the communication interface to be opened but does not transmit any serial-layer data.
 byte[] receiveBytes(int length, byte[] messageSpace, int offset, int timeoutMillis)
          Receive a number of bytes on the serial transport.
 void sendBytes(int length, byte[] message, int offset, int timeoutMs)
          Send bytes down the serial transport layer.
 void setBaudRate(int rate)
          Set the current baud rate of the communication channel.
 void shutdown()
          Close the communication channel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialTransportTCP

public SerialTransportTCP()
Method Detail

open

public void open()
          throws ReaderException
Description copied from interface: SerialTransport
Causes the communication interface to be opened but does not transmit any serial-layer data. This should perform actions such as opening a serial port device or establishing a network connection within a wrapper protocol.

Specified by:
open in interface SerialTransport
Throws:
ReaderException

sendBytes

public void sendBytes(int length,
                      byte[] message,
                      int offset,
                      int timeoutMs)
               throws ReaderException
Description copied from interface: SerialTransport
Send bytes down the serial transport layer. No interpretation or modification occurs.

Specified by:
sendBytes in interface SerialTransport
Parameters:
length - number of bytes to send
message - array containing the bytes to be sent
offset - position in array to send from
timeoutMs - The duration to wait for the operation to complete.
Throws:
ReaderException

receiveBytes

public byte[] receiveBytes(int length,
                           byte[] messageSpace,
                           int offset,
                           int timeoutMillis)
                    throws ReaderException
Description copied from interface: SerialTransport
Receive a number of bytes on the serial transport.

Specified by:
receiveBytes in interface SerialTransport
Parameters:
length - number of bytes to receive
messageSpace - byte array to store the message in, or null to have one allocated
offset - location in messageSpace to store bytes
timeoutMillis - maximum duration to wait for a message
Returns:
the byte array with the number of bytes added
Throws:
ReaderException

getBaudRate

public int getBaudRate()
                throws ReaderException
Description copied from interface: SerialTransport
Get the current baud rate of the communication channel.

Specified by:
getBaudRate in interface SerialTransport
Returns:
the baud rate
Throws:
ReaderException

setBaudRate

public void setBaudRate(int rate)
                 throws ReaderException
Description copied from interface: SerialTransport
Set the current baud rate of the communication channel.

Specified by:
setBaudRate in interface SerialTransport
Parameters:
rate - the baud rate to set
Throws:
ReaderException

flush

public void flush()
           throws ReaderException
Description copied from interface: SerialTransport
Take any actions necessary (possibly none) to remove unsent data from the output path.

Specified by:
flush in interface SerialTransport
Throws:
ReaderException

shutdown

public void shutdown()
              throws ReaderException
Description copied from interface: SerialTransport
Close the communication channel.

Specified by:
shutdown in interface SerialTransport
Throws:
ReaderException