int parseRecvData(int first, int last, int steps, int data_byte) { recv_data.clear(); char remain_data[3]; int remain_byte = 0; enum { LineDataSize = 64 }; int n; char buffer[pImpl::LineSize]; while ((n = readLine(buffer, LineSize, FirstTimeout)) > 0) { if (sumcheck(buffer, n-1, buffer[n-1]) < 0) { // !!! エラーメッセージの更新 fprintf(stderr, "error: %s\n", buffer); return -1; } // 前回残りのデータを処理 int index = 0; if (remain_byte > 0) { int copy_byte = data_byte - remain_byte; memmove(&remain_data[remain_byte], buffer, copy_byte); recv_data.push_back(decode(remain_data, data_byte)); remain_byte = 0; index = copy_byte; } // 受信データの距離変換 for (; index + data_byte <= n-1; index += data_byte) { recv_data.push_back(decode(&buffer[index], data_byte)); } // 余ったデータを記録 if (((n-1) - index)> 0) { int copy_byte = n-1 - index; memmove(&remain_data[remain_byte], &buffer[index], copy_byte); remain_byte += copy_byte; } } fprintf(stderr, "size: %d\n", recv_data.size()); for (std::vector<long>::iterator it = recv_data.begin(); it != recv_data.end(); ++it) { fprintf(stderr, "%d, ", *it); } fprintf(stderr, "\n"); return -1; }
自室の二次元データ。カラーボックスとか