浏览代码

fix CRC position in frame

Juraj Ďuďák 2 年之前
父节点
当前提交
3c9f3de2a6
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/dataframe.cpp

+ 3 - 2
src/dataframe.cpp

@@ -174,8 +174,9 @@ bool DataFrame::AddFloat(float f)
 uint8_t DataFrame::Commit(void)
 {
 	// compute _length
-	_frame[1] = _length;
-	_frame[_length--] = crc8(0, _length-2, _frame);
+	_length++;
+	_frame[1] = _length - 2;
+	_frame[_length - 1] = crc8(0, _length-1, _frame);
 	// length of payload: from byte 2 to CRC byte (the last)
 	return _length;