fileA.py
GPIO トリガーに基づいてラジオ スタジオの照明を制御するメイン ファイルがあります。私が懸念している部分は、次のように While True ループにあります。
While True:
#other triggers for other things unrelated
if GPIO.input(25) == GPIO.LOW and (state) = 'off':
blue()
studiostatus = "online"
#other triggers for other things unrelated
elif count > 7200:
dbo()
clockoff()
studiostatus = "offline"
次に、同じ Raspberry Pi で 2 つ目の Python ファイルfileB.py
を同時に実行します。
import SocketServer
from BaseHTTPServer import BaseHTTPRequestHandler
def some_function():
print "some_function got called"
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/doorbell':
some_function()
self.send_response(200)
httpd = SocketServer.TCPServer(("", 8080), MyHandler)
httpd.serve_forever()
studiostatus
ただし、これを変数 fromで継続的に更新してfileA.py
、行が次のようにfileB.py
なるようにしたいと思います
if self.path == '/doorbell' and studiostatus = "online":
action1()
elif self.path == '/doorbell' and studiostatus = "offline":
action2()
現在、これに取り組むための最善の方法で木のための木を見ることができないので、どんな助けも大歓迎です