You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Alessandro Rossignoli (Jira)" <ji...@apache.org> on 2020/06/04 16:35:00 UTC

[jira] [Comment Edited] (PLC4X-202) OPC-UA Driver cannot write Unsigned Types

    [ https://issues.apache.org/jira/browse/PLC4X-202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17126057#comment-17126057 ] 

Alessandro Rossignoli edited comment on PLC4X-202 at 6/4/20, 4:34 PM:
----------------------------------------------------------------------

[~nalim2] using the larger type is ok for the internal implementation, but let's look at the user of plc4x perspective: when the user passes an integer, how do you distinguish an unsigned short from an actual integer? Is there any type info on the address of a variable in the OPC standard? ex: ns=2;i=3/UInt32?
 Moreover when reading, the addresses are not required to contain any type information (if OPC-UA supports any).

The problem is that if the type on the OPC server doesn't match the type you write on the addItem call, it won't write anything and will reply an INVALID_DATA_TYPE.
{code:java}
plcWriteRequestBuilder.addItem("var", "ns=2;i=1", 12);
{code}
so writing 12 will pass a java.lang.Integer by default, but trust me, if the OPC server has an unsigned integral type there is no way that Milo will write 12.

When reading there is no problem in the type since we the type info is probably put on an Object type by the OPC server.


was (Author: itaross):
[~nalim2] using the larger type is ok for the internal implementation, but let's look at the user of plc4x perspective: when the user passes an integer, how do you distinguish an unsigned short from an actual integer? Is there any type info on the address of a variable in the OPC standard? ex: ns=2;i=3/UInt32?
Moreover when reading, the addresses are not required to contain any type information (if OPC-UA supports any).

The problem is that if the type on the OPC server doesn't match the type you write on the addItem call, it won't write anything and will reply an INVALID_DATA_TYPE.
{code:java}
plcWriteRequestBuilder.addItem("var", "ns=2;i=1", 12);
{code}
so writing 12 will pass a java.lang.Integer by default, but trust me, if the OPC server has an unsigned integral type there is no way that Milo will write 12.

> OPC-UA Driver cannot write Unsigned Types
> -----------------------------------------
>
>                 Key: PLC4X-202
>                 URL: https://issues.apache.org/jira/browse/PLC4X-202
>             Project: Apache PLC4X
>          Issue Type: Bug
>          Components: Driver-OPC-UA
>    Affects Versions: 0.7.0
>            Reporter: Alessandro Rossignoli
>            Priority: Major
>
> Currently, unsigned types are not supported in writing direction from the driver although they are fully supported by Eclipse Milo and in reading.
> Actually I have applied a modification and tested it to be able to support these types. It is kind of the same patch applied for BigIntegers but done introducing UShort and UInteger from Eclipse Milo.
> The downside is that every driver will use the Eclipse Milo types, being the JVM missing unsigned types. I don't know if you have a better solution or if using Milo types in all the drivers is acceptable for you.
> I am open for suggestions :)
>  
> (PS. when I will complete all the testing I will create 3 separate PR for issue #200, #201 and this one)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)