You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/02/07 11:22:20 UTC
[incubator-plc4x] 02/02: switch to LittleEndian
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch feature/Beckhoff_ADS_protocol
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 944cebf35cfaf74b43f23f0f55bd981febc5d597
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Feb 7 12:22:14 2018 +0100
switch to LittleEndian
---
.../plc4x/java/ads/api/commands/types/Length.java | 7 +++---
.../java/ads/api/commands/types/ReadLength.java | 7 +++---
.../java/ads/api/commands/types/SampleSize.java | 7 +++---
.../plc4x/java/ads/api/commands/types/Samples.java | 7 +++---
.../java/ads/api/commands/types/WriteLength.java | 7 +++---
.../plc4x/java/ads/api/generic/types/AMSPort.java | 3 ++-
.../plc4x/java/ads/api/generic/types/Command.java | 29 +++++++++++-----------
.../java/ads/api/generic/types/DataLength.java | 7 +++---
.../plc4x/java/ads/api/generic/types/Length.java | 7 +++---
.../plc4x/java/ads/api/generic/types/State.java | 15 ++++++-----
10 files changed, 51 insertions(+), 45 deletions(-)
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
index 390ef3e..606f432 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
@@ -34,10 +34,11 @@ public class Length extends ByteValue {
public static Length of(long length) {
checkUnsignedBounds(length, NUM_BYTES);
return new Length(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (length >> 24 & 0xff))
- .put((byte) (length >> 16 & 0xff))
- .put((byte) (length >> 8 & 0xff))
+ // LE
.put((byte) (length & 0xff))
+ .put((byte) (length >> 8 & 0xff))
+ .put((byte) (length >> 16 & 0xff))
+ .put((byte) (length >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
index 9f48a2b..bf2a06f 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
@@ -34,10 +34,11 @@ public class ReadLength extends ByteValue {
public static ReadLength of(long length) {
checkUnsignedBounds(length, NUM_BYTES);
return new ReadLength(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (length >> 24 & 0xff))
- .put((byte) (length >> 16 & 0xff))
- .put((byte) (length >> 8 & 0xff))
+ // LE
.put((byte) (length & 0xff))
+ .put((byte) (length >> 8 & 0xff))
+ .put((byte) (length >> 16 & 0xff))
+ .put((byte) (length >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
index ff78866..55e1306 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
@@ -34,10 +34,11 @@ public class SampleSize extends ByteValue {
public static SampleSize of(long sampleSize) {
checkUnsignedBounds(sampleSize, NUM_BYTES);
return new SampleSize(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (sampleSize >> 24 & 0xff))
- .put((byte) (sampleSize >> 16 & 0xff))
- .put((byte) (sampleSize >> 8 & 0xff))
+ // LE
.put((byte) (sampleSize & 0xff))
+ .put((byte) (sampleSize >> 8 & 0xff))
+ .put((byte) (sampleSize >> 16 & 0xff))
+ .put((byte) (sampleSize >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
index 2298e00..4ebfddb 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
@@ -34,10 +34,11 @@ public class Samples extends ByteValue {
public static Samples of(long numberOfSamples) {
checkUnsignedBounds(numberOfSamples, NUM_BYTES);
return new Samples(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (numberOfSamples >> 24 & 0xff))
- .put((byte) (numberOfSamples >> 16 & 0xff))
- .put((byte) (numberOfSamples >> 8 & 0xff))
+ // LE
.put((byte) (numberOfSamples & 0xff))
+ .put((byte) (numberOfSamples >> 8 & 0xff))
+ .put((byte) (numberOfSamples >> 16 & 0xff))
+ .put((byte) (numberOfSamples >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
index 12931d6..4e593c0 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
@@ -34,10 +34,11 @@ public class WriteLength extends ByteValue {
public static WriteLength of(long length) {
checkUnsignedBounds(length, NUM_BYTES);
return new WriteLength(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (length >> 24 & 0xff))
- .put((byte) (length >> 16 & 0xff))
- .put((byte) (length >> 8 & 0xff))
+ // LE
.put((byte) (length & 0xff))
+ .put((byte) (length >> 8 & 0xff))
+ .put((byte) (length >> 16 & 0xff))
+ .put((byte) (length >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
index a0439bb..906a456 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
@@ -41,8 +41,9 @@ public class AMSPort extends ByteValue {
public static AMSPort of(int port) {
checkUnsignedBounds(port, NUM_BYTES);
return new AMSPort(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (port >> 8 & 0xff))
+ // LE
.put((byte) (port & 0xff))
+ .put((byte) (port >> 8 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Command.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Command.java
index f831a61..b5b8da2 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Command.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Command.java
@@ -26,22 +26,22 @@ import org.apache.plc4x.java.ads.api.util.ByteValue;
import java.nio.ByteBuffer;
public enum Command implements ByteReadable {
- Invalid(0x0000),
- ADS_Read_Device_Info(0x0001),
- ADS_Read(0x0002),
- ADS_Write(0x0003),
- ADS_Read_State(0x0004),
- ADS_Write_Control(0x0005),
- ADS_Add_Device_Notification(0x0006),
- ADS_Delete_Device_Notification(0x0007),
- ADS_Device_Notification(0x0008),
- ADS_Read_Write(0x0009),
+ Invalid(0x00),
+ ADS_Read_Device_Info(0x01),
+ ADS_Read(0x02),
+ ADS_Write(0x03),
+ ADS_Read_State(0x04),
+ ADS_Write_Control(0x05),
+ ADS_Add_Device_Notification(0x06),
+ ADS_Delete_Device_Notification(0x07),
+ ADS_Device_Notification(0x08),
+ ADS_Read_Write(0x09),
/**
* Other commands are not defined or are used internally. Therefore the Command Id is only allowed to contain the above enumerated values!
*/
UNKNOWN();
- public static final int NUM_BYTES = 4;
+ public static final int NUM_BYTES = 2;
final byte[] value;
@@ -50,13 +50,12 @@ public enum Command implements ByteReadable {
value = new byte[0];
}
- Command(long value) {
+ Command(int value) {
ByteValue.checkUnsignedBounds(value, NUM_BYTES);
this.value = ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (value >> 24 & 0xff))
- .put((byte) (value >> 16 & 0xff))
- .put((byte) (value >> 8 & 0xff))
+ // LE
.put((byte) (value & 0xff))
+ .put((byte) (value >> 8 & 0xff))
.array();
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
index 83d987b..0f56d2f 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
@@ -34,10 +34,11 @@ public class DataLength extends ByteValue {
public static DataLength of(long length) {
checkUnsignedBounds(length, NUM_BYTES);
return new DataLength(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (length >> 24 & 0xff))
- .put((byte) (length >> 16 & 0xff))
- .put((byte) (length >> 8 & 0xff))
+ // LE
.put((byte) (length & 0xff))
+ .put((byte) (length >> 8 & 0xff))
+ .put((byte) (length >> 16 & 0xff))
+ .put((byte) (length >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
index b0b4363..14da90e 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
@@ -34,10 +34,11 @@ public class Length extends ByteValue {
public static Length of(long length) {
checkUnsignedBounds(length, NUM_BYTES);
return new Length(ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (length >> 24 & 0xff))
- .put((byte) (length >> 16 & 0xff))
- .put((byte) (length >> 8 & 0xff))
+ // LE
.put((byte) (length & 0xff))
+ .put((byte) (length >> 8 & 0xff))
+ .put((byte) (length >> 16 & 0xff))
+ .put((byte) (length >> 24 & 0xff))
.array());
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
index bb444c2..47fbb40 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
@@ -42,13 +42,13 @@ import java.nio.ByteBuffer;
* Bit number 7 marks, if it should be transfered with TCP or UDP.
*/
public enum State implements ByteReadable {
- ADS_REQUEST_TCP(0x0004),
- ADS_RESPONSE_TCP(0x0005),
- ADS_REQUEST_UDP(0x0044),
- ADS_RESPONSE_UDP(0x0045),
+ ADS_REQUEST_TCP(0x04),
+ ADS_RESPONSE_TCP(0x05),
+ ADS_REQUEST_UDP(0x44),
+ ADS_RESPONSE_UDP(0x45),
UNKNOWN();
- public static final int NUM_BYTES = 4;
+ public static final int NUM_BYTES = 2;
final byte[] value;
@@ -59,10 +59,9 @@ public enum State implements ByteReadable {
State(long value) {
ByteValue.checkUnsignedBounds(value, NUM_BYTES);
this.value = ByteBuffer.allocate(NUM_BYTES)
- .put((byte) (value >> 24 & 0xff))
- .put((byte) (value >> 16 & 0xff))
- .put((byte) (value >> 8 & 0xff))
+ // LE
.put((byte) (value & 0xff))
+ .put((byte) (value >> 8 & 0xff))
.array();
}
--
To stop receiving notification emails like this one, please contact
sruehl@apache.org.