19:03, EEST
June 27, 2012
I tried this using the client SDK instead, and I’m seeing the same problem.
TintArr is an Int16[3], and TbyteArr is an SByte[3].
Here’s my code:
NodeId arrId = new NodeId(2, “TintArr”);
DataValue dv = client.readValue(arrId);
System.out.println(dv.getValue()); // Prints [2, 4, 6]
Short [] intData = new Short[3];
intData[0] = new Short((short)3);
intData[1] = new Short((short)6);
intData[2] = new Short((short)9);
client.writeValue(arrId, intData); // Succeeds
arrId = new NodeId(2, “TbyteArr”);
dv = client.readValue(arrId);
System.out.println(dv.getValue()); // Prints [1, 2, 3]
Byte [] byteData = new Byte[3];
byteData[0] = new Byte((byte)2);
byteData[1] = new Byte((byte)4);
byteData[2] = new Byte((byte)6);
client.writeValue(arrId, byteData); // Throws exception
Exception in thread “main” com.prosysopc.ua.StatusException: Bad_TypeMismatch (0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.” StatusCode=Bad_TypeMismatch (0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.”
at com.prosysopc.ua.client.UaClient.a(Unknown Source)
at com.prosysopc.ua.client.UaClient.writeAttribute(Unknown Source)
at com.prosysopc.ua.client.UaClient.writeValue(Unknown Source)
at com.oldi.opcuaclient.SampleConsoleClient.writeByteArray(SampleConsoleClient.java:279)
at com.oldi.opcuaclient.SampleConsoleClient.main(SampleConsoleClient.java:298)
7:46, EEST
December 21, 2011
I could not reproduce this: I created this kind of node in the server:
CacheVariable sByteArrayNode = new CacheVariable(myNodeManager, SBYTEARRAY_NODEID, "SByteArray", LocalizedText.NO_LOCALE); sByteArrayNode.setDataTypeId(Identifiers.SByte); sByteArrayNode.setValueRank(ValueRanks.OneDimension);
And write to it from the client like
Byte[] byteData = new Byte[3]; byteData[0] = new Byte((byte) 2); byteData[1] = new Byte((byte) 4); byteData[2] = new Byte((byte) 6); client.writeValue(SBYTEARRAY_NODEID, byteData);
without an error.
What’s the DataType that you use for the Node?
11:47, EEST
December 21, 2011
14:33, EEST
January 30, 2014
Hi Aro,
Could you please give me your opinion. Problem is similar to above described.
I get into trouble with Beckhoff OPC UA server and two-dimensional array. I can’t figure out why I am getting this type mismatch status
when try to write with UaClient.
Also when I tried to write the value to the same array with UaExpert demo client via their GUI I am getting the same error.
With one-dimensional array there is no problem.
Here is the code:
DataValue value1 = getUaClient().readAttribute(testNode1, Attributes.Value);
DataValue dimensions = getUaClient().readAttribute(testNode1, Attributes.ArrayDimensions);
UnsignedInteger[] dims = (UnsignedInteger[]) dimensions.getValue().getValue();
int first = dims[0].intValue();
int second = dims[1].intValue();
Object v1 = value1.getValue().getValue();
Integer[][] xray1 = (Integer[][]) v1;
if (value1.getValue().isArray()) {
logger.info("ArrayDimension: " + MultiDimensionArrayUtils.getDimension(v1));
logger.info("Values: " + MultiDimensionArrayUtils.toString(v1));
for (int i = 0; i < first; i++) {
for (int j = 0; j < second; j++) {
logger.info("[{}][{}] : {}", i, j, xray1[i][j]);
xray1[i][j] = new Integer(15011);
}
}
}
getUaClient().writeAttribute(testNode1, Attributes.Value, xray1); // <———- here it fires the error
and this is the log:
27.06.2014 16:17:17,779 INFO OpcUaServerBrowser.createOpcUaSymbolFile – ArrayDimension: 2
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – Values: [[3155068, 0, 0, 0, 0][0, 0, 0, 3155068, 0]]
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [0][0] : 3155068
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [0][1] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [0][2] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [0][3] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [0][4] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [1][0] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [1][1] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [1][2] : 0
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [1][3] : 3155068
27.06.2014 16:17:17,780 INFO OpcUaServerBrowser.createOpcUaSymbolFile – [1][4] : 0
27.06.2014 16:17:17,784 ERROR OpcUaServerBrowser.createOpcUaSymbolFile – Bad_TypeMismatch (0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.”
The value in UaExpert client is shown as: Int32 Matrix[2][5] and DataType is Int32 and it is with r/w enabled.
Is this problem related to server side?
BR,
Goran
Most Users Ever Online: 1919
Currently Online:
24 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 731
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1