Looking for clarification on sysfs IIO devices, do _raw devices require both _offset and _scale?
In reference to:
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio
I have Temperature, Pressure, and Humidity IIO sensors. IIO _raw devices look like this on sysfs:
this happens to be a SI7020 type device with 2 sensors
/sys/bus/iio/devices/iio:device0/in_humidityrelative_offset /sys/bus/iio/devices/iio:device0/in_humidityrelative_raw /sys/bus/iio/devices/iio:device0/in_humidityrelative_scale /sys/bus/iio/devices/iio:device0/in_temp_offset /sys/bus/iio/devices/iio:device0/in_temp_raw /sys/bus/iio/devices/iio:device0/in_temp_scale
Other IIO _input devices look like this on sysfs:
this happens to be a DPS310 device with 2 sensors
/sys/bus/iio/devices/iio:device1/in_temp_input /sys/bus/iio/devices/iio:device1/in_pressure_input
As I read it if the IIO device was an _input type on sysfs, just read it (and possibly scale it for units).
But if the IIO device was a _raw type on sysfs my understanding is that it must be accompanied by a _offset and a _scale for at least temperature, pressure, humidity, voltage, and current sensors.
Is that correct?
Further for any IIO device that is a _raw type on sysfs is it required to be accompanied by a _offset and a _scale as well?
Thank you!
Signature · 1 line
Bruce
Quoted 21 lines · Bruce Mitchell
In reference to:
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iioI have Temperature, Pressure, and Humidity IIO sensors. IIO
_rawdevices look like this on sysfs:
this happens to be a SI7020 type device with 2 sensors /sys/bus/iio/devices/iio:device0/in_humidityrelative_offset /sys/bus/iio/devices/iio:device0/in_humidityrelative_raw /sys/bus/iio/devices/iio:device0/in_humidityrelative_scale /sys/bus/iio/devices/iio:device0/in_temp_offset /sys/bus/iio/devices/iio:device0/in_temp_raw /sys/bus/iio/devices/iio:device0/in_temp_scaleOther IIO
_inputdevices look like this on sysfs:
this happens to be a DPS310 device with 2 sensors /sys/bus/iio/devices/iio:device1/in_temp_input /sys/bus/iio/devices/iio:device1/in_pressure_inputAs I read it if the IIO device was an
_inputtype on sysfs, just read it (and possibly scale it for units).
Quoted 8 lines
But if the IIO device was a
_rawtype on sysfs my understanding is that it must be accompanied by a_offsetand a_scalefor at least temperature, pressure, humidity, voltage, and current sensors.
Is that correct?Further for any IIO device that is a
_rawtype on sysfs is it required to be accompanied by a_offsetand a_scaleas well?
Hi,
That sounds about right.
The _input name is historically and comes from hwmon framework. It means that the data has been processed by the kernel driver and converted to the right SI units for the channel type. This is usually used for sensor that have a non-linear transfer function. raw on the other hand means the data is just as it is reported by the hardware. The reason for this is that conversion to SI units is often not lossless, since we have finite precision. So it is up to the application to decide whether it wants to work on the raw data or how it wants to round the converted data.
input attributes never have scale and offset since they are already in the right unit. For raw scale and offset are optional. If scale does not exist assume it is 1, if offset does not exist assume it is 0. You'll rarely see a device with raw attributes without scale, but there are quite a few without offset.
- Lars
Quoted 33 lines · Lars-Peter Clausen
Quoted 21 lines · Bruce Mitchell
In reference to:
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iioI have Temperature, Pressure, and Humidity IIO sensors. IIO
_rawdevices look like this on sysfs:
this happens to be a SI7020 type device with 2 sensors /sys/bus/iio/devices/iio:device0/in_humidityrelative_offset /sys/bus/iio/devices/iio:device0/in_humidityrelative_raw /sys/bus/iio/devices/iio:device0/in_humidityrelative_scale /sys/bus/iio/devices/iio:device0/in_temp_offset /sys/bus/iio/devices/iio:device0/in_temp_raw /sys/bus/iio/devices/iio:device0/in_temp_scaleOther IIO
_inputdevices look like this on sysfs:
this happens to be a DPS310 device with 2 sensors /sys/bus/iio/devices/iio:device1/in_temp_input /sys/bus/iio/devices/iio:device1/in_pressure_inputAs I read it if the IIO device was an
_inputtype on sysfs, just read it (and possibly scale it for units).Quoted 8 lines
But if the IIO device was a
_rawtype on sysfs my understanding is that it must be accompanied by a_offsetand a_scalefor at least temperature, pressure, humidity, voltage, and current sensors.
Is that correct?Further for any IIO device that is a
_rawtype on sysfs is it required to be accompanied by a_offsetand a_scaleas well?Hi,
Quoted 9 lines
That sounds about right.
The
_inputname is historically and comes from hwmon framework. It means that the data has been processed by the kernel driver and converted to the right SI units for the channel type. This is usually used for sensor that have a non-linear transfer function.rawon the other hand means the data is just as it is reported by the hardware. The reason for this is that conversion to SI units is often not lossless, since we have finite precision. So it is up to the application to decide whether it wants to work on the raw data or how it wants to round the converted data.
inputattributes never have scale and offset since they are already in the right unit. For raw scale and offset are optional. If scale does not exist assume it is 1, if offset does not exist assume it is 0. You'll rarely see a device with raw attributes without scale, but there are quite a few without offset.- Lars
Thank you Lars!
Signature · 1 line
Bruce