Skip to content

Commit

Permalink
Update liveStreamListenerExample.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeiSolokhin committed Nov 22, 2023
1 parent 9d264d7 commit f7d9c9d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions PythonExamples/liveStreamListenerExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import json
import csv

# configuration
HOST, PORT = '', 14043
SAVE_TO_FILE = True
UNPACK_PACKET = False
SAVE_TO_FILE = False

def WriteUnpackedToFile(data):
if SAVE_TO_FILE:
Expand Down Expand Up @@ -49,14 +51,16 @@ def Unpack(data):
print ("Start listener at port {}".format(PORT))
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((HOST, PORT))
s.setblocking(0)
s.setblocking(1)

while True:
try:
data, address = s.recvfrom(20000)
Unpack(data)
data, address = s.recvfrom(40000)
if UNPACK_PACKET:
Unpack(data)

except socket.error:
except socket.error as e:
print (e)
pass
else:
packet_time = time.time()
Expand Down

0 comments on commit f7d9c9d

Please sign in to comment.