[SOLVED] Sending "escape" character over TCP

Hi,

I am building an application which have to send string command over ethernet (TCP).
example of command : escE1HDCP
this is a command in string type with the character “escape” before.

i can have a string “E1HDCP” to be sent, but how can i send this “escape” character ?

thanks a lot.

i think esc is ascii 27 so you need to send:

“\27E1HDCP”

also be sure to use sendRaw instead of send since send adds a custom terminator to messages to be able to separate them, OF detects those separators and removes them but if you are sending to another software or library the terminator will break the message

Hello,

Thanks for the answer.

I tried it in oF and in another app built over Qt framework but i’m still unable to get the thing done.
tried also with the hex code 0x1B

Here is what i got :

in my app :

  
  
bool Matrix::getHdcpStatus(string input)  
{  
    string resp;  
    string esc = 0x1B;  
    resp = dxpClient->sendQuery(esc + "E" + input + "HDCP");  
    return resp.toInt();  
}  
  

sendQuery() method looks like this :

  
  
bool TCPClient::sendQuery(string command)  
{  
    socket->write(command.toStdString().data());  
    return true;  
}  
  
  

i would use an ofxTCPClient (assuming that the other side is a server)

  
  
ofxTCPClient client;  
  
string command="\27E"+input+"HDCP";  
client.sendRawBytes(command.c_str(),command.size());  
  

Hi,

Thank you for your answers
Everything works now.

Escape has the ascii code : 0x1B (hexa), 27 (decimal) or 033 (octal)

So the command “escE1HDCP” in string type is :

  
  
"\x1BE1HDCP\r"  
  

Note : don’t forget the return character (\r) at the end as suggested in the protocol.

Thanks again