Problem getting the right answer from a server receiving a TCP command



  • Hello,

    I have some problem getting the right answer from a server receiving a TCP command.

    I will try to make myself clear ;)

    My app is connecting to a server (a video device) and sends it string commands to switch video input and/or activate/deactivate functions according to the manufacturer protocol.

    Sending commands seems ok.
    Some commands are write only (modify settings), some others are read only (request an answer from the server about parameter state, e.g. power is on or off ?)

    in my case, i ask the device if HDCP feature is activated or not for each input.

    This works... almost... I can send the command and have an answer but results are a bit odd...

    I placed some qDebug() to trace some values. It seems that the first value i get is the answer sent when connection is ok (welcome message) + value requested. It appears that i get answers too late or not in time (see qDebug() output at the end of this post)

    I use signals and slots only for the connexion, other socket functions are done "manually"

    Here is what i have so far :

    handle connexion :

    [code]
    bool TCPClient::connection(QString _addr, int _port)
    {
    addr = _addr;
    port = _port;

    socket->connectToHost(addr, port);
    
    if(!socket->waitForConnected(2000))
    {
        qDebug() << "Can't connect to : " << addr << " on port " << port;
        return false;
    }
    return true;
    

    }

    [/code]

    after connexion, (signal connected()) method getHdcpStatus() is called

    [code]
    bool Matrix::getHdcpStatus(QString input)
    {
    QString resp;
    QString esc = "\x1B";
    resp = dxpClient->sendQuery(esc + "E" + input + "HDCP\r").trimmed();
    qDebug() << "HDCP for input "<< input << "= " << resp;
    return resp.toInt();
    }
    [/code]

    these 2 methods are used to send commands and requests to the device :

    [code]
    QString TCPClient::sendQuery(QString query)
    {
    if(this->sendCommand(query) && !socket->waitForReadyRead(2000))
    {
    qDebug() << "Can't get any response from device !";
    return QString();
    }
    return socket->readAll();
    }

    [/code]

    [code]
    bool TCPClient::sendCommand(QString command)
    {
    if (socket->state() != QAbstractSocket::ConnectedState)
    {
    qDebug() << "Can't send command : not connected !";
    return false;
    }
    socket->write(command.toStdString().data());
    timer->start(timeout);
    return true;
    }
    [/code]

    Here are the answers i get. I know HDCP feature is active for all input so i should get "1" for all input.

    [quote]
    Connecting to Matrix...

    Connected to : "192.168.5.112" on port 23

    HDCP for input "1" = "(c) Copyright 2011, Extron Electronics, DXP DVI-HDMI, V1.17, 60-875-01
    Thu, 10 Oct 2013 11:07:41"
    HDCP for input "2" = "1"
    HDCP for input "3" = "1"
    HDCP for input "4" = "3
    1"
    [/quote]

    Thanks a lot


Log in to reply
 

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