summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-07-15 18:29:03 -0700
committerMathias Agopian <mathias@google.com>2010-07-19 14:14:04 -0700
commitcdefccdba52337df41f577d9ebfcfd67c05708cf (patch)
tree03129c5aa6925aea8353664d8c196227f69bfd03 /tests
parentb1e212e7b6fce2bc5c743b05853129e19760d7a4 (diff)
downloadhardware_libhardware-cdefccdba52337df41f577d9ebfcfd67c05708cf.zip
hardware_libhardware-cdefccdba52337df41f577d9ebfcfd67c05708cf.tar.gz
hardware_libhardware-cdefccdba52337df41f577d9ebfcfd67c05708cf.tar.bz2
new sensor_event_t structure for the new HAL that can handle bigger payloads
Change-Id: I8f21e457c308eea9cb1f73b49b1fed36627ec55e
Diffstat (limited to 'tests')
-rw-r--r--tests/nusensors/nusensors.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/nusensors/nusensors.cpp b/tests/nusensors/nusensors.cpp
index 215c972..5c6f332 100644
--- a/tests/nusensors/nusensors.cpp
+++ b/tests/nusensors/nusensors.cpp
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
list[i].power);
}
- sensors_data_t buffer[16];
+ sensors_event_t buffer[16];
err = sensors_open(&module->common, &device);
if (err != 0) {
@@ -100,12 +100,19 @@ int main(int argc, char** argv)
printf("read %d events:\n", n);
for (int i=0 ; i<n ; i++) {
- const sensors_data_t& data = buffer[i];
+ const sensors_event_t& data = buffer[i];
+
+ if (data.version != sizeof(sensors_event_t)) {
+ printf("incorrect event version (version=%d, expected=%d",
+ data.version, sizeof(sensors_event_t));
+ break;
+ }
+
switch(data.sensor) {
case SENSOR_TYPE_ACCELEROMETER:
printf("sensor=%s, time=%lld, value=<%5.1f,%5.1f,%5.1f>\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.acceleration.x,
data.acceleration.y,
data.acceleration.z);
@@ -113,7 +120,7 @@ int main(int argc, char** argv)
case SENSOR_TYPE_MAGNETIC_FIELD:
printf("sensor=%s, time=%lld, value=<%5.1f,%5.1f,%5.1f>\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.magnetic.x,
data.magnetic.y,
data.magnetic.z);
@@ -121,7 +128,7 @@ int main(int argc, char** argv)
case SENSOR_TYPE_ORIENTATION:
printf("sensor=%s, time=%lld, value=<%5.1f,%5.1f,%5.1f>\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.orientation.azimuth,
data.orientation.pitch,
data.orientation.roll);
@@ -129,25 +136,25 @@ int main(int argc, char** argv)
case SENSOR_TYPE_PROXIMITY:
printf("sensor=%s, time=%lld, value=%f\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.distance);
break;
case SENSOR_TYPE_TEMPERATURE:
printf("sensor=%s, time=%lld, value=%f\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.temperature);
break;
case SENSOR_TYPE_LIGHT:
printf("sensor=%s, time=%lld, value=%f\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.light);
break;
default:
printf("sensor=%s, time=%lld, value=<%f,%f,%f>\n",
getSensorName(data.sensor),
- data.time,
+ data.timestamp,
data.acceleration.x,
data.acceleration.y,
data.acceleration.z);