BadTypeMismatch|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
BadTypeMismatch
Avatar
Nadeesha Dileen Nawagaththegama
Member
Members
Forum Posts: 4
Member Since:
12/11/2017
sp_UserOfflineSmall Offline
1
01/28/2018 - 23:21
sp_Permalink sp_Print

Hi,

I'm new to opc, opcua and wont to write a new node value to server form opcua client, so i used following way and passed appropriate arguments to that write function. But it gets results as {BadTypeMismatch}, can you please help me to solve this.

ResponseHeader responseHeader = m_session.Write(
                    null,
                    nodesToWrite,
                    out results,
                    out diagnosticInfos);

Thank you..

Avatar
Paul Hunkar
Member
Members
Forum Posts: 27
Member Since:
07/05/2017
sp_UserOfflineSmall Offline
2
01/29/2018 - 13:46
sp_Permalink sp_Print

Hi,

BadTypeMismatch means that the datatype of the variable you were trying to write to does not match what you are writing, without more information (like actual parameters values and some information about the server) that is about all I can provided.

Paul

Avatar
Nadeesha Dileen Nawagaththegama
Member
Members
Forum Posts: 4
Member Since:
12/11/2017
sp_UserOfflineSmall Offline
3
01/29/2018 - 22:36
sp_Permalink sp_Print sp_EditHistory

Hi Paul,

Thanks for helping. 

I 'm testing my client with Opc Ua Quickstart Data Access Server. Following is the code with parameters and values that I'm used. pls help

WriteValueCollection nodesToWrite = new WriteValueCollection();
WriteValue writeValue = new WriteValue();
NodeId nodeId = "ns=2;s=1:FC1001?SetPoint";
writeValue.AttributeId = Attributes.Value;
writeValue.IndexRange = null;
object objvalue = 400.5F;
                DataValue dataValue = new DataValue()
                { 
                    WrappedValue = 400.5F,
                    SourceTimestamp = DateTime.Now,
                    Value = objvalue
                };
writeValue.Value.Value = dataValue;
writeValue.Value.StatusCode = StatusCodes.Good;
writeValue.Value.ServerTimestamp = DateTime.MinValue;
writeValue.Value.SourceTimestamp = DateTime.MinValue;
nodesToWrite.Add(writeValue);
foreach (WriteValue nodeToWrite in nodesToWrite)
{
    NumericRange indexRange;
    ServiceResult result = NumericRange.Validate(nodeToWrite.IndexRange, out indexRange);
 
    if (ServiceResult.IsGood(result) && indexRange != NumericRange.Empty)
    {
        // apply the index range.
        object valueToWrite = nodeToWrite.Value.Value;
 
        result = indexRange.ApplyRange(ref valueToWrite);
 
        if (ServiceResult.IsGood(result))
        {
            nodeToWrite.Value.Value = valueToWrite;
        }
    }
} 
StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;  
ResponseHeader responseHeader = m_session.Write(
    null,
    nodesToWrite,
    out results,
    out diagnosticInfos);
Thank you..

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 48
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855