Ubuntu: how to use iio on surface pro to access sensor data in Ubuntu 13.04



Question:

I have Ubuntu 13.04 running on a Surface Pro.

One of the usb device (ID 045e:0794) has registered a number of hid sensor devices:

  • HID-SENSOR-200041.0: Light: Ambient Light
  • HID-SENSOR-200062.0: Mechanical: Boolean Switch Array
  • HID-SENSOR-200073.0: Motion: Accelerometer 3D
  • HID-SENSOR-200076.0: Motion: Gyrometer 3D
  • HID-SENSOR-200083.0: Orientation: Compass 3D
  • HID-SENSOR-200086.0: Orientation: Inclinometer 3D
  • HID-SENSOR-20008a.0: Orientation: Device Orientation

When loading hid-sensor-als a iio device is available in /sys/bus/iio/devices/iio:device0 and also /dev/iio:device0 is created.

New iio devices are also created when loading hid-sensor-accel-3d and hid-sensor-gyro-3d.

Now my question is how can i get and read out data from these sensors?


Solution:1

I went through the same exercise for a Yoga 2 Pro, under Fedora 20. The problem is that the sensor hub sensor drivers don't expose a raw interface, so you have to use the buffered interface, which is not easy to set up. To add to that, the drivers may not correctly initalize some sensors so that they hang.

There is a program called generic_buffer alluded to in the presentation mentioned above. However, there are many problems with that program, at least the most readily available versions.

I have a fixed up version of generic_buffer in https://github.com/pfps/yoga-laptop under sensors. I also have a program that monitors the accelerometer and rotates the screen accordingly. Feel free to use and abuse them, and, if you can, please improve them.


Solution:2

quick google, I found this: https://archive.fosdem.org/2012/schedule/event/693/127_iio-a-new-subsystem.pdf

pages 22-24: Userspace API, has some shell commands accessing the device files in /sys.

In the linux kernel tree, "Documentation/ABI/testing/sysfs-bus-iio" has some info as well.

I'm not an expert, but maybe that could help get you some of the way?


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »