Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Type error while writing array of SByte
May 7, 2013
13:09, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

I’m able to read and write array types on my server, except that when I try to write an array of SByte from UAExpert, I get a BadTypeMismatch error. The writeValue method of my NodeManager is never called for that write.

May 8, 2013
19:03, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

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)

May 10, 2013
7:46, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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?

May 10, 2013
11:10, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

Maybe it’s because I’m using a custom node manager?

In readNonValue(), I’m returning AccessLevel.READWRITE, Identifiers.Byte, and ValueRanks.OneDimension.

May 10, 2013
11:47, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

TimK said

In readNonValue(), I’m returning AccessLevel.READWRITE, Identifiers.Byte, and ValueRanks.OneDimension.

Byte in OPCUA is UnsignedByte 🙂 Change it to SByte.

June 27, 2014
14:33, EEST
Avatar
gjevremovic
Member
Members
Forum Posts: 49
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

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:

NodeId testNode1 = new NodeId(4, "MAIN.Xray");
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

June 27, 2014
14:53, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, the error comes from the server. Best to ask Beckhoff about it.

Forum Timezone: Europe/Helsinki

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, ellis87832073466

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1