Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Open62541 OPC UA Reading Node Value

  • Hi,

    I'm trying to work with the Open62541 library. My only problem is to read the value of the node. It's a boolean. What is my mistake?

    #include <QCoreApplication>
    #include <QOpcUaClient>
    #include <QOpcUaProvider>

    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);

    QOpcUaProvider provider;
    if (provider.availableBackends().isEmpty())
        return 0;
    QOpcUaClient *client = provider.createClient(provider.availableBackends()[0]);
    if (!client)
        qDebug() << "error";
    // Connect to the stateChanged signal. Compatible slots of QObjects can be used instead of a lambda.
    QObject::connect(client, &QOpcUaClient::stateChanged, [client](QOpcUaClient::ClientState state) {
        qDebug() << "Client state changed:" << state;
        if (state == QOpcUaClient::ClientState::Connected) {
            QOpcUaNode *node = client->node("ns=3;s=S7_300.Eingang.E137_6");
            if (node)
                qDebug() << "A node object has been created";
            node->readAttributes(QOpcUa::NodeAttribute::Value);  // here is probably my mistake Output= QVariant(Invalid)
            qDebug() << node->attribute(QOpcUa::NodeAttribute::Value);
    client->connectToEndpoint(QUrl("opc.tcp://")); // Connect to the first endpoint in the list
    return a.exec();


Log in to reply