Skip to content

Commit d728ed1

Browse files
authored
Fix for Comm5 MA-4200 hardware (#4332)
Sometimes a CRC error can occur due to problem with signed char calculation.
1 parent b099401 commit d728ed1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hardware/Comm5Serial.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ void Comm5Serial::ParseData(const unsigned char* data, const size_t len)
262262
case STFRAME_CRC2:
263263
frame.push_back(data[i]);
264264
frameCRC = crc16_update(frameCRC, 0);
265-
readCRC = (uint16_t)(frame.at(frame.size() - 2) << 8) | (frame.at(frame.size() - 1) & 0xFF);
265+
readCRC = (static_cast<uint16_t>(frame.at(frame.size() - 2)) << 8) | frame.at(frame.size() - 1);
266266
if (frameCRC == readCRC)
267267
parseFrame(frame);
268+
else
269+
Log(LOG_ERROR, "Frame CRC error");
268270
currentState = STSTART_OCTET1;
269271
frame.clear();
270272
break;

0 commit comments

Comments
 (0)