|
|
@ -20,7 +20,6 @@ bool HMP110::readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, in |
|
|
|
bool ret = m_modbusBlockHost->readReg03(slaveAddr, regAddr, regVal, overtimems); |
|
|
|
// ZLOGI(TAG, "=============== END%d", ret);
|
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
bool HMP110::readReg03Muti(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, int regNum, int overtimems) { //
|
|
|
@ -72,19 +71,22 @@ bool HMP110::read_reg(int32_t add, uint16_t* val, size_t len) { |
|
|
|
} |
|
|
|
|
|
|
|
bool HMP110::read_sensor_data(hmp110_sensordata_t* sensordata) { |
|
|
|
uint16_t buf[7]; |
|
|
|
bool suc = readReg03Muti(m_id, 0x0100, buf, 7, 300); |
|
|
|
static_assert(sizeof(hmp110_sensordata_t) == 14 * 2, "sizeof(hmp110_sensordata_t) != 14*2"); |
|
|
|
uint16_t buf[14]; |
|
|
|
bool suc = readReg03Muti(m_id, 0x0100, buf, 14, 300); |
|
|
|
if (!suc) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
sensordata->rh = buf[0]; |
|
|
|
sensordata->temp = buf[1]; |
|
|
|
sensordata->df_ptemp = buf[2]; |
|
|
|
sensordata->ah = buf[3]; |
|
|
|
sensordata->mr = buf[4]; |
|
|
|
sensordata->wet_bulb_temp = buf[5]; |
|
|
|
sensordata->enthalpy = buf[6]; |
|
|
|
memset(sensordata, 0, sizeof(hmp110_sensordata_t)); |
|
|
|
memcpy(sensordata, buf, sizeof(hmp110_sensordata_t)); |
|
|
|
// sensordata->rh = buf[0];
|
|
|
|
// sensordata->temp = buf[1];
|
|
|
|
// sensordata->df_ptemp = buf[2];
|
|
|
|
// sensordata->ah = buf[3];
|
|
|
|
// sensordata->mr = buf[4];
|
|
|
|
// sensordata->wet_bulb_temp = buf[5];
|
|
|
|
// sensordata->enthalpy = buf[6];
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|