编辑:我想我几乎所有的东西都在工作。这只是我的第二个循环一直有索引失败。。。知道为什么我的通信循环失败了吗
我目前正在尝试获取HD180x optomoa投影仪的红外代码。这正变成一个非常困难的问题
我只需要打开电源,别的什么都不需要
我没有一个红外传感器直接捕捉代码,并且把它作为一个挑战,在没有红外传感器的情况下尝试去做
到目前为止,这是不可能的。我已经尝试了几种不同的方法,使用树莓Pi直接从远程获取IR代码,但没有成功
我的下一个想法是使用红外爆炸机,然后循环所有可能的红外通电代码
LIRC是唯一一款Pi-IR软件,它有很多遥控器的列表:http://lirc.sourceforge.net/remotes/
我想尝试做的是制作一个python脚本,从列表中获取所有文件,然后尝试所有文件。我们的目标就是打开投影仪,这样我就可以让它一直运行下去,如果它打开了,我就可以找出是哪个打开了
因此,我的伪代码如下所示:
我不确定如何从配置文件中获取“名称”字段和“代码”字段
另外,不知道如何通过python发送终端命令
有什么想法吗
我能够得到开始发送的代码,现在我只需要找出如何从conf文件中获取“IR代码”
我非常接近……我只需要能够执行“irsend list”“>;>;/home/pi/list.ist”,这样我就可以找到当前活动的远程设备的名称……我似乎不知道如何正确运行该命令。我想引号把它弄乱了
import os
import shutil
import subprocess
import time
# Using readline()
count = 0
#os.remove("list.list")
os.system("touch /home/pi/com.list")
os.system("touch /home/pi/list.list")
os.system("systemctl start lircd")
for filename in os.listdir('confs'):
currconf = "/home/pi/confs/" + filename
print "**********start*******"
print "1. ", filename
#print "2. ", currconf
#os.system("systemctl stop lircd")
#subprocess.call('systemctl stop lircd', shell=True)
shutil.move(currconf, "/etc/lirc/lircd.conf")
subprocess.call('systemctl reset-failed lircd', shell=True)
subprocess.call('systemctl restart lircd', shell=True)
time.sleep(1)
subprocess.call('systemctl status lircd | tail -3', shell=True)
# os.system("systemctl start lircd")
# irlist = ""
#print "3. ", irlist
os.remove("/home/pi/list.list")
os.remove("/home/pi/com.list")
os.system('irsend list \"\" \"\" >> /home/pi/list.list')
qbfile = open("/home/pi/list.list", "r")
for aline in qbfile:
values = aline.split()
print(values[0])
rname = values[0].strip('\n')
print "2. rname", rname
comlist = 'irsend list ' + rname + ' \"\" >> /home/pi/com.list'
print "3. comlist", comlist
os.system(comlist)
comfile = open("/home/pi/com.list", "r")
for coms in comfile:
comvalues = coms.split()
comand = comvalues[1]#.strip('\n')
cmd = "irsend SEND_ONCE " + rname + " " + comand
print "4. cmd ", cmd
time.sleep(.001)
os.system(cmd)
print "**********end*******"
我把一切都搞定了。。这是密码
相关问题 更多 >
编程相关推荐