Skip to content
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

Fixes #36 Command buffer overflow with SHT2x #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions SHTSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,19 @@ class SHT2xSensor : public SHTI2cSensor
// so we have to spit the command into two bytes and
// have to read from I2C two times with EXPECTED_DATA_SIZE / 2

// read T from SHT2x Sensor
// Upper byte is T for SHT2x Sensors
cmd[0] = mI2cCommand >> 8;
// Lower byte is RH for SHT2x Sensors
cmd[1] = mI2cCommand & 0xff;

// read T from SHT2x Sensor
if (!readFromI2c(mWire, mI2cAddress, cmd, mCmd_Size, data,
EXPECTED_DATA_SIZE / 2, mDuration)) {
DEBUG_SHT("SHT2x readFromI2c(T) false\n");
return false;
}

// read RH from SHT2x Sensor
if (!readFromI2c(mWire, mI2cAddress, &cmd[1], mCmd_Size, &data[3],
// Lower byte is RH for SHT2x Sensors
cmd[0] = mI2cCommand & 0xff;
if (!readFromI2c(mWire, mI2cAddress, cmd, mCmd_Size, &data[3],
EXPECTED_DATA_SIZE / 2, mDuration)) {
DEBUG_SHT("SHT2x readFromI2c(RH) false\n");
return false;
Expand Down