Skip to content

Commit

Permalink
Changing return type of 'requestFrom' from uint8_t to size_t allows t…
Browse files Browse the repository at this point in the history
…he function to return the correct amount of bytes read (since internally it's already a size_t which is downcast to a uint8_t upon returning it. (arduino#97)
  • Loading branch information
aentinger authored Dec 10, 2020
1 parent 4ee5aae commit b97a5db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ uint8_t arduino::MbedI2C::endTransmission(void) {
return endTransmission(true);
}

uint8_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len, bool stopBit) {
size_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len, bool stopBit) {
char buf[256];
int ret = master->read(address << 1, buf, len, !stopBit);
if (ret != 0) {
Expand All @@ -84,7 +84,7 @@ uint8_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len, bool stopBit)
return len;
}

uint8_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len) {
size_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len) {
return requestFrom(address, len, true);
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/Wire/Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class MbedI2C : public HardwareI2C
virtual uint8_t endTransmission(bool stopBit);
virtual uint8_t endTransmission(void);

virtual uint8_t requestFrom(uint8_t address, size_t len, bool stopBit);
virtual uint8_t requestFrom(uint8_t address, size_t len);
virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit);
virtual size_t requestFrom(uint8_t address, size_t len);

virtual void onReceive(void(*)(int));
virtual void onRequest(void(*)(void));
Expand Down

0 comments on commit b97a5db

Please sign in to comment.