Return value of HRESULT hr in Console application of HDC1010 humidity sensor

Hello all,

I’m writing a console application to retrieve the temperature and humidity values from HDC1010 sensor.

Code snippet:

PROPVARIANT var = {};
HRESULT hr = ppReport->GetSensorValue(SENSOR_DATA_TYPE_TEMPERATURE_CELSIUS, &var);
if (SUCCEEDED(hr))
{
float temp = var.fltVal;
std::cout << "Temperature in celsius: " << temp;
std::cout << “\n”;
}

    PropVariantClear(&var);

hr = ppReport->GetSensorValue(SENSOR_DATA_TYPE_RELATIVE_HUMIDITY_PERCENT, &var);
if (SUCCEEDED(hr))
{
float humidity = var.fltVal;
std::cout << "Relative Humidity: " << humidity;
std::cout << “\n”;
}

    PropVariantClear(&var);

Here, return value of hr is 0 on SUCCESS and -ve value on FAILURE. But I obtain 0x80070490 due to which GetSensorValue() fails.

While referring to below links, the error code 0x80070490 is not even listed:

  1. https://docs.microsoft.com/en-us/windows/win32/learnwin32/error-handling-in-com
  2. https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/705fb797-2175-4a90-b5a3-3918024b10b8

Can you please reach out to this?

Thanks,
Subashini.

On 2022-01-27 2:04 a.m., SUBASHINI wrote:

Here, return value of hr is 0 on SUCCESS and -ve value on FAILURE.
But I obtain 0x80070490 due to which GetSensorValue() fails.

While referring to below links, the error code 0x80070490 is not
even listed:
If you haven’t seen it before, Microsoft’s error lookup tool is
extremely useful to help understand error codes:

https://www.microsoft.com/en-us/download/details.aspx?id=100432

-Nathan

Usually, an 8007xxxx error code means someone has taken a Win32 error and passed it to HRESULT_FROM_WIN32 to convert it to an HRESULT. So, you look up the low-order 16 bits. 0x490 is ERROR_NOT_FOUND.