tuwien.auto.calimero.cemi
Class CEMILData

java.lang.Object
  extended by tuwien.auto.calimero.cemi.CEMILData
All Implemented Interfaces:
CEMI
Direct Known Subclasses:
CEMILDataEx

public class CEMILData
extends java.lang.Object
implements CEMI

A cEMI link layer data message (L-Data).

Only standard frame formats are supported, with a transport layer protocol data unit of 16 bytes maximum. Additional information in the message structure is not supported.

Objects of this L-Data type are immutable.


Field Summary
protected  short ctrl1
          Control field 1, the lower 8 bits contain control information.
protected  short ctrl2
          Control field 2, the lower 8 bits contain control information.
protected  short mc
          Message code of this message.
static short MC_LDATA_CON
          Message code for L-Data confirmation, code = 46.
static short MC_LDATA_IND
          Message code for L-Data indication, code = 41.
static short MC_LDATA_REQ
          Message code for L-Data request, code = 17.
 
Constructor Summary
  CEMILData(byte[] data, int offset)
          Creates a new L-Data message from a byte stream.
  CEMILData(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p)
          Creates a L-Data message with most control information set to default values.
  CEMILData(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean confirm)
          Creates a L-Data message, mainly for confirmation.
protected CEMILData(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean repeat, boolean broadcast, boolean ack, int hopCount)
          Creates a L-Data message with full customization for control information.
  CEMILData(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean repeat, int hopCount)
          Creates a L-Data message, mainly for TP1 media.
 
Method Summary
 KNXAddress getDestination()
          Returns the KNX destination address.
 byte getHopCount()
          Returns the hop count set in the control information.
 short getMessageCode()
          Returns the cEMI message code.
 byte[] getPayload()
          Returns the L-Data TPDU.
 Priority getPriority()
          Returns the message priority.
 IndividualAddress getSource()
          Returns the KNX individual source address.
 short getStructLength()
          Returns the length of this cEMI message frame.
 boolean isAckRequested()
          Returns whether L2 acknowledge was requested.
 boolean isPositiveConfirmation()
          Returns if confirmation indicates success or error in a confirmation message.
 boolean isRepetition()
          Returns whether frame repetition is requested, or this is a repeated frame.
 byte[] toByteArray()
          Returns the byte representation of the whole cEMI message structure.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ctrl1

protected short ctrl1
Control field 1, the lower 8 bits contain control information.


ctrl2

protected short ctrl2
Control field 2, the lower 8 bits contain control information.


mc

protected short mc
Message code of this message.


MC_LDATA_CON

public static final short MC_LDATA_CON
Message code for L-Data confirmation, code = 46.

See Also:
Constant Field Values

MC_LDATA_IND

public static final short MC_LDATA_IND
Message code for L-Data indication, code = 41.

See Also:
Constant Field Values

MC_LDATA_REQ

public static final short MC_LDATA_REQ
Message code for L-Data request, code = 17.

See Also:
Constant Field Values
Constructor Detail

CEMILData

public CEMILData(byte[] data,
                 int offset)
          throws KNXFormatException
Creates a new L-Data message from a byte stream.

Parameters:
data - byte stream containing a cEMI L-Data message
offset - start offset of cEMI frame in data
Throws:
KNXFormatException - if no (valid) frame was found or the provided frame is not a standard frame

CEMILData

public CEMILData(int msgCode,
                 IndividualAddress src,
                 KNXAddress dst,
                 byte[] tpdu,
                 Priority p)
Creates a L-Data message with most control information set to default values.

The initialized message has send repetitions according to default medium behavior (for indication message this equals "not repeated frame"), broadcast is "don't care", acknowledge request is default medium behavior, hop count is 6 and confirmation request is "don't care" in the control field.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 16
p - message priority, priority set in the control field

CEMILData

public CEMILData(int msgCode,
                 IndividualAddress src,
                 KNXAddress dst,
                 byte[] tpdu,
                 Priority p,
                 boolean confirm)
Creates a L-Data message, mainly for confirmation.

The message hop count is set to 6, send repetitions according to default medium behavior, broadcast and acknowledge request are set to "don't care" in the control field.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information); i.e. the NPDU without the length field, tpdu.length <= 16
p - message priority, priority set in the control field
confirm - confirm flag in the control field, true to set error, false for no error

CEMILData

protected CEMILData(int msgCode,
                    IndividualAddress src,
                    KNXAddress dst,
                    byte[] tpdu,
                    Priority p,
                    boolean repeat,
                    boolean broadcast,
                    boolean ack,
                    int hopCount)
Creates a L-Data message with full customization for control information.

The confirmation flag of the control field is left out, since it is mutual exclusive with the rest of the control information and set to "don't care" (refer to CEMILData(int, IndividualAddress, KNXAddress, byte[], Priority, boolean)).

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 16
p - message priority, priority set in the control field
repeat - for request messages, send repetitions on the medium - false for do not repeat if error, true for default repeat behavior;
meaning of default behavior on media:
  • TP0, PL132, RF: no repetitions
  • TP1, PL110: repetitions allowed
for indication message - true if is repeated frame, false otherwise
broadcast - system / domain broadcast behavior, applicable on open media only: false for system broadcast, true for broadcast; on closed media set true for "don't care"
ack - acknowledge request, true if acknowledge is requested, false for default behavior;
meaning of default behavior on media:
  • TP0, PL132: no acknowledge requested
  • TP1, PL110: acknowledge requested
hopCount - hop count starting value set in control field, in the range 0 <= value <= 7

CEMILData

public CEMILData(int msgCode,
                 IndividualAddress src,
                 KNXAddress dst,
                 byte[] tpdu,
                 Priority p,
                 boolean repeat,
                 int hopCount)
Creates a L-Data message, mainly for TP1 media.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 16
p - message priority, priority set in the control field
repeat - for request message, send repetitions on the medium - false for do not repeat if error, true for default repeat behavior;
meaning of default behavior on media:
  • TP0, PL132, RF: no repetitions
  • TP1, PL110: repetitions allowed
for indication message - true if is repeated frame, false otherwise
hopCount - hop count starting value set in control field, in the range 0 <= value <= 7
Method Detail

getDestination

public final KNXAddress getDestination()
Returns the KNX destination address.

Returns:
destination address as KNXAddress

getHopCount

public final byte getHopCount()
Returns the hop count set in the control information.

The hop count value is in the range 0 <= value <= 7.

Returns:
hop count as 3 bit value

getMessageCode

public final short getMessageCode()
Description copied from interface: CEMI
Returns the cEMI message code.

The codes of the different cEMI message types can be looked up in the according subtype implementations.

Specified by:
getMessageCode in interface CEMI
Returns:
the message code byte

getPayload

public final byte[] getPayload()
Returns the L-Data TPDU.

The returned array is the NPDU without the length field of the message structure, starting with the TPCI / APCI field.

Specified by:
getPayload in interface CEMI
Returns:
a copy of the TPDU as byte array

getPriority

public final Priority getPriority()
Returns the message priority.

Returns:
used Priority

getSource

public final IndividualAddress getSource()
Returns the KNX individual source address.

Returns:
address as IndividualAddress

getStructLength

public short getStructLength()
Description copied from interface: CEMI
Returns the length of this cEMI message frame.

Specified by:
getStructLength in interface CEMI
Returns:
the message length in bytes

isAckRequested

public final boolean isAckRequested()
Returns whether L2 acknowledge was requested.

This information is valid in L-Data requests and partially in L-Data indications; for L-Data confirmations the value behavior is undefined (it might have the same value like the corresponding request).

For requests the following returns apply:
If true, acknowledge was requested explicitly, false for "don't care" (default medium behavior).
Default behavior on media for L2 ack:

For indication messages following media behavior applies:

Returns:
acknowledge request as boolean

isPositiveConfirmation

public final boolean isPositiveConfirmation()
Returns if confirmation indicates success or error in a confirmation message.

If return is true (confirmation bit in control field is 0 for no error), the associated request message to this confirmation was transmitted successfully, false otherwise (confirmation bit in control field is 1 for error).
On messages types other than confirmation, this information is "don't care" and always returns true.

Returns:
the confirmation state as boolean

isRepetition

public final boolean isRepetition()
Returns whether frame repetition is requested, or this is a repeated frame.

For request messages, returns false for do not repeat if error, true for default repeat behavior.
Meaning of default behavior on media:

For indication messages, returns false if this is not a repeated frame, true if repeated frame.

For L-Data confirmations the value behavior is undefined (it might have the same value like the corresponding request).

Returns:
repeat state as boolean

toByteArray

public byte[] toByteArray()
Description copied from interface: CEMI
Returns the byte representation of the whole cEMI message structure.

Specified by:
toByteArray in interface CEMI
Returns:
frame as byte array

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object