commit 91efb6d8912a7b00169c8c48d8b065fa22e1e593
parent d4df262fb42e2b4715ec777f012fdcedf4b6aca5
Author: rob <rob@tarina.org>
Date: Tue, 10 Jan 2023 18:42:50 +0200
ye
Diffstat:
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/tarinactrl.py b/tarinactrl.py
@@ -32,16 +32,30 @@ rectime=None
def sendtocamera(host, port, data):
print("Sending to "+host+" on port "+str(port)+" DATA:"+data)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- while True:
- try:
+ try:
+ while True:
+ s.connect((host, port))
+ s.send(str.encode(data))
+ break
+ except:
+ ('trying again...')
+ print("Sent to server..")
+ s.close()
+
+def sendtocamera2(host, port, data):
+ print("Sending to "+host+" on port "+str(port)+" DATA:"+data)
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try:
+ while True:
s.connect((host, port))
s.send(str.encode(data))
break
- except:
- ('trying again...')
+ except:
+ ('trying again...')
print("Sent to server..")
s.close()
+
##--------------Listen for Clients-----------------------
def listenforclients(host, port, q):
@@ -49,7 +63,7 @@ def listenforclients(host, port, q):
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host,port))
try:
- s.listen(1)
+ s.listen(5)
c, addr = s.accept()
while True:
data = c.recv(1024)
@@ -178,9 +192,9 @@ def main(serverstatus):
rectime=time.time()
elif a == mastersound:
sendtocamera(i,port,'STOP')
- if recording != mastersound:
- time.sleep(sleep)
- sendtocamera(i,port,'RECSOUND')
+ #if recording != mastersound:
+ # time.sleep(sleep)
+ # sendtocamera(i,port,'RECSOUND')
else:
sendtocamera(i,port,'PLACEHOLDER')
a=a+1
@@ -206,6 +220,7 @@ def main(serverstatus):
a=0
for c in cameras:
if c not in camerasoff:
+ print(c)
if a == camselected:
if a == mastersound:
sendtocamera(c,port,'STOP')
@@ -227,10 +242,12 @@ def main(serverstatus):
sendtocamera(c,port,'STOP')
time.sleep(sleep)
sendtocamera(c,port,'RECSOUND')
- sendtocamera(c,port,'STOP')
- time.sleep(sleep)
- sendtocamera(c,port,'PLACEHOLDER')
- a=a+1
+ else:
+ sendtocamera(c,port,'STOP')
+ time.sleep(sleep)
+ sendtocamera(c,port,'PLACEHOLDER')
+ #time.sleep(2)
+ a=a+1
camselected=newselected
printmenu(recording,selected,cameras,camselected,serverstatus,rectime)
return serverstatus