Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-139241

OPC UA callMethod

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.9.0
    • OpcUA
    • None
    • Windows

      I'm trying to call a method using a binary NodeId. The method node is created, but the method call returns BadNodeIdUnknown. However, it works when called via UaExpert.

      // Code
      
      bool OpcUaManager::callDeleteFile(const QString &fileName)
      {
          if (!m_client || !m_connected) {
              qWarning() << "[OPC UA] Нет подключения.";
              return false;
          }    QOpcUaNode *node = m_client->node("ns=7;b=AQAAAKbhKnGK9zM6r+oscbr6M2CM7kA=");
          if (!node) {
              qWarning() << "[OPC UA] Узел метода не найден.";
              return false;
          }    QList<QOpcUa::TypedVariant> args = {
              QOpcUa::TypedVariant(fileName, QOpcUa::Types::String)
          };    connect(node, &QOpcUaNode::methodCallFinished,
                  this, [fileName, node](const QString &, const QVariant &, QOpcUa::UaStatusCode status) {
              QMetaEnum metaEnum = QMetaEnum::fromType<QOpcUa::UaStatusCode>().enclosingMetaObject()
                      ->enumerator(QMetaEnum::fromType<QOpcUa::UaStatusCode>().enclosingMetaObject()
                                   ->indexOfEnumerator("UaStatusCode"));
              const char *name = metaEnum.valueToKey(static_cast<int>(status));        if (status == QOpcUa::UaStatusCode::Good) {
                  qDebug().noquote() << "[OPC UA] DeleteFile успешно:" << fileName;
              } else {
                  qWarning().noquote() << "[OPC UA] Ошибка DeleteFile:" << fileName
                                       << "| Статус:" << (name ? name : "Unknown")
                                       << QString(" (0x%1)").arg(static_cast<quint32>(status), 8, 16, QLatin1Char('0')).toUpper();
              }        node->deleteLater();
          });
          return node->callMethod("ns=7;b=AQAAAKbhKnGK9zM6r+oscbr6M2CM7m5QjO8lYIzFKXiMgw==", args);;
      }

       

      //log  Wireshark  
                  
       [0]: CallMethodRequest
                          ObjectId: NodeId
                              .... 0101 = EncodingMask: Opaque (0x5)
                              Namespace Index: 7
                              Identifier ByteString: 01
                          MethodId: NodeId
                              .... 0101 = EncodingMask: Opaque (0x5)
                              Namespace Index: 7
                              Identifier ByteString: 01
                          InputArguments: Array of Variant
                              ArraySize: 1
                              [0]: Variant
                                  Variant Type: String (0x0c)
                                  String: R.txt

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            basyskom.jannis.voelker Jannis Völker
            xxx777 Vadim Korotaev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes