commit d89e3281759c908677ac68b38058cc31af05342c
parent ebaa6d5a54c89fc59985dbeb913258efe90ec765
Author: rob <rob@tarina.org>
Date: Fri, 17 Mar 2023 10:19:08 +0000
test
Diffstat:
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/tarinactrl.py b/tarinactrl.py
@@ -36,29 +36,16 @@ def sendtocamera(host, port, data):
while True:
s.connect((host, port))
s.send(str.encode(data))
+ print("Sent to server..")
break
except:
- ('trying again...')
- print("Sent to server..")
+ ('did not connect')
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...')
- print("Sent to server..")
- s.close()
-
-
##--------------Listen for Clients-----------------------
def listenforclients(host, port, q):
+ global cameras
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host,port))
@@ -67,6 +54,8 @@ def listenforclients(host, port, q):
c, addr = s.accept()
while True:
data = c.recv(1024)
+ if addr not in cameras:
+ cameras.append(addr)
if not data:
break
ctrltime=time.time()
@@ -259,6 +248,9 @@ def main(serverstatus):
#time.sleep(2)
a=a+1
camselected=newselected
+
+ # ping ip every 10 sec while not recording to connect cameras
+
printmenu(recording,selected,cameras,camselected,serverstatus,rectime)
return serverstatus