char[]の内容の解析に問題があります。これにはバイトが含まれており、ASCII針としてフォーマットできます。ただし、最後の2バイトはCRCです。したがって、16進数から文字列までの配列の最後の2つのエントリを除くすべてを解釈します。
std::ostringstream payload;
std::ostringstream crc;
payload << std::hex;
crc << std::hex;
// last two bytes are CRC
for (int i = 0; i < this->d_packetlen - 2; i++)
{
payload << static_cast<unsigned>(this->d_packet[i]);
for (int j = i; j < this->d_packetlen; i++)
{
crc << static_cast<unsigned>(this->d_packet[j]);
}
}
std::string payload_result = payload.str();
std::string crc_result = crc.str();
fprintf(d_new_fp, "%s, %s, %d, %d\n", payload_result.c_str(),
crc_result.c_str(), this->d_lqi, this->d_lqi_sample_count);
これは機能しません、そしてそれがなぜであるかわかりませんか?未歌の文字をASCIIにキャストする簡単な方法はありますか?
最高、マリウス