bewest / decoding-carelink

python serial driver for mm comlink2 protocol
http://bewest.github.io/decoding-carelink
Other
71 stars 52 forks source link

Raise an error on CRC mismatch, rather than fail an assertion #170

Closed oskarpearson closed 8 years ago

oskarpearson commented 8 years ago

In some cases mmeowlink encounters CRC errors in data pages, even though the comms channel CRCs are correct. This triggers a decocare assertion error.

I'm changing this to a 'raise' error instead, so that it can be caught by openaps and retried.

loudnate commented 8 years ago

:+1:

oskarpearson commented 8 years ago

Please don't merge yet.

I've just managed to catch this in action, and am now getting this error with the patch. I'll need to do another fix here.

    raise DataTransferCorruptionError("CRC does not match page data (len:%s, expected:0x%x, actual:0x%x)" % (len(data), crc, computed))
TypeError: %x format: a number is required, not bytearray
oskarpearson commented 8 years ago

@bewest I opted for the simplest solution here. Should be ready to go once CI finishes.

Thanks!