stefan pushed a commit to branch master.
commit 7d17130db6659244e0c601a4573aadf845eeaba5
Author: Stefan Schmidt <[email protected]>
Date: Wed Apr 10 14:48:29 2013 +0100
eeze/sensor: Check if sens is valid the same way we do in other cases.
---
src/bin/eeze/eeze_sensor_test.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/bin/eeze/eeze_sensor_test.c b/src/bin/eeze/eeze_sensor_test.c
index 2fa7e6e..3e80020 100644
--- a/src/bin/eeze/eeze_sensor_test.c
+++ b/src/bin/eeze/eeze_sensor_test.c
@@ -147,13 +147,17 @@ main(void)
* values. Depending on the hardware this can take a long time. If you
don't have special
* requirements the cached values should be used. */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
- eeze_sensor_read(sens);
- if (!sens) printf("can't find an light sensor!\n");
- if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
- if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
- if (!eeze_sensor_timestamp_get(sens, ×tamp)) printf("fail get
timestamp\n");
- printf("Light output: accuracy %i, lux %f at time: %lli\n", acc, x,
timestamp);
- eeze_sensor_free(sens);
+ if (sens)
+ {
+ eeze_sensor_read(sens);
+ if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
+ if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get
accuracy\n");
+ if (!eeze_sensor_timestamp_get(sens, ×tamp)) printf("fail get
timestamp\n");
+ printf("Light output: accuracy %i, lux %f at time: %lli\n", acc, x,
timestamp);
+ eeze_sensor_free(sens);
+ }
+ else
+ printf("Could not find an light sensor!\n");
printf("=== Test async reads / events: ===\n");
/* Async read request for sensors. You have to register an event handler for
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter