Skip to content

Commit

Permalink
move motion_module auto power off from setup_udev_rules.sh to 99-real…
Browse files Browse the repository at this point in the history
…sense-libusb.rules

increase timeout to 200mSec based on a NUC test.
Modify rule to apply for accel sensor only.
  • Loading branch information
doronhi committed Oct 28, 2020
1 parent faeac08 commit a22be02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 3 additions & 0 deletions config/99-realsense-libusb.rules
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ KERNEL=="iio*", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b5c", MODE:="0777",
DRIVER=="hid_sensor*", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b5c", RUN+="/bin/sh -c ' chmod -R 0777 /sys/%p && chmod 0777 /dev/%k'"
KERNEL=="iio*", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b64", MODE:="0777", GROUP:="plugdev", RUN+="/bin/sh -c 'chmod -R 0777 /sys/%p'"
DRIVER=="hid_sensor*", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b64", RUN+="/bin/sh -c ' chmod -R 0777 /sys/%p && chmod 0777 /dev/%k'"

# For products with motion_module, if (kernels is 4.15 and up) and (device name is "accel_3d") wait, in another process, until (enable flag is set to 1 or 200 mSec passed) and then set it to 0.
KERNEL=="iio*", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0ad5|0afe|0aff|0b00|0b01|0b3a|0b3d|0b64", RUN+="/bin/sh -c '(major=`uname -r | cut -d \".\" -f1` && minor=`uname -r | cut -d \".\" -f2` && (([ $major -eq 4 ] && [ $minor -ge 15 ]) || [ $major -ge 5 ])) && (enamefile=/sys/%p/name && [ `cat $enamefile` = \"accel_3d\" ]) && enfile=/sys/%p/buffer/enable && echo \"COUNTER=0; while [ \$COUNTER -lt 20 ] && grep -q 0 $enfile; do sleep 0.01; COUNTER=\$((COUNTER+1)); done && echo 0 > $enfile\" | at now'"
7 changes: 0 additions & 7 deletions scripts/setup_udev_rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# --uninstall : remove permissions for realsense devices.

install=true
auto_power_off=false

for var in "$@"
do
Expand All @@ -18,10 +17,6 @@ done

if [ "$install" = true ]; then
echo "Setting-up permissions for RealSense devices"
if [ "$auto_power_off" = true ]; then
echo "Setting-up RealSense Device auto power off."
sudo apt install -q=3 at || (echo "Failed to install package 'at'. Remove flag --auto_power_off and run again." && exit 1)
fi
else
echo "Remove permissions for RealSense devices"
fi
Expand All @@ -39,8 +34,6 @@ if [ "$install" = true ]; then
echo -e "\e[0m"
fi
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
echo | sudo tee -a /etc/udev/rules.d/99-realsense-libusb.rules > /dev/null
echo "KERNEL==\"iio*\", ATTRS{idVendor}==\"8086\", ATTRS{idProduct}==\"0ad5|0afe|0aff|0b00|0b01|0b3a|0b3d|0b64\", RUN+=\"/bin/sh -c '[ \`uname -r | cut -d \\\".\\\" -f1\` -le 4 ] || enfile=/sys/%p/buffer/enable && echo \\\"COUNTER=0; while [ \\\$COUNTER -lt 10 ] && grep -q 0 \$enfile; do sleep 0.01; COUNTER=\\\$((COUNTER+1)); done && echo 0 > \$enfile\\\" | at now'\"" | sudo tee -a /etc/udev/rules.d/99-realsense-libusb.rules > /dev/null
else
sudo rm /etc/udev/rules.d/99-realsense-libusb.rules
fi
Expand Down

0 comments on commit a22be02

Please sign in to comment.