From d74ac654a94c794c1c456576c54f96595693d7d9 Mon Sep 17 00:00:00 2001 From: Diego Herranz Date: Sun, 16 May 2021 12:32:54 +0100 Subject: [PATCH] hdc1008_demo: set intial measurement mode No mode was set before the first read by the app. The first time the app was run, it worked properly, reading temperature and humidity on the first read(). But subsequent reads returned humidity only since that was last mode set up. Also, the ioctl read was returning invalid results. --- examples/hdc1008_demo/hdc1008_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/hdc1008_demo/hdc1008_main.c b/examples/hdc1008_demo/hdc1008_main.c index 016dca766..f34daf32e 100644 --- a/examples/hdc1008_demo/hdc1008_main.c +++ b/examples/hdc1008_demo/hdc1008_main.c @@ -69,6 +69,14 @@ int main(int argc, FAR char *argv[]) /* Read both t and rh */ + ret = ioctl(fd, SNIOC_SET_OPERATIONAL_MODE, HDC1008_MEAS_T_AND_RH); + if (ret < 0) + { + printf("Failed to set temperature and humidity measurement mode: %d\n", + errno); + goto out; + } + ret = read(fd, buf, sizeof(buf)); if (ret < 0) {