aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2010-03-05 14:52:24 -0800
committerDavid 'Digit' Turner <digit@google.com>2010-03-05 14:52:24 -0800
commite1de67d34a5a896a936307a67f1308a993ed2013 (patch)
treed939a7b1779fe25192f98335ae160f07a5f8446a /emulator
parent91ed8175993fb6eca29e5281bf3f7f5b7a3b3ded (diff)
downloadsdk-e1de67d34a5a896a936307a67f1308a993ed2013.zip
sdk-e1de67d34a5a896a936307a67f1308a993ed2013.tar.gz
sdk-e1de67d34a5a896a936307a67f1308a993ed2013.tar.bz2
Fix sensor emulation.
This gets rid of a bug where the control fd would be closed when the data channel is opened, making the later activation of sensors impossible. Also add more debugging messages.
Diffstat (limited to 'emulator')
-rw-r--r--emulator/sensors/sensors_qemu.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/emulator/sensors/sensors_qemu.c b/emulator/sensors/sensors_qemu.c
index 47a9d43..ae5e630 100644
--- a/emulator/sensors/sensors_qemu.c
+++ b/emulator/sensors/sensors_qemu.c
@@ -135,7 +135,7 @@ control__open_data_source(struct sensors_control_device_t *dev)
}
D("%s: fd=%d", __FUNCTION__, ctl->fd);
handle = native_handle_create(1, 0);
- handle->data[0] = ctl->fd;
+ handle->data[0] = dup(ctl->fd);
return handle;
}
@@ -149,8 +149,8 @@ control__activate(struct sensors_control_device_t *dev,
char command[128];
int ret;
- D("%s: handle=%s (%d) enabled=%d", __FUNCTION__,
- _sensorIdToName(handle), handle, enabled);
+ D("%s: handle=%s (%d) fd=%d enabled=%d", __FUNCTION__,
+ _sensorIdToName(handle), handle, ctl->fd, enabled);
if (!ID_CHECK(handle)) {
E("%s: bad handle ID", __FUNCTION__);
@@ -175,9 +175,10 @@ control__activate(struct sensors_control_device_t *dev,
}
ret = qemud_channel_send(ctl->fd, command, -1);
- if (ret < 0)
+ if (ret < 0) {
+ E("%s: when sending command errno=%d: %s", __FUNCTION__, errno, strerror(errno));
return -1;
-
+ }
ctl->active_sensors = new_sensors;
return 0;
@@ -263,6 +264,7 @@ data__data_open(struct sensors_data_device_t *dev, native_handle_t* handle)
data->timeOffset = 0;
data->events_fd = dup(handle->data[0]);
+ D("%s: dev=%p fd=%d (was %d)", __FUNCTION__, dev, data->events_fd, handle->data[0]);
native_handle_close(handle);
native_handle_delete(handle);
return 0;
@@ -330,7 +332,7 @@ data__poll(struct sensors_data_device_t *dev, sensors_data_t* values)
int64_t event_time;
if (len < 0) {
- E("%s: len=%d", __FUNCTION__, len);
+ E("%s: len=%d, errno=%d: %s", __FUNCTION__, len, errno, strerror(errno));
return -errno;
}