Browse Source

fix CRC position in frame

Juraj Ďuďák 2 years ago
parent
commit
3c9f3de2a6
1 changed files with 3 additions and 2 deletions
  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;