[
https://issues.apache.org/jira/browse/PLC4X-133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16879840#comment-16879840
]
Marcus Schmitt commented on PLC4X-133:
--------------------------------------
Hi,
I have encountered the same error.
Therefore I have created the following test:
{code:java}
package plc4x;
import org.apache.plc4x.java.ads.api.util.ByteValue;
import org.junit.jupiter.api.Test;
public class ByteValueTests {
@Test
public void
given_bits_0_through_31_set_when_checkUnsignedBounds_with_4_bytes_to_check_then_expect_no_error()
{
ByteValue.checkUnsignedBounds(0xffff_ffff, 4);
}
@Test
public void
given_Integer_MAX_VALUE_when_checkUnsignedBounds_with_4_bytes_to_check_then_expect_expect_no_error()
{
ByteValue.checkUnsignedBounds(Integer.MAX_VALUE, 4);
}
@Test
public void
given_Integer_MIN_VALUE_when_checkUnsignedBounds_with_4_bytes_to_check_then_expect_expect_no_error()
{
ByteValue.checkUnsignedBounds(Integer.MIN_VALUE, 4);
}
}
{code}
These tests produced the following results:
{code:java}
java.lang.IllegalArgumentException: Value must between 0 and 4.294967296E9. Was
-1
at
org.apache.plc4x.java.ads.api.util.ByteValue.checkUnsignedBounds(ByteValue.java:52)
at
plc4x.ByteValueTests.given_bits_0_through_31_set_when_checkUnsignedBounds_with_4_bytes_to_check_then_expect_no_error(ByteValueTests.java:10)
{code}
{code:java}
java.lang.IllegalArgumentException: Value must between 0 and 4.294967296E9. Was
-2147483648
at
org.apache.plc4x.java.ads.api.util.ByteValue.checkUnsignedBounds(ByteValue.java:52)
at
plc4x.ByteValueTests.given_Integer_MIN_VALUE_when_checkUnsignedBounds_with_4_bytes_to_check_then_expect_expect_no_error(ByteValueTests.java:20)
{code}
I'm expecting every test to pass because the method name implies checking
unsigned int values but the error message shows a negative number.
I hope this information proves helpful.
> ADS Big-Endian Support
> ----------------------
>
> Key: PLC4X-133
> URL: https://issues.apache.org/jira/browse/PLC4X-133
> Project: Apache PLC4X
> Issue Type: New Feature
> Components: Driver-ADS
> Affects Versions: 0.4.0
> Environment: Client
> - JDK 8
> - Windows 10
> - TwinCAT3 v3.1.4022.29
> PLC
> - Beckhoff IPC C6920-0030
> - Intel Core 2 Duo mit Windows 7 64Bit
> - Twincat XAE 3.1.4022.29 (64Bit Runtime)
> Reporter: Martin
> Priority: Minor
> Attachments: issue_DirectAdsField.png
>
>
> For some reason the response of the PLC seems not to be in *LITTLE_ENDIAN*
> format.
> Therefore, the Byte to Integer conversion in [1] results in a negative number.
>
> The issue occurs during the *symbolHandle* creation process in [2].
>
> I had a look at the ADS specification [3] and the response should be in
> *LITTLE_ENDIAN* format, but for some reason it is not.
>
> As suggested by [~cdutz] we should create an option to override the
> endianness in the connection-string.
>
> [1]
> [https://github.com/apache/plc4x/blob/develop/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedIntLEByteValue.java#L39]
> [2]
> [https://github.com/apache/plc4x/blob/develop/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java#L187]
> [3]
> [https://infosys.beckhoff.com/index.php?content=../content/1031/tcplclibutilities/html/TcPlcLibUtilities_AddOn_ByteOrder.htm&id=]
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)