[SOLVED] sending special character (escape) over TCP
I am building an application to control hardware.
The device waits for a string command over ethernet (TCP).
example of command : escE1HDCP
this is a command in string type with the character "escape" before.
some others are plain string.
i can have a string "E1HDCP" to be sent, but how can i send this "escape" character ?
I use QString command type. Commands without this special character works without any issue.
here is what i have so far :
@bool Matrix::getHdcpStatus(QString input)
resp = dxpClient->sendQuery("\27E" + input + "HDCP");
thanks a lot.
C++ string literals can contains escapes like "\nnn", where nnn is octal, or "\xnn", where nn is hexadecimal. Your string matches neither of these. The Escape character (decimal 27) is either "\033" or "\x1B".
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 :
Note : don't forget the return character (\r) at the end as suggested in the protocol.