imu-setup: Check status before configuring
Configuration is not possible while buffer mode is ongoing. The previous code was making sure that it was disabled but was always enabling it once done, even if it was not enabled before. But if only the sampling frequency has been set, it could happen that enabling was not possible. For example, if no channel was selected. Leading to error messages in the logs. BugzID: 62694
This commit is contained in:
parent
99f672de40
commit
c628a3f981
|
|
@ -2,14 +2,25 @@
|
||||||
ACC_SYSFS_PATH="/sys/bus/iio/devices/iio:device0"
|
ACC_SYSFS_PATH="/sys/bus/iio/devices/iio:device0"
|
||||||
GYRO_SYSFS_PATH="/sys/bus/iio/devices/iio:device1"
|
GYRO_SYSFS_PATH="/sys/bus/iio/devices/iio:device1"
|
||||||
|
|
||||||
if [ -f "$ACC_SYSFS_PATH/buffer" ]; then
|
if [ -d "$ACC_SYSFS_PATH/buffer" ]; then
|
||||||
echo 0 > $ACC_SYSFS_PATH/buffer/enable
|
buffer_enable=$(cat "$ACC_SYSFS_PATH/buffer/enable")
|
||||||
|
if [ "$buffer_enable" = "1" ]; then
|
||||||
|
echo 0 > "$ACC_SYSFS_PATH/buffer/enable"
|
||||||
|
fi
|
||||||
echo $ACC_SAMPLING_FREQUENCY > $ACC_SYSFS_PATH/sampling_frequency
|
echo $ACC_SAMPLING_FREQUENCY > $ACC_SYSFS_PATH/sampling_frequency
|
||||||
echo 1 > $ACC_SYSFS_PATH/buffer/enable
|
if [ "$buffer_enable" = "1" ]; then
|
||||||
|
echo 1 > $ACC_SYSFS_PATH/buffer/enable
|
||||||
|
fi
|
||||||
|
|
||||||
echo 0 > $GYRO_SYSFS_PATH/buffer/enable
|
|
||||||
|
buffer_enable=$(cat $GYRO_SYSFS_PATH/buffer/enable)
|
||||||
|
if [ "$buffer_enable" = "1" ]; then
|
||||||
|
echo 0 > $GYRO_SYSFS_PATH/buffer/enable
|
||||||
|
fi
|
||||||
echo $GYRO_SAMPLING_FREQUENCY > $GYRO_SYSFS_PATH/sampling_frequency
|
echo $GYRO_SAMPLING_FREQUENCY > $GYRO_SYSFS_PATH/sampling_frequency
|
||||||
echo 1 > $GYRO_SYSFS_PATH/buffer/enable
|
if [ "$buffer_enable" = "1" ]; then
|
||||||
|
echo 1 > $GYRO_SYSFS_PATH/buffer/enable
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
imu-poll &
|
imu-poll &
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue