jcontrol.comm
Class FT1_2

java.lang.Object
  extended byjcontrol.comm.RS232
      extended byjcontrol.comm.FT1_2
All Implemented Interfaces:
jcontrol.io.BasicInputStream, jcontrol.io.BasicOutputStream, jcontrol.io.ComplexInputStream, jcontrol.io.ComplexOutputStream, jcontrol.comm.ConsoleInputStream, jcontrol.comm.ConsoleOutputStream, java.lang.Runnable

public class FT1_2
extends jcontrol.comm.RS232
implements java.lang.Runnable

Partial implementation of the FT1.2 protocol. E.g. for use with EIB BCUs.

For detailed information of the FT1.2 protocol refer to IEC 870-5-1 and IEC 870-5-2 (DIN 19244).

How to use:

Version:
1.0
Author:
boehme
Available on JControl Devices:
lib

Field Summary
static int BAUDRATE
          Default baudrate for communication
static int CF_PRM_REQ_CLASS1
          for use in the FT1_2 event loop
static int CF_PRM_REQ_STATUS
          for use in the FT1_2 event loop
static int CF_PRM_SEND_UDAT
          for use in the FT1_2 event loop
static int EXCHANGE_TIMEOUT
          Time-out for end of exchange in case of SEND/CONFIRM or REQUEST/RESPOND (510 bits at 19200 converted to 27 milliseconds)
static int LINE_IDLE_TIMEOUT
          Maximum time between two characters, minimum idle time berore error is detected (33 bits at 19200 converted to 2 milliseconds)
static int REPEAT_LIMIT
          Repeat limit the retransmissions due to transmission errors
 
Fields inherited from class jcontrol.comm.RS232
ECHO, FLOWCONTROL_RTSCTS, FLOWCONTROL_XONXOFF, PARITY_EVEN, PARITY_ODD
 
Fields inherited from interface jcontrol.comm.ConsoleOutputStream
STD_LF
 
Fields inherited from interface jcontrol.comm.ConsoleInputStream
LF_CHARS
 
Constructor Summary
FT1_2()
          Constructs a new FT1_2 instance using the serial line.
 
Method Summary
 void close()
          Closes the FT1_2 and the underlying RS232 connections.
 byte[] reqCLASS1()
          Requests CLASS1 from the BCU and waits for RESPOND (with UDAT).
 boolean reqSTATUS()
          Requests STATUS from the BCU and waits for RESPOND (just ACK).
 void run()
          Used internally for the FT1_2 event loop.
 void sendACK(byte[] udat)
          sends a ACK message (single byte) from within a FT1_2EventListener to generate confirm event
 boolean sendRESET()
          Sends RESET to the BCU and waits for CONFIRM.
 void sendResponse(byte[] udat)
          sends a respond message from within a FT1_2EventListener.
 boolean sendUDAT(byte[] udata)
          Sends UDAT to the BCU and waits for CONFIRM.
 void setListener(FT1_2EventListener el)
          sets a FT1_2EventListener
 
Methods inherited from class jcontrol.comm.RS232
available, errorCode, print, println, println, read, read, readLine, readUTF8, setBaudrate, setParams, write, write, writeUTF8
 
Methods inherited from class java.lang.Object
clone, equals, notifyAll, wait
 

Field Detail

BAUDRATE

public static final int BAUDRATE
Default baudrate for communication

See Also:
Constant Field Values

CF_PRM_REQ_CLASS1

public static final int CF_PRM_REQ_CLASS1
for use in the FT1_2 event loop

See Also:
FT1_2EventListener.onIndication(byte[], int), Constant Field Values

CF_PRM_REQ_STATUS

public static final int CF_PRM_REQ_STATUS
for use in the FT1_2 event loop

See Also:
FT1_2EventListener.onIndication(byte[], int), Constant Field Values

CF_PRM_SEND_UDAT

public static final int CF_PRM_SEND_UDAT
for use in the FT1_2 event loop

See Also:
FT1_2EventListener.onIndication(byte[], int), Constant Field Values

EXCHANGE_TIMEOUT

public static final int EXCHANGE_TIMEOUT
Time-out for end of exchange in case of SEND/CONFIRM or REQUEST/RESPOND (510 bits at 19200 converted to 27 milliseconds)

See Also:
Constant Field Values

LINE_IDLE_TIMEOUT

public static final int LINE_IDLE_TIMEOUT
Maximum time between two characters, minimum idle time berore error is detected (33 bits at 19200 converted to 2 milliseconds)

See Also:
Constant Field Values

REPEAT_LIMIT

public static final int REPEAT_LIMIT
Repeat limit the retransmissions due to transmission errors

See Also:
Constant Field Values
Constructor Detail

FT1_2

public FT1_2()
      throws java.io.IOException
Constructs a new FT1_2 instance using the serial line. Always uses default baudrate 19200 and default timeouts.

Method Detail

close

public void close()
Closes the FT1_2 and the underlying RS232 connections.

Specified by:
close in interface jcontrol.io.BasicInputStream
See Also:
RS232.close()

reqCLASS1

public byte[] reqCLASS1()
Requests CLASS1 from the BCU and waits for RESPOND (with UDAT).

Returns:
UDAT (null on error)

reqSTATUS

public boolean reqSTATUS()
Requests STATUS from the BCU and waits for RESPOND (just ACK).

Returns:
success

run

public void run()
Used internally for the FT1_2 event loop. All FT1_2 reception is performed here.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

sendACK

public void sendACK(byte[] udat)
sends a ACK message (single byte) from within a FT1_2EventListener to generate confirm event

Parameters:
udat - buffer to confirm (use null to send a NACK)

sendRESET

public boolean sendRESET()
Sends RESET to the BCU and waits for CONFIRM.

Returns:
success

sendResponse

public void sendResponse(byte[] udat)
                  throws java.io.IOException
sends a respond message from within a FT1_2EventListener. The Message will be stored and repeated automatically on request. (We don't need this for BCU communication.)

Parameters:
udat - data to send with response, use null for STATUS responses
Throws:
java.io.IOException

sendUDAT

public boolean sendUDAT(byte[] udata)
Sends UDAT to the BCU and waits for CONFIRM.

Parameters:
udata - user data to send (at least 1 byte)
Returns:
success

setListener

public void setListener(FT1_2EventListener el)
sets a FT1_2EventListener

Parameters:
el - eventlistener to use (null for remove)