hadess / iio-sensor-proxy

IIO accelerometer sensor to input device proxy
196 stars 63 forks source link

Accelerometer: Get scale from sensors with IIO_SHARED_BY_ALL mask. #284

Closed danielstuart14 closed 4 years ago

danielstuart14 commented 5 years ago

Properties with IIO_SHARED_BY_ALL mask don't have the sensor type prefix before the file identifier, this caused some devices to not use the scale from sysfs.

As so, it is fixed by searching through sysfs for both properties: scale and in_accel_scale.

This commit is based on f14d26d1 [accel-location: add helper functions for ACCEL_LOCATION udev property].

danielstuart14 commented 5 years ago

@hadess if you want, I can merge both accel-location and accel-scale into one single file, with both functions. I thought it would be cleaner, but I decided to create a separated file for the new function as the previous one isn't of my authorship.

hadess commented 5 years ago

Ideally, the information about whether the scale is shared for one or all channels should be available in the channel_info, but it doesn't look like it's exported from the kernel.

A single file is fine for those, but you shouldn't modify the input accel driver, which doesn't use IIO.

hadess commented 5 years ago

It would also be useful if you could mention in the commit message which device (as in computer/laptop) you used to test this, and whether it has one or multiple accelerometers (and which driver that would use, if it's relevant).

danielstuart14 commented 5 years ago

Ok! I'll do the changes and make a propose

danielstuart14 commented 5 years ago

@hadess should be gtg, I also added the requested info to the commit message.

danielstuart14 commented 5 years ago

@hadess , I updated the commit, now it's matching the coding style. Also, is my previous statement true? Maybe I misunderstood the buffer functions, but, after looking through it, it doesn't seem to use the device scale.