|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttuwien.auto.calimero.serial.FT12Connection
public class FT12Connection
Connection based on the FT1.2 protocol for communication with a BCU2 device.
Currently, one log service is provided for all connection instances, with the log service named "FT1.2".
Field Summary | |
---|---|
static int |
ACK_PENDING
Status code of communication: waiting for acknowledge after send, no error, not ready to send. |
static int |
CLOSED
State of communication: in closed state, no send possible. |
static int |
OK
State of communication: in idle state, no error, ready to send. |
Constructor Summary | |
---|---|
FT12Connection(int portNumber)
Creates a new connection to a BCU2 using the FT1.2 protocol. |
|
FT12Connection(java.lang.String portID)
Creates a new connection to a BCU2 using the FT1.2 protocol. |
|
FT12Connection(java.lang.String portID,
int baudrate)
Creates a new connection to a BCU2 using the FT1.2 protocol, and set the baud rate for communication. |
Method Summary | |
---|---|
void |
addConnectionListener(KNXListener l)
Adds the specified event listener l to receive events from this
connection. |
void |
close()
Ends communication with the BCU2 as specified by the FT1.2 protocol. |
int |
getBaudRate()
Returns the currently used baud rate. |
java.lang.String |
getPortID()
Returns the port identifier used in this connection. |
static java.lang.String[] |
getPortIdentifiers()
Attempts to gets the available serial communication ports on the host. |
int |
getState()
Returns information about the current FT1.2 communication state. |
void |
removeConnectionListener(KNXListener l)
Removes the specified event listener l , so it does no longer
receive events from this connection. |
void |
send(byte[] frame,
boolean blocking)
Sends an EMI frame to the BCU2 connected with this endpoint. |
void |
setBaudrate(int baud)
Sets a new baud rate for this connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ACK_PENDING
public static final int CLOSED
public static final int OK
Constructor Detail |
---|
public FT12Connection(int portNumber) throws KNXException
If the port to use can not be told just by the number, use
FT12Connection(String)
.
The baud rate is set to 19200.
portNumber
- port number of the serial communication port to use; mapped to
the default port identifier using this number (device and platform specific)
KNXException
- on port not found or access error, initializing port settings
failed, if reset of BCU2 failedpublic FT12Connection(java.lang.String portID) throws KNXException
The baud rate is set to 19200.
portID
- port identifier of the serial communication port to use
KNXException
- on port not found or access error, initializing port settings
failed, if reset of BCU2 failedpublic FT12Connection(java.lang.String portID, int baudrate) throws KNXException
If the requested baud rate is not supported, it may get substituted with a valid baud rate by default.
portID
- port identifier of the serial communication port to usebaudrate
- baud rate to use for communication, 0 < baud rate
KNXException
- on port not found or access error, initializing port settings
failed, if reset of BCU2 failedMethod Detail |
---|
public void addConnectionListener(KNXListener l)
l
to receive events from this
connection.
If l
was already added as listener, no action is performed.
l
- the listener to addpublic void close()
The BCU is always switched back into normal mode.
All registered event listeners get notified. The close event is the last event the
listeners receive.
If this connection endpoint is already closed, no action is performed.
public final int getBaudRate()
After closing the connection, the returned baud rate is 0 by default.
public final java.lang.String getPortID()
After the connection is closed, the returned ID will always be the empty string.
public static java.lang.String[] getPortIdentifiers()
At first, the Java system property "microedition.commports" is queried. If there is
no property with that key, and Calimero itself has access to serial ports,
the lowest 10 ports numbers are enumerated and checked if present.
The empty array is returned if no ports are discovered.
public final int getState()
public void removeConnectionListener(KNXListener l)
l
, so it does no longer
receive events from this connection.
If l
was not added in the first place, no action is performed.
l
- the listener to removepublic void send(byte[] frame, boolean blocking) throws KNXAckTimeoutException, KNXPortClosedException
In blocking mode, all necessary retransmissions of the sent frame will be done
automatically according to the protocol specification (i.e. in case of timeout).
If a communication failure occurs on the port, close()
is called. A send
timeout does not lead to closing of this connection.
In blocking send mode, on successfully receiving a confirmation, all listeners are
guaranteed to get notified before this method returns. The communication state (see
getState()
) is reset to OK
when the notification completed, so
to prevent another send call from a listener.
frame
- EMI message to send, length of frame < 256 bytesblocking
- true
to block for confirmation (ACK),
false
to immediately return after send
KNXAckTimeoutException
- in blocking
mode, if a timeout
regarding the acknowledge message was encountered
KNXPortClosedException
- if no communication was established in the
first place or communication was closedpublic void setBaudrate(int baud)
baud
- requested baud rate [Bit/s], 0 < baud rate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |