bewest / decoding-carelink

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

[mmeowlink_temp_basal] Handle empty byte arrays on temp basal response #164

Closed oskarpearson closed 8 years ago

oskarpearson commented 8 years ago

In certain cases with mmeowlink, self.data is a blank bytearray as there is no radio data returned. Attempting to access the 0th element raises 'IndexError: bytearray index out of range' in this case.

This change adds a simple guard clause to avoid the exception. When the correct data is actually set in the data array on the second attempt, the code works as expected and the temporary basal report stores the correct data.

sulkaharo commented 8 years ago

LGTM, running in production now and the exception is gone, everything functioning as expected.