IIO is a Linux subsystem intended to support reading sensors (or some kind of analog-to-digital convertors) including accelerometers, gyros, temperature/pressure/light sensors. It recently left staging (November 2011).
Reading sensor values via IIO can be done directly or in buffered mode. The later requires setup of a trigger.
Here is the script I use to test an Linux IIO driver I'm developping for the Si1143 ambient light/proximity sensor:
# load necessary modules modprobe industrialio modprobe iio-trig-sysfs modprobe kfifo_buf modprobe industrialio-triggered-buffer # reload driver rmmod si114x_new insmod si114x-new.ko # register new i2c device echo si114x 0x5a > /sys/devices/platform/omap_i2c.2/i2c-2/new_device # proximity reading (direct) cat /sys/bus/iio/devices/iio:device0/in_proximity0_raw # add new IIO sysfs trigger echo 123 > /sys/bus/iio/devices/iio_sysfs_trigger/add_trigger echo sysfstrig123 > /sys/bus/iio/devices/iio:device0/trigger/current_trigger # enable some channels echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_proximity0_en echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_intensity_en echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_temp_en # enable scan buffer echo 100 > /sys/bus/iio/devices/iio:device0/buffer/length echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable # trigger to read data echo 1 > /sys/bus/iio/devices/trigger0/trigger_now # read the captured data (buffered) cat /dev/iio\:device0 > /tmp/data.bin
posted at: 11:56 | path: /projects | permanent link