-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redundancy Check issues #97
Comments
What do you mean? Instead of if not struct.unpack('<H', get_crc(msg[:-2])) ==\
struct.unpack('<H', msg[-2:]):
raise CRCError('CRC validation failed.') you suggest: if struct.unpack('<H', get_crc(msg[:-2])) !=\
struct.unpack('<H', msg[-2:]):
raise CRCError('CRC validation failed.') |
Yes. The expression evaluates false because not of an integer is always false unless the integer is zero. And then if you are trying to compare a boolean false (evaluated from the not expression) with an integer that will also always be false. |
This would also be vaild
|
See operator precedence: https://docs.python.org/3/reference/expressions.html#operator-precedence
If However |
Function validate_crc does not evaluate the CRC bytes correctly. Incorrect use of not and ==
The text was updated successfully, but these errors were encountered: