How to Read and Write to a WAGO Modbus 750-841



  • My current project requires me to connect to a WAGO Modbus 750-841 and be able to read from each coil and write to each coil. I was able to establish a connection but now my problem is read and writing. I don't know where to start or what approach I should take. I have used a basic write method and bytesAvailable method but each one doesn't want to communicate to the Modbus. I don't know what i'm doing wrong. My code is as follows any help would greatly appreciated.

    socket->connectToHost("IP address of Modbus",502);
    
    if(socket->waitForConnected(3000))
    {
        qDebug() << "Connected!!";
    
        //write
        socket->write("FC=01");
        qDebug() << "Bytes to write" << socket->bytesToWrite();
    
        //read
        socket->waitForBytesWritten(1000);
        socket->waitForReadyRead(3000);
    
        qDebug() << "Reading:" << socket->bytesAvailable();
        
    }
    else
    {
        qDebug() << "Not Connected!!";
    }

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.