diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index fe227af..9b26686 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -16,6 +16,24 @@ https://github.com/doip/doip-library.git A documentation of the whole project is available at http://automotive-doip.com/downloads/DoIP-Software-Documentation.pdf +============================================================================== + + Release Notes for Version: 1.3.0 + +CHANGES +======= + +- Issue #24: Changed DoIP version to 0x03 + +============================================================================== + + Release Notes for Version: 1.2.2 + +CHANGES +======= + +- Issue #22: Updated README + ============================================================================== Release Notes for Version: 1.2.1 diff --git a/build.gradle b/build.gradle index 0a5ade1..a6ffcf6 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { group = "com.github.doip" -version = '1.2.2' +version = '1.3.0' repositories { mavenCentral() diff --git a/src/main/java/doip/library/comm/DoipTcpConnectionListener.java b/src/main/java/doip/library/comm/DoipTcpConnectionListener.java index 04de0e0..2ff872e 100644 --- a/src/main/java/doip/library/comm/DoipTcpConnectionListener.java +++ b/src/main/java/doip/library/comm/DoipTcpConnectionListener.java @@ -17,7 +17,7 @@ public interface DoipTcpConnectionListener { public void onDoipTcpDiagnosticMessagePosAck(DoipTcpConnection doipTcpConnection, DoipTcpDiagnosticMessagePosAck doipMessage); - public void onDoipTcpDiagnosticMessageNegAck(DoipTcpConnection doipTcpConnection, DoipTcpDiagnosticMessageNegAck doipTcpDiagnosticMessageNegAck); + public void onDoipTcpDiagnosticMessageNegAck(DoipTcpConnection doipTcpConnection, DoipTcpDiagnosticMessageNegAck doipTcpDiagnosticMessageNegAck); public void onDoipTcpRoutingActivationRequest(DoipTcpConnection doipTcpConnection, DoipTcpRoutingActivationRequest doipMessage); diff --git a/src/main/java/doip/library/comm/DoipTcpStreamBuffer.java b/src/main/java/doip/library/comm/DoipTcpStreamBuffer.java index 7e92e20..b782f7d 100644 --- a/src/main/java/doip/library/comm/DoipTcpStreamBuffer.java +++ b/src/main/java/doip/library/comm/DoipTcpStreamBuffer.java @@ -5,6 +5,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import doip.library.message.DoipMessage; import doip.library.util.StreamBuffer; @@ -21,10 +23,10 @@ */ public class DoipTcpStreamBuffer extends StreamBuffer { - /** - * log4j2 logger - */ + /** Log4j2 logger */ private static Logger logger = LogManager.getLogger(DoipTcpStreamBuffer.class); + private static Marker enter = MarkerManager.getMarker("ENTER"); + private static Marker exit = MarkerManager.getMarker("EXIT"); public static final int STATE_HEADER_NOT_COMPLETED = 1; @@ -60,9 +62,9 @@ public class DoipTcpStreamBuffer extends StreamBuffer { private int state = STATE_HEADER_NOT_COMPLETED; public void addListener(DoipTcpStreamBufferListener listener) { - logger.trace(">>> public void addListener(DoipStreamBufferListener listener)"); + logger.trace(enter, ">>> public void addListener(DoipStreamBufferListener listener)"); this.listeners.add(listener); - logger.trace("<<< public void addListener(DoipStreamBufferListener listener)"); + logger.trace(exit, "<<< public void addListener(DoipStreamBufferListener listener)"); } /** @@ -70,7 +72,7 @@ public void addListener(DoipTcpStreamBufferListener listener) { * the buffer. */ public void append(byte[] newData) { - logger.trace(">>> void append(byte[] newData)"); + logger.trace(enter, ">>> void append(byte[] newData)"); logger.debug("Append " + newData.length + " bytes to the buffer"); super.append(newData); @@ -80,7 +82,7 @@ public void append(byte[] newData) { + " bytes in the buffer which needs to get processed. Calling processBuffer() again."); ret = this.processBuffer(); } - logger.trace("<<< void append(byte[] newData)"); + logger.trace(exit, "<<< void append(byte[] newData)"); } /** @@ -91,18 +93,21 @@ public void append(byte[] newData) { * payload types for UDP messages will also be declared as invalid * payload type. */ - public boolean checkPayloadType(int payloadType) { + public static boolean isValidTcpPayloadType(int payloadType) { + logger.trace(enter, ">>> public boolean checkPayloadType(int payloadType)"); + boolean ret = false; if (payloadType == 0x0000 || payloadType == 0x0005 || payloadType == 0x0006 || payloadType == 0x0007 || payloadType == 0x0008 || payloadType == 0x8001 || payloadType == 0x8002 || payloadType == 0x8003) { - return true; + ret = true; } - return false; + logger.trace(enter, ">>> public boolean checkPayloadType(int payloadType)"); + return ret; } /** * This function will check if the payload length is correct. * - * @return Returns true if the payload is correct for the specific payload type. + * @return Returns true if the payload length is correct for the specific payload type. */ public boolean checkPayloadTypeSpecificLength() { logger.trace(">>> boolean checkPayloadTypeSpecificLength()"); @@ -155,7 +160,7 @@ public boolean checkPayloadTypeSpecificLength() { * @param data The data which will be checked. * @return Returns true if the first two bytes contain a valid sync pattern */ - public boolean checkSyncPattern(byte[] data) { + public static boolean checkSyncPattern(byte[] data) { logger.trace(">>> boolean checkSyncPattern(byte[] data)"); int protocolVersion = data[0] & 0xFF; int inverseProtocolVersion = data[1] & 0xFF; @@ -223,7 +228,7 @@ public void handleTcpHeader() { this.payloadLength = (highhigh << 24) | (highlow << 16) | (lowhigh << 8) | lowlow; logger.debug("\tPayload Length in Header = " + payloadLength); - if (checkPayloadType(payloadType) == false) { + if (isValidTcpPayloadType(payloadType) == false) { logger.warn("Invalid payload type"); this.onHeaderUnknownPayloadType(); this.state = STATE_SHREDDER_NOT_COMPLETED; diff --git a/src/main/java/doip/library/comm/DoipUdpMessageHandler.java b/src/main/java/doip/library/comm/DoipUdpMessageHandler.java index 2a015db..fd72716 100644 --- a/src/main/java/doip/library/comm/DoipUdpMessageHandler.java +++ b/src/main/java/doip/library/comm/DoipUdpMessageHandler.java @@ -410,9 +410,11 @@ public void onDoipUdpEntityStatusRequest(DoipUdpEntityStatusRequest doipMessage, ">>> public void onDoipUdpEntityStatusRequest(DoipUdpEntityStatusRequest doipMessage, DatagramPacket packet)"); } + logger.debug("Number of listeners = " + this.listeners.size()); Iterator iter = this.listeners.iterator(); while (iter.hasNext()) { DoipUdpMessageHandlerListener listener = iter.next(); + logger.debug("Calling listener on address " + listener.toString()); listener.onDoipUdpEntityStatusRequest(doipMessage, packet); } @@ -496,7 +498,6 @@ public void onHeaderTooShort(DatagramPacket packet) { if (logger.isTraceEnabled()) { logger.trace("<<< public void onHdeaderTooShort(DatagramPacket packet)"); } - } public void onInvalidPayloadLength(DatagramPacket packet) { diff --git a/src/main/java/doip/library/message/DoipMessage.java b/src/main/java/doip/library/message/DoipMessage.java index e670bfc..c52610c 100644 --- a/src/main/java/doip/library/message/DoipMessage.java +++ b/src/main/java/doip/library/message/DoipMessage.java @@ -1,6 +1,8 @@ package doip.library.message; import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Base class for all DoIP Messages @@ -28,6 +30,8 @@ public abstract class DoipMessage { public final static int TYPE_TCP_DIAG_MESSAGE = 0x8001; public final static int TYPE_TCP_DIAG_MESSAGE_POS_ACK = 0x8002; public final static int TYPE_TCP_DIAG_MESSAGE_NEG_ACK = 0x8003; + + private static Logger logger = LogManager.getLogger(DoipMessage.class); protected DoipMessage() { } @@ -36,43 +40,44 @@ protected DoipMessage() { public abstract void log(Level level); - public static String getPayloadTypeAsString(int type) { + public abstract String getMessageName(); + + public static String getPayloadTypeAsString(int type) { switch (type) { case 0x0000: - return "Generic DoIP Header Negative Acknowledge"; + return "generic DoIP header negative acknowledge"; case 0x0001: - return "Vehicle Identification Request Message"; + return "vehicle identification request message"; case 0x0002: - return "Vehicle Identification Request Message with EID"; + return "vehicle identification request message with EID"; case 0x0003: - return "Vehicle Identification Request Message with VIN"; + return "vehicle identification request message with VIN"; case 0x0004: - return "Vehicle Announcement Message"; + return "vehicle announcement message"; case 0x0005: - return "Routing Activation Request"; + return "routing activation request"; case 0x0006: - return "Routing Activation Response"; + return "routing activation response"; case 0x0007: - return "Alive Check Request"; + return "alive check request"; case 0x0008: - return "Alive Check Response"; + return "alive check response"; case 0x4001: - return "DoIP Entity Status Request"; + return "DoIP entity status request"; case 0x4002: - return "DoIP Entity Status Response"; + return "DoIP entity status response"; case 0x4003: - return "Diagnostic Power Mode Information Request"; + return "diagnostic power mode information request"; case 0x4004: - return "Diagnostic Power Mode Information Response"; + return "diagnostic power mode information response"; case 0x8001: - return "Diagnostic Message"; + return "diagnostic message"; case 0x8002: - return "Diagnostic Message Positive Acknowledgement"; + return "diagnostic message positive acknowledgement"; case 0x8003: - return "Diagnostic Message Negative Acknowledgement"; + return "diagnostic message negative acknowledgement"; default: - break; + throw logger.throwing(Level.FATAL, new IllegalArgumentException("An invaid value has been passed to function DoipMessage.getPayoadTypeAsString(int type)")); } - return null; } } diff --git a/src/main/java/doip/library/message/DoipTcpAliveCheckRequest.java b/src/main/java/doip/library/message/DoipTcpAliveCheckRequest.java index 98a2e17..889f4bf 100644 --- a/src/main/java/doip/library/message/DoipTcpAliveCheckRequest.java +++ b/src/main/java/doip/library/message/DoipTcpAliveCheckRequest.java @@ -19,7 +19,15 @@ public void log(Level level) { logger.log(level, "DoIP alive check request"); logger.log(level, "----------------------------------------"); } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ALIVE_REQ); + } + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ALIVE_REQ); + } + @Override public void parsePayload(byte[] payload) { // Nothing to parse because there is no payload @@ -27,7 +35,7 @@ public void parsePayload(byte[] payload) { @Override public byte[] getMessage() { - byte[] message = new byte[] { 0x02, (byte) 0xFD, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00 }; + byte[] message = new byte[] { 0x03, (byte) 0xFC, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00 }; return message; } diff --git a/src/main/java/doip/library/message/DoipTcpAliveCheckResponse.java b/src/main/java/doip/library/message/DoipTcpAliveCheckResponse.java index b56a59a..3eb9d6f 100644 --- a/src/main/java/doip/library/message/DoipTcpAliveCheckResponse.java +++ b/src/main/java/doip/library/message/DoipTcpAliveCheckResponse.java @@ -19,6 +19,14 @@ public DoipTcpAliveCheckResponse(int sourceAddress) { log(Level.INFO); } } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ALIVE_RES); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ALIVE_RES); + } public void log(Level level) { logger.log(level, "----------------------------------------"); @@ -42,7 +50,7 @@ public void parsePayload(byte[] payload) { @Override public byte[] getMessage() { - byte[] message = new byte[] { 0x02, (byte) 0xFD, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00 }; + byte[] message = new byte[] { 0x03, (byte) 0xFC, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00 }; message[8] = (byte) (sourceAddress >> 8); message[9] = (byte) sourceAddress; return message; diff --git a/src/main/java/doip/library/message/DoipTcpDiagnosticMessage.java b/src/main/java/doip/library/message/DoipTcpDiagnosticMessage.java index 7fedc41..ef0ba0d 100644 --- a/src/main/java/doip/library/message/DoipTcpDiagnosticMessage.java +++ b/src/main/java/doip/library/message/DoipTcpDiagnosticMessage.java @@ -27,16 +27,23 @@ public DoipTcpDiagnosticMessage(int sourceAddress, int targetAddress, byte[] mes this.log(Level.INFO); } } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE); + } + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE); + } + public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP diagnostic message:"); - logger.log(level, " Source address = " + this.sourceAddress); - logger.log(level, " Target address = " + this.targetAddress); + logger.log(level, " Source address = " + String.format("0x%04X", this.sourceAddress)); + logger.log(level, " Target address = " + String.format("0x%04X", this.targetAddress)); logger.log(level, " Message = " + Conversion.byteArrayToHexStringShortDotted(this.diagnosticMessage, 64)); logger.log(level, "----------------------------------------"); - } @Override @@ -61,8 +68,8 @@ public static DoipTcpDiagnosticMessage createInstance(byte[] payload) { public byte[] getMessage() { byte[] data = new byte[8 + 4 + diagnosticMessage.length]; - data[0] = 0x02; - data[1] = (byte) 0xFD; + data[0] = 0x03; + data[1] = (byte) 0xFC; data[2] = (byte) 0x80; data[3] = 0x01; data[4] = (byte) ((diagnosticMessage.length + 4) >> 24); diff --git a/src/main/java/doip/library/message/DoipTcpDiagnosticMessageAck.java b/src/main/java/doip/library/message/DoipTcpDiagnosticMessageAck.java index 4e65e6a..b174e61 100644 --- a/src/main/java/doip/library/message/DoipTcpDiagnosticMessageAck.java +++ b/src/main/java/doip/library/message/DoipTcpDiagnosticMessageAck.java @@ -13,12 +13,12 @@ public abstract class DoipTcpDiagnosticMessageAck extends DoipTcpMessage { protected DoipTcpDiagnosticMessageAck() { } - public DoipTcpDiagnosticMessageAck(int sourceAddress, int targetAddress, int ackCode, byte[] message) { + public DoipTcpDiagnosticMessageAck(int sourceAddress, int targetAddress, int ackCode, byte[] diagnosticMessage) { this.sourceAddress = sourceAddress; this.targetAddress = targetAddress; this.ackCode = ackCode; - if (message != null) { - this.diagnosticMessage = message; + if (diagnosticMessage != null) { + this.diagnosticMessage = diagnosticMessage; } } @@ -32,7 +32,7 @@ public void parsePayload(byte[] payload) { this.targetAddress = (high << 8) | low; this.ackCode = payload[4] & 0xFF; if (payload.length > 5) { - this.diagnosticMessage = Arrays.copyOfRange(payload, 5, payload.length - 5); + this.diagnosticMessage = Arrays.copyOfRange(payload, 5, payload.length); } else { this.diagnosticMessage = new byte[] {}; } @@ -41,8 +41,8 @@ public void parsePayload(byte[] payload) { @Override public byte[] getMessage() { byte[] data = new byte[8 + 4 + 1 + diagnosticMessage.length]; - data[0] = 0x02; - data[1] = (byte) 0xFD; + data[0] = 0x03; + data[1] = (byte) 0xFC; data[2] = (byte) 0x80; if (this.ackCode == 0) { data[3] = 0x02; diff --git a/src/main/java/doip/library/message/DoipTcpDiagnosticMessageNegAck.java b/src/main/java/doip/library/message/DoipTcpDiagnosticMessageNegAck.java index 44d1982..347953f 100644 --- a/src/main/java/doip/library/message/DoipTcpDiagnosticMessageNegAck.java +++ b/src/main/java/doip/library/message/DoipTcpDiagnosticMessageNegAck.java @@ -25,6 +25,14 @@ public DoipTcpDiagnosticMessageNegAck(int sourceAddress, int targetAddress, int log(Level.INFO); } + public String getMessageName () { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE_NEG_ACK); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE_NEG_ACK); + } + public String getNackCodeAsString(int code) { switch (code) { case 0x02: diff --git a/src/main/java/doip/library/message/DoipTcpDiagnosticMessagePosAck.java b/src/main/java/doip/library/message/DoipTcpDiagnosticMessagePosAck.java index 6c1c014..544768e 100644 --- a/src/main/java/doip/library/message/DoipTcpDiagnosticMessagePosAck.java +++ b/src/main/java/doip/library/message/DoipTcpDiagnosticMessagePosAck.java @@ -17,6 +17,14 @@ public DoipTcpDiagnosticMessagePosAck(int sourceAddress, int targetAddress, int log(Level.INFO); } + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE_POS_ACK); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_DIAG_MESSAGE_POS_ACK); + } + public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP diagnostic message positive acknowledgement:"); diff --git a/src/main/java/doip/library/message/DoipTcpHeaderNegAck.java b/src/main/java/doip/library/message/DoipTcpHeaderNegAck.java index 1e875cf..9e8a36c 100644 --- a/src/main/java/doip/library/message/DoipTcpHeaderNegAck.java +++ b/src/main/java/doip/library/message/DoipTcpHeaderNegAck.java @@ -24,14 +24,38 @@ public static DoipTcpHeaderNegAck createInstance(byte[] payload) { doipHeaderNegAck.log(Level.INFO); return doipHeaderNegAck; } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_HEADER_NACK); + } + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_HEADER_NACK); + } + public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP header negative acknowledgement (TCP):"); - logger.log(level, " Code = " + this.code); - logger.log(level, ""); + logger.log(level, " Code = " + String.format("0x%02X (", code) + getCodeAsString() + ")"); logger.log(level, "----------------------------------------"); } + + public String getCodeAsString() { + switch (code) { + case 0x00: + return "incorrect pattern format"; + case 0x01: + return "unknown payload type"; + case 0x02: + return "message too large"; + case 0x03: + return "out of memory"; + case 0x04: + return "invalid payload length"; + default: + return "reserved by this document"; + } + } public int getCode() { return code; @@ -39,7 +63,7 @@ public int getCode() { @Override public byte[] getMessage() { - byte[] message = new byte[] { 0x02, (byte) 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; + byte[] message = new byte[] { 0x03, (byte) 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; message[8] = (byte) (code & 0xFF); return message; } diff --git a/src/main/java/doip/library/message/DoipTcpRoutingActivationRequest.java b/src/main/java/doip/library/message/DoipTcpRoutingActivationRequest.java index b5796f9..25a1017 100644 --- a/src/main/java/doip/library/message/DoipTcpRoutingActivationRequest.java +++ b/src/main/java/doip/library/message/DoipTcpRoutingActivationRequest.java @@ -21,6 +21,14 @@ public DoipTcpRoutingActivationRequest(int sourceAddress, int activationType, lo private DoipTcpRoutingActivationRequest() { } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ROUTING_REQ); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ROUTING_REQ); + } public void log(Level level) { logger.log(level, "----------------------------------------"); @@ -68,8 +76,8 @@ public byte[] getMessage() { message[18] = (byte) (this.oemData); } - message[0] = 0x02; - message[1] = (byte) 0xFD; + message[0] = 0x03; + message[1] = (byte) 0xFC; message[2] = 0x00; message[3] = 0x05; message[4] = 0x00; diff --git a/src/main/java/doip/library/message/DoipTcpRoutingActivationResponse.java b/src/main/java/doip/library/message/DoipTcpRoutingActivationResponse.java index a5768c1..1280eab 100644 --- a/src/main/java/doip/library/message/DoipTcpRoutingActivationResponse.java +++ b/src/main/java/doip/library/message/DoipTcpRoutingActivationResponse.java @@ -23,6 +23,14 @@ public DoipTcpRoutingActivationResponse(int testerAddress, int entityAddress, in this.log(Level.INFO); } + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ROUTING_RES); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_TCP_ROUTING_RES); + } + public String getResponseCodeAsString(int code) { switch (code) { case 0x00: @@ -98,8 +106,8 @@ public byte[] getMessage() { msg[19] = (byte) (this.oemData >> 8); msg[20] = (byte) (this.oemData); } - msg[0] = 0x02; - msg[1] = (byte) 0xFD; + msg[0] = 0x03; + msg[1] = (byte) 0xFC; msg[2] = 0x00; msg[3] = 0x06; msg[4] = 0x00; diff --git a/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeRequest.java b/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeRequest.java index 83bdab1..ec7ccd3 100644 --- a/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeRequest.java +++ b/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeRequest.java @@ -18,9 +18,17 @@ public void log(Level level) { logger.log(level, "----------------------------------------"); } + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_DIAG_POWER_MODE_REQ); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_DIAG_POWER_MODE_REQ); + } + @Override public byte[] getMessage() { - byte[] message = new byte[] {0x02, (byte)0xFD, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00}; + byte[] message = new byte[] {0x03, (byte)0xFC, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00}; return message; } } diff --git a/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeResponse.java b/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeResponse.java index 7bf1126..61f3f2e 100644 --- a/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeResponse.java +++ b/src/main/java/doip/library/message/DoipUdpDiagnosticPowerModeResponse.java @@ -13,6 +13,14 @@ public class DoipUdpDiagnosticPowerModeResponse extends DoipUdpMessage { public DoipUdpDiagnosticPowerModeResponse(int diagnosticPowerMode) { this.diagnsoticPowerMode = diagnosticPowerMode; } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_DIAG_POWER_MODE_RES); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_DIAG_POWER_MODE_RES); + } public void log(Level level) { logger.log(level, "----------------------------------------"); @@ -23,7 +31,7 @@ public void log(Level level) { @Override public byte[] getMessage() { - byte[] message = new byte[] { 0x02, (byte) 0xFD, 0x40, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00 }; + byte[] message = new byte[] { 0x03, (byte) 0xFC, 0x40, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00 }; message[8] = (byte) this.diagnsoticPowerMode; return message; } diff --git a/src/main/java/doip/library/message/DoipUdpEntityStatusRequest.java b/src/main/java/doip/library/message/DoipUdpEntityStatusRequest.java index 7d23c0b..39a0e53 100644 --- a/src/main/java/doip/library/message/DoipUdpEntityStatusRequest.java +++ b/src/main/java/doip/library/message/DoipUdpEntityStatusRequest.java @@ -17,10 +17,18 @@ public void log(Level level) { logger.log(level, "DoIP entity status request."); logger.log(level, "----------------------------------------"); } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_ENTITY_STATUS_REQ); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_ENTITY_STATUS_REQ); + } @Override public byte[] getMessage() { - byte[] msg = new byte[] {0x02, (byte) 0xFD, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00}; + byte[] msg = new byte[] {0x03, (byte) 0xFC, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00}; return msg; } diff --git a/src/main/java/doip/library/message/DoipUdpEntityStatusResponse.java b/src/main/java/doip/library/message/DoipUdpEntityStatusResponse.java index cb6de8a..678fe57 100644 --- a/src/main/java/doip/library/message/DoipUdpEntityStatusResponse.java +++ b/src/main/java/doip/library/message/DoipUdpEntityStatusResponse.java @@ -25,6 +25,14 @@ public DoipUdpEntityStatusResponse(int nodeType, int maxNumberOfSockets, int cur this.log(Level.INFO); } + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_ENTITY_STATUS_RES); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_ENTITY_STATUS_RES); + } + public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP entity status response:"); @@ -38,8 +46,8 @@ public void log(Level level) { @Override public byte[] getMessage() { byte[] msg = new byte[15]; - msg[0] = 0x02; - msg[1] = (byte) 0xFD; + msg[0] = 0x03; + msg[1] = (byte) 0xFC; msg[2] = 0x40; msg[3] = 0x02; msg[4] = 0x00; diff --git a/src/main/java/doip/library/message/DoipUdpHeaderNegAck.java b/src/main/java/doip/library/message/DoipUdpHeaderNegAck.java index b62199b..e744d0d 100644 --- a/src/main/java/doip/library/message/DoipUdpHeaderNegAck.java +++ b/src/main/java/doip/library/message/DoipUdpHeaderNegAck.java @@ -9,26 +9,54 @@ public class DoipUdpHeaderNegAck extends DoipUdpMessage implements DoipHeaderNeg private static Logger logger = LogManager.getLogger(DoipUdpHeaderNegAck.class); private int code = -1; - @SuppressWarnings("unused") - private DoipUdpHeaderNegAck() { - } - public DoipUdpHeaderNegAck(int code) { this.code = code; this.log(Level.INFO); } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_HEADER_NACK); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_HEADER_NACK); + } public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP header negative acknowledgement (UDP):"); - logger.log(level, " Code = " + this.code); - logger.log(level, ""); + logger.log(level, " Code = " + String.format("0x%02X (", code) + getCodeAsString() + ")"); logger.log(level, "----------------------------------------"); } + + public String getCodeAsString() { + switch (code) { + case 0x00: + return "incorrect pattern format"; + case 0x01: + return "unknown payload type"; + case 0x02: + return "message too large"; + case 0x03: + return "out of memory"; + case 0x04: + return "invalid payload length"; + default: + return "reserved by this document"; + } + } @Override public byte[] getMessage() { - byte[] message = new byte[] { 0x02, (byte) 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; + byte[] message = new byte[] { 0x03, (byte) 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; message[8] = (byte) (code & 0xFF); return message; } diff --git a/src/main/java/doip/library/message/DoipUdpMessage.java b/src/main/java/doip/library/message/DoipUdpMessage.java index 11f1420..10c6c24 100644 --- a/src/main/java/doip/library/message/DoipUdpMessage.java +++ b/src/main/java/doip/library/message/DoipUdpMessage.java @@ -95,7 +95,9 @@ public static DoipUdpMessage parseUDP(byte[] data) //--------------------------------------------------------- case 0x0004: // VAM; UDP //--------------------------------------------------------- - checkPayloadLength(33, payloadLength, data.length); + /* The last byte could be optional, therefore we + use specific method to check the payload length */ + checkPayloadLength_0x0004_VAM(payloadLength, data.length); // VIN vin = new byte[17]; @@ -118,7 +120,13 @@ public static DoipUdpMessage parseUDP(byte[] data) int furtherActionRequired = data[39] & 0xFF; // Sync Status - byte syncStatus = data[40]; + int syncStatus; + if (payloadLength == 33) { + syncStatus = (data[40] & 0xFF); + } else { + syncStatus = -1; + } + logger.trace("<<< DoipMessage parseUDP(byte[] data)"); return new DoipUdpVehicleAnnouncementMessage(vin, logicalAddress, eid, gid, furtherActionRequired, @@ -185,12 +193,45 @@ public static DoipUdpMessage parseUDP(byte[] data) */ private static void checkPayloadLength(long expectedLength, long payloadLength, long dataLength) throws InvalidPayloadLength { - logger.trace(">>> void checkPayloadLength(long expectedLength, long payloadLength, long dataLength)"); - logger.debug("\tExpected Payload Length = " + expectedLength); - if ((payloadLength != expectedLength) || (payloadLength != (dataLength - 8))) { - logger.warn("Invalid payload length."); - throw new InvalidPayloadLength(); + try { + logger.trace(">>> void checkPayloadLength(long expectedLength, long payloadLength, long dataLength)"); + + if (payloadLength != expectedLength) { + logger.warn("The payload length given in the DoIP header is invalid. " + + "It should be " + expectedLength + ", but it is " + payloadLength + "."); + throw new InvalidPayloadLength(); + } + logger.debug("\tExpected Payload Length = " + expectedLength); + if (payloadLength != (dataLength - 8)) { + logger.warn("The payload length given in the DoIP header does not match " + + "to the actual length of the payload. The payload given in the DoIP header is " + payloadLength + ", " + + "but the actual length of the payload is " + (dataLength - 8) + "."); + throw new InvalidPayloadLength(); + } + logger.debug("Payload length of DoIP message is correct."); + } finally { + logger.trace("<<< void checkPayloadLength(long expectedLength, long payloadLength, long dataLength)"); + } + } + + private static void checkPayloadLength_0x0004_VAM(long payloadLength, long dataLength) throws InvalidPayloadLength { + try { + logger.trace(">>> void checkPayloadLength_0x0004_VAM(long payloadLength, long dataLength)"); + if ((payloadLength != 32) && (payloadLength != 33)) { + logger.warn("The payload length given in the DoIP header of the vehicle announcement message (0x0004) is invalid. " + + "It should be 32 or 33, but it is " + payloadLength + "."); + throw new InvalidPayloadLength(); + } + + if (payloadLength != (dataLength - 8)) { + logger.warn("The payload length given in the DoIP header of the vehicle announcement message (0x0004) does not match " + + "to the actual length of the payload. The payload given in the DoIP header is " + payloadLength + ", " + + "but the actual length of the payload is " + (dataLength - 8) + "."); + throw new InvalidPayloadLength(); + } + logger.debug("Payload length of the vehicle announcement message (0x0004) is correct."); + } finally { + logger.trace("<<< void checkPayloadLength_0x0004_VAM(long payloadLength, long dataLength)"); } - logger.trace("<<< void checkPayloadLength(long expectedLength, long payloadLength, long dataLength)"); } } diff --git a/src/main/java/doip/library/message/DoipUdpVehicleAnnouncementMessage.java b/src/main/java/doip/library/message/DoipUdpVehicleAnnouncementMessage.java index 3d89b74..8a76692 100644 --- a/src/main/java/doip/library/message/DoipUdpVehicleAnnouncementMessage.java +++ b/src/main/java/doip/library/message/DoipUdpVehicleAnnouncementMessage.java @@ -28,6 +28,14 @@ public DoipUdpVehicleAnnouncementMessage(byte[] vin, int logicalAddress, byte[] log(Level.INFO); } + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VAM); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VAM); + } + public void log(Level level) { logger.log(level, "----------------------------------------"); logger.log(level, "DoIP vehicle announcement message:"); @@ -36,15 +44,20 @@ public void log(Level level) { logger.log(level, " EID = " + Conversion.byteArrayToHexString(eid)); logger.log(level, " GID = " + Conversion.byteArrayToHexString(gid)); logger.log(level, " Further action required = " + furtherActionRequired); - logger.log(level, " Sync status = " + syncStatus); + if (syncStatus == -1) { + logger.log(level, " Sync status not available"); + } else { + logger.log(level, " Sync status = " + syncStatus); + } logger.log(level, "----------------------------------------"); } @Override public byte[] getMessage() { byte[] msg = new byte[41]; - msg[0] = 0x02; - msg[1] = (byte) 0xFD; + if (syncStatus == -1) msg = new byte[40]; + msg[0] = 0x03; + msg[1] = (byte) 0xFC; msg[2] = 0x00; msg[3] = 0x04; msg[4] = 0x00; @@ -59,7 +72,7 @@ public byte[] getMessage() { System.arraycopy(this.eid, 0, msg, 27, 6); System.arraycopy(this.gid, 0, msg, 33, 6); msg[39] = (byte) this.furtherActionRequired; - msg[40] = (byte) this.syncStatus; + if (syncStatus != -1) msg[40] = (byte) this.syncStatus; return msg; } diff --git a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequest.java b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequest.java index 9118104..c2796bf 100644 --- a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequest.java +++ b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequest.java @@ -17,6 +17,14 @@ public void log(Level level) { logger.log(level, "DoIP vehicle identification request."); logger.log(level, "----------------------------------------"); } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR); + } @Override public byte[] getMessage() { diff --git a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithEid.java b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithEid.java index 0aca438..4cdbb4b 100644 --- a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithEid.java +++ b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithEid.java @@ -25,6 +25,14 @@ public void log(Level level) { logger.log(level, " EID = " + Conversion.byteArrayToHexString(this.eid)); logger.log(level, "----------------------------------------"); } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR_EID); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR_EID); + } @Override public byte[] getMessage() { diff --git a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithVin.java b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithVin.java index 69b4412..6afcb59 100644 --- a/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithVin.java +++ b/src/main/java/doip/library/message/DoipUdpVehicleIdentRequestWithVin.java @@ -23,6 +23,15 @@ public void log(Level level) { logger.log(level, " VIN = " + Conversion.byteArrayToHexString(this.vin)); logger.log(level, "----------------------------------------"); } + + public String getMessageName() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR_VIN); + } + + public static String getMessageNameOfClass() { + return getPayloadTypeAsString(DoipMessage.TYPE_UDP_VIR_VIN); + } + @Override public byte[] getMessage() { byte[] msg = new byte[25]; diff --git a/src/main/java/doip/library/net/TcpReceiver.java b/src/main/java/doip/library/net/TcpReceiver.java index fdd8a6c..45035b1 100644 --- a/src/main/java/doip/library/net/TcpReceiver.java +++ b/src/main/java/doip/library/net/TcpReceiver.java @@ -5,15 +5,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; + /** * Implements functions to handle events from a TCP socket. * It is implemented as a typical publisher-subscriber pattern. - * */ public class TcpReceiver { - private Logger logger = LogManager.getLogger(TcpReceiver.class); + private static Logger logger = LogManager.getLogger(TcpReceiver.class); + private static Marker enter = MarkerManager.getMarker("ENTER"); + private static Marker exit = MarkerManager.getMarker("EXIT"); LinkedList listeners = new LinkedList(); @@ -22,9 +26,9 @@ public class TcpReceiver { * @param listener The listener which shall be added */ public void addListener(TcpReceiverListener listener) { - this.logger.trace(">>> void addListener(TcpReceiverListener listener)"); + logger.trace(enter, ">>> void addListener(TcpReceiverListener listener)"); this.listeners.add(listener); - this.logger.trace("<<< void addListener(TcpReceiverListener listener)"); + logger.trace(exit, "<<< void addListener(TcpReceiverListener listener)"); } /** @@ -32,9 +36,9 @@ public void addListener(TcpReceiverListener listener) { * @param listener The listener which shall be removed */ public void removeListener(TcpReceiverListener listener) { - this.logger.trace(">>> void removeListener(TcpReceiverListener listener)"); + logger.trace(enter, ">>> void removeListener(TcpReceiverListener listener)"); this.listeners.remove(listener); - this.logger.trace("<<< void removeListener(TcpReceiverListener listener)"); + logger.trace(exit, "<<< void removeListener(TcpReceiverListener listener)"); } /** @@ -43,13 +47,13 @@ public void removeListener(TcpReceiverListener listener) { * @param data The data which had been received */ public void onDataReceived(byte[] data) { - this.logger.trace(">>> void onDataReceived(byte[] data)"); + logger.trace(enter, ">>> void onDataReceived(byte[] data)"); Iterator iter = this.listeners.iterator(); while (iter.hasNext()) { TcpReceiverListener listener = iter.next(); listener.onDataReceived(data); } - this.logger.trace("<<< void onDataReceived(byte[] data)"); + logger.trace(exit, "<<< void onDataReceived(byte[] data)"); } /** @@ -57,12 +61,12 @@ public void onDataReceived(byte[] data) { * informs all listeners that the socket had been closed. */ public void onSocketClosed() { - this.logger.trace(">>> public void onSocketClosed()"); + logger.trace(enter, ">>> public void onSocketClosed()"); Iterator iter = this.listeners.iterator(); while (iter.hasNext()) { TcpReceiverListener listener = iter.next(); listener.onSocketClosed(); } - this.logger.trace("<<< public void onSocketClosed()"); + logger.trace(exit, "<<< public void onSocketClosed()"); } } diff --git a/src/main/java/doip/library/net/TcpReceiverThread.java b/src/main/java/doip/library/net/TcpReceiverThread.java index fbd4f13..537546a 100644 --- a/src/main/java/doip/library/net/TcpReceiverThread.java +++ b/src/main/java/doip/library/net/TcpReceiverThread.java @@ -7,6 +7,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import doip.library.util.Conversion; import doip.library.util.Helper; @@ -24,43 +26,35 @@ */ public class TcpReceiverThread extends TcpReceiver implements Runnable { - /** - * log4j logger - */ - private Logger logger = LogManager.getLogger(TcpReceiverThread.class); + /** Log4j logger */ + private static Logger logger = LogManager.getLogger(TcpReceiverThread.class); - /** - * This is the thread which will be started. - */ + /** Log4j marker for function entry */ + private static Marker enter = MarkerManager.getMarker("ENTER"); + + /** Log4j marker for function exit */ + private static Marker exit = MarkerManager.getMarker("EXIT'"); + + /** This is the thread which will be started. */ private volatile Thread thread = null; /** - * Name of the thread. This can be any name. It will be used in log4j when the - * thread name will be logged in the log file. + * Name of the thread. This can be any name. It will be used in Log4j + * when the thread name will be logged in the log file. */ private String threadName = null; - /** - * The socket on which the thread will listen for incoming data. - */ + /** The socket on which the thread will listen for incoming data. */ private volatile Socket socket = null; - /** - * Maximum number of bytes which will be logged. - */ + /** Maximum number of bytes which will be logged for messages. */ private int maxByteArraySizeLogging = 64; - /** - * This constructor shall never be used so it had been declared private. - */ - @SuppressWarnings("unused") - private TcpReceiverThread() { - } - /** * Constructor with the thread name. * * @param threadName Thread name which will be logged in the log file. + * @param maxByteArraySizeLogging @see maxByteArraySizeLogging */ public TcpReceiverThread(String threadName, int maxByteArraySizeLogging) { this.threadName = threadName; @@ -73,15 +67,11 @@ public TcpReceiverThread(String threadName, int maxByteArraySizeLogging) { * @return */ public synchronized boolean isAlive() { - if (logger.isTraceEnabled()) { - this.logger.trace(">>> boolean isAlive()"); - } + logger.trace(">>> boolean isAlive()"); if (this.thread == null) return false; boolean isAlive = this.thread.isAlive(); - if (logger.isTraceEnabled()) { - this.logger.trace("<<< boolean isAlive()"); - } + logger.trace("<<< boolean isAlive()"); return isAlive; } @@ -91,15 +81,11 @@ public synchronized boolean isAlive() { * @param socket Socket on which the thread will listen for new incoming data. */ public void start(Socket socket) { - if (logger.isTraceEnabled()) { - this.logger.trace(">>> void start()"); - } + logger.trace(">>> void start()"); this.socket = socket; this.thread = new Thread(this, this.threadName); this.thread.start(); - if (logger.isTraceEnabled()) { - this.logger.trace("<<< void start()"); - } + logger.trace("<<< void start()"); } /** @@ -108,9 +94,7 @@ public void start(Socket socket) { * socket. */ public void stop() { - if (logger.isTraceEnabled()) { - this.logger.trace(">>> void stop()"); - } + logger.trace(">>> void stop()"); try { logger.debug("Close socket"); if (this.socket != null) { @@ -128,9 +112,7 @@ public void stop() { // logger.error(Helper.getExceptionAsString(e)); // } this.thread = null; - if (logger.isTraceEnabled()) { - this.logger.trace("<<< void stop()"); - } + logger.trace("<<< void stop()"); } /** @@ -139,18 +121,13 @@ public void stop() { */ @Override public void run() { - if (logger.isTraceEnabled()) { - this.logger.trace(">>> void run()"); - } + logger.trace(enter, ">>> void run()"); try { byte[] data = new byte[0x10000]; InputStream inputStream = this.socket.getInputStream(); for (;;) { - if (logger.isDebugEnabled()) { - logger.debug("Read data from socket input stream (blocking read) ..."); - } - + logger.debug("Read data from socket input stream (blocking read) ..."); int count = inputStream.read(data); if (count <= 0) { @@ -160,25 +137,25 @@ public void run() { } else { byte[] receivedData = Arrays.copyOf(data, count); - if (logger.isInfoEnabled()) { - this.logger.info("TCP-RECV: Remote = " + this.socket.getInetAddress().getHostAddress() + ":" - + this.socket.getPort() + ", Length = " + receivedData.length + ", Data = " + Conversion - .byteArrayToHexStringShortDotted(receivedData, this.maxByteArraySizeLogging)); - } + logger.info("TCP-RECV: Remote = " + this.socket.getInetAddress().getHostAddress() + ":" + + this.socket.getPort() + ", Length = " + receivedData.length + ", Data = " + Conversion + .byteArrayToHexStringShortDotted(receivedData, this.maxByteArraySizeLogging)); this.onDataReceived(receivedData); } } - if (logger.isDebugEnabled()) { - logger.debug("No more data to receive. Thread will terminate."); - } + logger.debug("No more data to receive. Thread will terminate."); + } catch (IOException e) { + logger.info("An IOException occured while reading data from the socket."); + logger.info("This might be because"); + logger.info(" - the TCP connection has been closed by the remote host,"); + logger.info(" - the connection has been closed by the local host or"); + logger.info(" - a TCP communication error did occur."); logger.info(Helper.getExceptionAsString(e)); } this.onSocketClosed(); - if (logger.isTraceEnabled()) { - this.logger.trace("<<< void run()"); - } + logger.trace(exit, "<<< void run()"); } public Socket getSocket() { diff --git a/src/main/java/doip/library/properties/MissingProperty.java b/src/main/java/doip/library/properties/MissingProperty.java index dccc8c3..2cb65fa 100755 --- a/src/main/java/doip/library/properties/MissingProperty.java +++ b/src/main/java/doip/library/properties/MissingProperty.java @@ -9,9 +9,6 @@ @SuppressWarnings("serial") public class MissingProperty extends Exception { - @SuppressWarnings("unused") - private MissingProperty() {} - /** * Constructor with the key * @param key The key which was expected to exist in the property file. diff --git a/src/main/java/doip/library/properties/MissingSystemProperty.java b/src/main/java/doip/library/properties/MissingSystemProperty.java new file mode 100644 index 0000000..9b8d1af --- /dev/null +++ b/src/main/java/doip/library/properties/MissingSystemProperty.java @@ -0,0 +1,10 @@ +package doip.library.properties; + +public class MissingSystemProperty extends Exception { + + private static final long serialVersionUID = 839224216192327460L; + + public MissingSystemProperty(String key) { + super("The systemproperty \"" +key+"\" is missing"); + } +} diff --git a/src/main/java/doip/library/util/StringConstants.java b/src/main/java/doip/library/util/StringConstants.java index 374a153..95b0630 100644 --- a/src/main/java/doip/library/util/StringConstants.java +++ b/src/main/java/doip/library/util/StringConstants.java @@ -5,30 +5,30 @@ public class StringConstants { /** * String with 78 characters '-' */ - public static final String LINE = "------------------------------------------------------------------------------"; + public static final String SINGLE_LINE = "------------------------------------------------------------------------------"; /** * String with 78 characters '#' */ - public static final String FENCE = "##############################################################################"; + public static final String HASH_LINE = "##############################################################################"; /** * String with 78 characters '=' */ - public static final String WALL = "=============================================================================="; + public static final String DOUBLE_LINE = "=============================================================================="; /** * String with 36 characters "-" */ - public static final String SHORTLINE = "------------------------------------"; + public static final String SHORT_SINGLE_LINE = "------------------------------------"; /** * String with 36 characters '#' */ - public static final String SHORTFENCE = "####################################"; + public static final String SHORT_HASH_LINE = "####################################"; /** * String with 36 characters '=' */ - public static final String SHORTWALL = "===================================="; + public static final String SHORT_DOUBLE_LINE = "===================================="; } diff --git a/src/test/java/doip/library/message/TestDoipTcpAliveCheckRequest.java b/src/test/java/doip/library/message/TestDoipTcpAliveCheckRequest.java index 90e9263..0caf4f2 100644 --- a/src/test/java/doip/library/message/TestDoipTcpAliveCheckRequest.java +++ b/src/test/java/doip/library/message/TestDoipTcpAliveCheckRequest.java @@ -17,6 +17,6 @@ public void test() { DoipTcpAliveCheckRequest msg = new DoipTcpAliveCheckRequest(); String hexString = Conversion.byteArrayToHexString(msg.getMessage()); logger.info("HEX string = " + hexString); - assertEquals("02 FD 00 07 00 00 00 00", hexString); + assertEquals("03 FC 00 07 00 00 00 00", hexString); } } diff --git a/src/test/java/doip/library/message/TestDoipTcpAliveCheckResponse.java b/src/test/java/doip/library/message/TestDoipTcpAliveCheckResponse.java index d77b60f..733a548 100644 --- a/src/test/java/doip/library/message/TestDoipTcpAliveCheckResponse.java +++ b/src/test/java/doip/library/message/TestDoipTcpAliveCheckResponse.java @@ -12,7 +12,7 @@ public class TestDoipTcpAliveCheckResponse { public void test() { DoipTcpAliveCheckResponse msg = new DoipTcpAliveCheckResponse(0x1234); String hexString = Conversion.byteArrayToHexString(msg.getMessage()); - assertEquals("02 FD 00 08 00 00 00 02 12 34", hexString); + assertEquals("03 FC 00 08 00 00 00 02 12 34", hexString); } } diff --git a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessage.java b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessage.java index 57b0da1..56da12b 100644 --- a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessage.java +++ b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessage.java @@ -12,7 +12,7 @@ public class TestDoipTcpDiagnosticMessage { public void test() { DoipTcpDiagnosticMessage msg = new DoipTcpDiagnosticMessage(0x1122, 0x3344, new byte[] {0x01, 0x02, 0x03, 0x04 }); String hexString = Conversion.byteArrayToHexString(msg.getMessage()); - assertEquals("02 FD 80 01 00 00 00 08 11 22 33 44 01 02 03 04", hexString); + assertEquals("03 FC 80 01 00 00 00 08 11 22 33 44 01 02 03 04", hexString); } } diff --git a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessageNegAck.java b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessageNegAck.java index 580a8c2..5b19bef 100644 --- a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessageNegAck.java +++ b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessageNegAck.java @@ -12,6 +12,6 @@ public class TestDoipTcpDiagnosticMessageNegAck { public void test() { DoipTcpDiagnosticMessageNegAck msg = new DoipTcpDiagnosticMessageNegAck(0x1122, 0x3344, 0x02, new byte[0]); String hexString = Conversion.byteArrayToHexString(msg.getMessage()); - assertEquals("02 FD 80 03 00 00 00 05 11 22 33 44 02", hexString); + assertEquals("03 FC 80 03 00 00 00 05 11 22 33 44 02", hexString); } } diff --git a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessagePosAck.java b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessagePosAck.java index 67b25c0..7b43805 100644 --- a/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessagePosAck.java +++ b/src/test/java/doip/library/message/TestDoipTcpDiagnosticMessagePosAck.java @@ -12,7 +12,7 @@ public class TestDoipTcpDiagnosticMessagePosAck { public void test() { DoipTcpDiagnosticMessagePosAck msg = new DoipTcpDiagnosticMessagePosAck(0x1122, 0x3344, 0x00, new byte[] { 0x10, 003 }); String hexString = Conversion.byteArrayToHexString(msg.getMessage()); - assertEquals("02 FD 80 02 00 00 00 07 11 22 33 44 00 10 03", hexString); + assertEquals("03 FC 80 02 00 00 00 07 11 22 33 44 00 10 03", hexString); } }