de.cau.cs.kieler.krep.evalbench.comm
Class JNIConnection

java.lang.Object
  extended by de.cau.cs.kieler.krep.evalbench.comm.JNIConnection
All Implemented Interfaces:
IConnection

public class JNIConnection
extends Object
implements IConnection

Connection to software emulation of the processor via java native interfaces.

Rating yellow
(2010-02-05) review by cmot, msp

Constructor Summary
JNIConnection(String protocol, String logFile)
          Connect to software emulation.
 
Method Summary
 void dispose()
          Closes connection and removes locks on the involved device.
 String hark(int n)
          Harks to incoming data.
 String receive(char exit)
          Tries to receive a sequence of characters until an exit character is read.
 String receive(int n)
          Tries to receive a fixed number of characters.
 LinkedList<Integer> receiveByte(int n)
          Tries to receive a fixed number of characters.
 void send(byte data)
          Sends data to the target.
 void send(byte[] data)
          Sends data to the target.
 void send(String data)
          Sends data to the target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNIConnection

public JNIConnection(String protocol,
                     String logFile)
              throws CommunicationException
Connect to software emulation.

Parameters:
protocol - use KEP or KReP protocol
logFile - Name of the esi file to which the communication is logged or null to disabled logging.
Throws:
CommunicationException - thrown for any connection errors, e.g., if the software simulation is not found
Method Detail

dispose

public void dispose()
Closes connection and removes locks on the involved device.

Specified by:
dispose in interface IConnection

hark

public String hark(int n)
            throws CommunicationException
Harks to incoming data.

Specified by:
hark in interface IConnection
Parameters:
n - maximal number of characters to receive
Returns:
characters received in a specific time range
Throws:
CommunicationException - when an exception occurs while receiving data

receive

public String receive(char exit)
               throws CommunicationException
Tries to receive a sequence of characters until an exit character is read. The exit character is included in the returned string.

Specified by:
receive in interface IConnection
Parameters:
exit - the exit character
Returns:
received data
Throws:
CommunicationException - when a timeout is reached before the exit character is read

receive

public String receive(int n)
               throws CommunicationException
Tries to receive a fixed number of characters.

Specified by:
receive in interface IConnection
Parameters:
n - the number of characters to be fetched
Returns:
received data
Throws:
CommunicationException - when a timeout is reached before the exit character is read

send

public void send(String data)
          throws CommunicationException
Sends data to the target.

Specified by:
send in interface IConnection
Parameters:
data - data to be sent
Throws:
CommunicationException - when an exception occurs while sending data

send

public void send(byte data)
          throws CommunicationException
Sends data to the target.

Specified by:
send in interface IConnection
Parameters:
data - data to be sent
Throws:
CommunicationException - when an exception occurs while sending data

receiveByte

public LinkedList<Integer> receiveByte(int n)
                                throws CommunicationException
Tries to receive a fixed number of characters.

Specified by:
receiveByte in interface IConnection
Parameters:
n - the number of characters to be fetched
Returns:
received data
Throws:
CommunicationException - when a timeout is reached before the exit character is read

send

public void send(byte[] data)
          throws CommunicationException
Sends data to the target.

Specified by:
send in interface IConnection
Parameters:
data - data to be sent
Throws:
CommunicationException - when an exception occurs while sending data