你是如何发送数据的?您是在使用库还是发送原始字节?根据手册,您的数据命令应以转义序列开头,但还应指定数据长度:
// Each escape sequence starts with the ASCII character 27 (0x1B),
// the equivalent to the ESC key. The contents of < > are a byte or byte stream.
// - Cid is connection id (udp, tcp, etc)
// - Data Length is 4 ASCII char represents decimal value
// i.e. 1400 bytes would be '1' '4' '0' '0' (0x31 0x34 0x30 0x30).
// - Data size must match with specified length.
// Ignore all command or esc sequence in between data pay load.
<Esc>Z<Cid><Data Length xxxx 4 ascii char><data>
请注意有关数据大小的注释:“忽略数据有效负载之间的所有命令或 esc 序列”。
例如,GSCore.cpp 中的GSCore::writeData 函数如下所示:
// Including a trailing 0 that snprintf insists to write
uint8_t header[8];
// Prepare header: <esc> Z <cid> <ascii length>
snprintf((char*)header, sizeof(header), "\x1bZ%x%04d", cid, len);
// First, write the escape sequence up to the cid. After this, the
// module responds with <ESC>O or <ESC>F.
writeRaw(header, 3);
if (!readDataResponse()) {
if (GS_LOG_ERRORS && this->error)
this->error->println("Sending bulk data frame failed");
return false;
}
// Then, write the rest of the escape sequence (-1 to not write the
// trailing 0)
writeRaw(header + 3, sizeof(header) - 1 - 3);+
// And write the actual data
writeRaw(buf, len);
这很可能会起作用。或者,一个肮脏的黑客可能是在发送之前“转义转义字符”,即在发送之前用两个字符(0x27 0x27)替换每个0x27 - 但这只是一个疯狂的猜测,我假设你应该只查看手册。