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

processed review feedback

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