在刚启动的BeagleBone Black中,我执行:
me@beaglebone:~$ sudo -i
[sudo] password for me:
root@beaglebone:~# cd /sys/class/gpio/
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > unexport
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > unexport
...如您所见,第二次尝试有效。每隔尝试一次将引发错误。导出后取消导出不会引发错误,并且可以避免第二次错误。有道理吧?那么,也许当新启动时,默认情况下会导出该图钉吗?
然后,它应该能够在全新启动后取消导出该引脚:
me@beaglebone:~$ sudo -i
[sudo] password for me:
root@beaglebone:~# cd /sys/class/gpio
root@beaglebone:/sys/class/gpio# echo 60 > unexport
-bash: echo: write error: Invalid argument
root@beaglebone:/sys/class/gpio# echo 60 > unexport
-bash: echo: write error: Invalid argument
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > unexport
-bash: echo: write error: Invalid argument
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 60 > export
root@beaglebone:/sys/class/gpio# echo 60 > unexport
root@beaglebone:/sys/class/gpio#
...不! -Homey don't play that.
也许那个引脚处于某种特殊状态。在全新启动时尝试使用其他引脚:
root@beaglebone:/sys/class/gpio# echo 49 > export
-bash: echo: write error: Operation not permitted
root@beaglebone:/sys/class/gpio# echo 49 > export
root@beaglebone:/sys/class/gpio#
...相同的行为。
一个简单的解决方法是在启动时调用这些虚假导出中的一个,然后软件/脚本可以使用60而不会跳闸。但是理想情况下,最好能理解为什么会发生这种情况,甚至可以使它正常运行而不会产生麻烦。