Skip to content
Snippets Groups Projects
Commit b2b7f3be authored by Taya Snijder's avatar Taya Snijder
Browse files

processed review feedback

parent 2ce885bf
No related branches found
No related tags found
1 merge request!50Resolve L2SS-188 "2021 05 27 branched from master udp recv sst client"
...@@ -36,7 +36,7 @@ class SST(hardware_device): ...@@ -36,7 +36,7 @@ class SST(hardware_device):
# ----------------- # -----------------
SST_Port = device_property( SST_Port = device_property(
dtype='DevULong', dtype='DevUShort',
mandatory=True mandatory=True
) )
...@@ -45,8 +45,8 @@ class SST(hardware_device): ...@@ -45,8 +45,8 @@ class SST(hardware_device):
# ---------- # ----------
# -------- # --------
packet_count_R = attribute_wrapper(comms_annotation={"parameter": "packet_count"}, datatype=numpy.int64) packet_count_R = attribute_wrapper(comms_annotation={"parameter": "packet_count_R"}, datatype=numpy.int64)
timestamp_R = attribute_wrapper(comms_annotation={"parameter": "timestamp"}, datatype=numpy.int64) last_packet_timestamp_R = attribute_wrapper(comms_annotation={"parameter": "last_packet_timestamp_R"}, datatype=numpy.int64)
# -------- # --------
# overloaded functions # overloaded functions
...@@ -73,7 +73,7 @@ class SST(hardware_device): ...@@ -73,7 +73,7 @@ class SST(hardware_device):
except Exception as e: except Exception as e:
# use the pass function instead of setting read/write fails # use the pass function instead of setting read/write fails
i.set_pass_func() i.set_pass_func()
self.warn_stream("error while setting the sst attribute {} read/write function. {}".format(i, e)) self.warn_stream("error while setting the sst attribute {} read/write function. {}. using pass function instead".format(i, e))
pass pass
self.sst_client.start() self.sst_client.start()
......
...@@ -153,8 +153,8 @@ class SST(Thread): ...@@ -153,8 +153,8 @@ class SST(Thread):
self.last_packet = None self.last_packet = None
self.parameters = { self.parameters = {
"packet_count": numpy.int64(0), "packet_count_R": numpy.int64(0),
"timestamp": numpy.int64(0) "last_packet_timestamp_R": numpy.int64(0)
} }
super().__init__() super().__init__()
...@@ -166,17 +166,17 @@ class SST(Thread): ...@@ -166,17 +166,17 @@ class SST(Thread):
while True: while True:
if len(self.deque) > 0: if len(self.deque) > 0:
packet = self.deque.pop() packet = self.deque.popleft()
# if packet is None: # if packet is None:
# break # break
self.decode(packet) self.process_packet(packet)
def __del__(self): def __del__(self):
self.deque.appendleft(None) self.deque.appendleft(None)
self.join() self.join()
def decode(self, packet): def process_packet(self, packet):
self.parameters["packet_count"] = self.parameters["packet_count"] + numpy.int64(1) self.parameters["packet_count_R"] += 1
self.parameters["timestamp"] = numpy.int64(int(time.time())) self.parameters["last_packet_timestamp_R"] = numpy.int64(int(time.time()))
...@@ -9,14 +9,14 @@ MESSAGE = "{}".format(i) ...@@ -9,14 +9,14 @@ MESSAGE = "{}".format(i)
print("UDP target IP: %s" % UDP_IP) print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT) print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)
sock = socket.socket(socket.AF_INET, # Internet sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # create UDP socket
socket.SOCK_DGRAM) # UDP
while True: while True:
sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT)) sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
i += 1 i += 1
MESSAGE = "{}".format(i) MESSAGE = "{}".format(i)
#sleep for an arbitrary amount of time. Currently 0.2 settings for visual testing.
time.sleep(0.2) time.sleep(0.2)
# time.sleep(0.1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment