|
|
@@ -19,6 +19,7 @@ def on_connect(client, userdata, flags, rc):
|
|
|
|
|
|
# The callback for when a PUBLISH message is received from the server.
|
|
|
def on_message(client, userdata, msg):
|
|
|
+ global p
|
|
|
print(msg.topic+" "+str(msg.payload))
|
|
|
if msg.topic == "video/cam2/preview":
|
|
|
try:
|
|
|
@@ -26,12 +27,17 @@ def on_message(client, userdata, msg):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return
|
|
|
- if run and p is None:
|
|
|
+ if run == 1 and p is None:
|
|
|
print("Starting")
|
|
|
- p = subprocess.Popen(["/home/curso/code/snowmix/camera1/play-cam2.sh"]
|
|
|
- if p is not None and not run:
|
|
|
+ p = subprocess.Popen(["/home/curso/code/snowmix/camera1/play-cam2.sh"])
|
|
|
+ if (p is not None and run == 0):
|
|
|
print("Stopping")
|
|
|
p.terminate()
|
|
|
+ sleep(0.1)
|
|
|
+ if p is not None:
|
|
|
+ p.kill()
|
|
|
+ sleep(0.1)
|
|
|
+ p = None
|
|
|
|
|
|
|
|
|
client = mqtt.Client()
|