git clone https://gist.github.com/jadonk/8ece4ad83ac67e5215af6a3d686d0ae2
cd 8ece4ad83ac67e5215af6a3d686d0ae2
sudo ./thrash_motors.sh
sudo ./pwmcleaner.sh
Last active
October 10, 2019 19:31
-
-
Save jadonk/8ece4ad83ac67e5215af6a3d686d0ae2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /sys/class/pwm | |
set -x | |
set -e | |
FILES=$(ls -d pwm-*) | |
for file in $FILES; do | |
echo Found $file | |
PWM=$(echo $file | cut -d'-' -f 2) | |
PWMCHIP=pwmchip$(echo $PWM | cut -d':' -f 1) | |
CHANNEL=$(echo $PWM | cut -d':' -f 2) | |
echo Disabling $PWMCHIP channel $CHANNEL... | |
echo 0 > ${file}/enable | |
echo $CHANNEL > ${PWMCHIP}/unexport | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
set -e | |
while true; do | |
rc_test_motors -d 0.2 -m 1 & | |
RC=$! | |
sleep 1 | |
kill -15 \$RC | |
sleep 1 | |
done |
I was trying to use the above given procedure to solve my similar problem on BeagleBoneBlue but while running the script files I got the following errors:
In pwmcleaner.sh file the error was:
./pwmcleaner.sh: line 12: echo: write error: Invalid argument
and while trying to resolve this I changed echo 0 > ${file}/enable to echo 0 > ${file/enable}
and the output was:
./pwmcleaner.sh: line 12: pwm-0:0: Is a directory
And in thrash_motors.sh, the error was:
./thrash_motors.sh: line 8: kill: $RC: arguments must be process or job IDs
and to resolve this I changed kill -15 $RC to kill -15 $RC
and the output was:
./thrash_motors.sh: line 8: kill: (1668) - No such process
So I wanted to know whether I have done it right or not?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It was supposed to be RC=$! and it saves the process ID of the last invocation. This is done so we can kill the process after waiting a bit.