java 关闭中断_Raspberry pi使用中断方法关闭(关闭时出现垃圾代码)

我正在使用一个瞬间按钮来使用中断方法关闭覆盆子pi,同样的代码是:

#Import the modules to send commands to the system and access GPIO pins

from subprocess import call

import RPi.GPIO as gpio

# Define a function to keep script running

def loop():

raw_input()

# Define a function to run when an interrupt is called

def shutdown(pin):

call('halt', shell=False)

gpio.setmode(gpio.BOARD) # Set pin numbering to board numbering

gpio.setup(7, gpio.IN) # Set up pin 7 as an input

gpio.add_event_detect(7, gpio.RISING, callback=shutdown, bouncetime=200)

#Set up an interrupt to look for button presses

loop() # Run the loop function to keep script running

然后我将此脚本设置为在启动时自动运行,方法是将此行python /home/pi/PiSupply/softshut.py添加到/etc/rc.local .

关闭发生但在关闭时,屏幕上会出现此错误 .

map : vt01=>fb0

oops : terminated

在进行一些搜索时发现这可能是因为fbi.But因为它没有导致关闭任何问题我只是想将这个垃圾重定向到日志文件而不是出现在屏幕上 .

为此,我试过:

os.system('pkill fbi')

os.system('pkill fbi >/dev/null 2>/dev/null')

exec 2> /tmp/rc.local.log

exec 1>&2

但没有任何效果 . 任何人都可以解释发生了什么以及如何阻止垃圾出现在屏幕上或者可能完全消除错误 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值