[gnea/grbl-Mega Issue#158] EEPROM Checksum is either last char or last char+1

未分类 bolang 4个月前 (10-15) 29次浏览

Issue #158 | 状态: 进行中 | 作者: drf5n | 创建时间: 2022-04-11


> grbl/eeprom.c: In function ‘memcpytoeepromwithchecksum’: grbl/eeprom.c:133:26: warning: ‘<<' in boolean context, did you mean '' ? [-Wint-in-bool-context] 133 | checksum = (checksum << 1) || (checksum >> 7); | ~~~~~~~~~~^~~~~ grbl/eeprom.c: In function ‘memcpyfromeepromwithchecksum’: grbl/eeprom.c:144:26: warning: ‘<<' in boolean context, did you mean '' ? [-Wint-in-bool-context] 144 | checksum = (checksum << 1) || (checksum >> 7); | ~~~~~~~~~~^~~~~

That looks like it was a typo — it squashes the checksum down to a single bit of information, when it looks like it intended to roll it right one bit, so the final checksum ends up either zero or one larger than the last character in the data:

https://github.com/gnea/grbl-Mega/blob/df87b36f48b90930714accf03b411b60d5d948e5/grbl/eeprom.c#L130-L149

Maybe it was supposed to be

checksum = (checksum << 1) | (checksum >> 7);

Originally posted by @drf5n in https://github.com/gnea/grbl-Mega/issues/157#issuecomment-1095029184


评论 (2)

#1 – drf5n 于 2022-04-11

See grblHAL’s checksum implementation in https://github.com/grblHAL/core/blob/3a84b58d301f04279268b4ef1045fd6bc0961be5/nuts_bolts.c#L267-L278


#2 – drf5n 于 2023-04-01

See also GRBL issue # https://github.com/grbl/grbl/issues/1249


原始Issue: https://github.com/gnea/grbl-Mega/issues/158

喜欢 (0)