climateguard / RadSens

Arduino library for radiation detector module RadSens to simplify integration into compatible platforms.
GNU General Public License v3.0
51 stars 17 forks source link

In i2c_read() check endTransmission() and requestFrom() to ensure data returned is valid #11

Closed bakerkj closed 2 years ago

bakerkj commented 2 years ago

I believe this change addresses issues like #10 and maaad/RadSens1v2/issues/3 where i2c communications issues were not detected and therefore erroneous values were returned to the caller.

1) As documented here Arduino Wire endTransmission() documentation endTransmission() returns 0 on success and other values on error.

In the case of an error i2c_read() now returns false so callers do not try to interpret invalid data.

2) As documented here Arduino Wire requestFrom() documentation requestFrom() returns the number of bytes returned from the peripheral.

In the case of fewer bytes returned than the number requested in i2c_read() return false to callers so they do not try to interpret invalid data.

krbaker commented 2 years ago

+1 This is helping me solve some data inconsistency issues, thanks

octopolyr commented 2 years ago

Hi! Thanks for feedback! We've recieved your pull request, I'll take a time to talk with our CTO to approve it @bakerkj @krbaker

bakerkj commented 2 years ago

@climateguard / @octopolyr is it worth tagging a new release # with this fix?

octopolyr commented 2 years ago

@bakerkj We're working on a couple of features, the update will happen within a week. Please accept our apologies for the inconvenience

bakerkj commented 1 year ago

Hi @octopolyr , I was curious how the tag creation was going? Thanks!

bakerkj commented 1 year ago

@octopolyr / @climateguard I was just checking in. Would it be possible to issue a new release?

Thanks!