BadTypeMismatch while writing value from Client

Questions regarding the use of the Java SDK for Server or Client development or integration into customer products ...

Moderator: uasdkjava

Post Reply
Peter Eser
Full Member
Full Member
Posts: 8
Joined: 22 Oct 2015, 13:00

BadTypeMismatch while writing value from Client

Post by Peter Eser »

Hello all,

UaExpert gives a "Write to node ... failed [ret = BadTypeMismatch] when I change the value in the Data Access View.
DataType in Attributes is UInt16, this seems ok, nevertheless Data Access View shows Datatype Int32.
HasTypeDefinition is BaseDataVariableType
AccessLevel is Readable,Writeable
If I put in text instead of a number I get an other error (Could not convert value...) -> good.
My (own written) server shows no error message.

BTW how can I catch such write changes fron the client in the server. PlainVariable.addChangeListener() seems to catch all changes, even those with setValue().

Thanks for any help.
Regards, Peter

User avatar
Support Team
Hero Member
Hero Member
Posts: 2522
Joined: 18 Mar 2011, 15:09

Re: BadTypeMismatch while writing value from Client

Post by Support Team »

Hi Peter,

It looks like the server provides a different data type in the Value attribute (Int32) than indicated in the DataType attribute (UInt16).
UaExpert tries to write the data type back that he received before from the server. This fails since the server has to check the data type at write and we assume that the server rejects the written value (Int32) since the data type attribute is set to UInt16.

Please check what is the right data type (Int32 or UInt16) and set Value and DataType attribute consistent in your server.

Best Regards,
Unified Automation Support Team

Peter Eser
Full Member
Full Member
Posts: 8
Joined: 22 Oct 2015, 13:00

Re: BadTypeMismatch while writing value from Client

Post by Peter Eser »

Hello Support Team,

many thanks for answering. You're right, the Object type for setValue() in CacheVariable must 100% map to the DataType set.
So e.g. cannot set a Java Integer for an UInt16, have to remap to org.opcfoundation.ua.builtintypes.UnsignedShort.

Any idea to listen to such write changes from the client in the server?

Thanks and Regards, Peter

User avatar
Support Team
Hero Member
Hero Member
Posts: 2522
Joined: 18 Mar 2011, 15:09

Re: BadTypeMismatch while writing value from Client

Post by Support Team »

Hello,

The IoManagerListener is used to listen to change (i.e. write) requests from clients. The Server Tutorial shows how to use it.

Best regards
Suppport Team

Post Reply