You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/05/16 14:31:38 UTC

[incubator-nuttx-apps] branch master updated: hdc1008_demo: set intial measurement mode

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new d74ac65  hdc1008_demo: set intial measurement mode
d74ac65 is described below

commit d74ac654a94c794c1c456576c54f96595693d7d9
Author: Diego Herranz <di...@diegoherranz.com>
AuthorDate: Sun May 16 12:32:54 2021 +0100

    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 016dca7..f34daf3 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)
     {