Hi,
I am investigating an issue we are seeing when using the ReadMultipleValues function in a .NET 4.8 framework project using OPCLabs.QuickOpc NuGet package 5.61.343.
We are using the OPC-UA library to connect to a Siemens PLC, although this issue is OPC Server independent, where there are a number of items we need to read back. The item tags differ in datatype and range from floats, int16/short, uint16/ushort. When reading the uint16/ushort datatypes the value returned from the ReadMultipleValues command in the ValueResult is typed as an INT and not a ushort, which is incorrect if you do a typeof on the value. The same read on an int16/short does return a short typed value in the ValueResult structure.
If i run a ReadMultipleValues to get the DataType attribute for the items they do report the correct datatype. So, for Uint16 items this call indicates the OPC type as UInt16 etc. So, the opc server is returning the correct type for the item.
I have attached two screenshots to highlight the problem. The top half of the screenshot shows the value return from the attribute call to ReadMultipleValues where i request the datatype for the items. The bottom half shows the value returned in the ValueResult from the value read, for the same item. As you can see in the second screenshot the UInt16 is being returned as an Int32.
The first shows a correctly typed Int16 item:
The second shows the incorrectly typed UInt16:
If i change the UInt16 item in the OPC server to a Int16 you can see the same item now returns correctly as a short:
I assume this behaviour isn't as intended or am i wrong on this? I haven't had chance to create a minimal reproduction of this as yet but if you need one i can look at putting one together.