Commit 222c849f authored by Maxime Perrotin's avatar Maxime Perrotin

Fix buffers with ctypes properly

parent 90bbd93e
......@@ -185,19 +185,23 @@ class PollerThread(QThread):
print 'Failed to open message queue ' + self.q_name
return -1
buffer_size = GetMsgQueueBufferSize(msg_q)
# Configure a buffer to read data from the queue
buff = ctypes.create_string_buffer(buffer_size)
while True:
if self.stop_requested:
return 0
p_data_from_mq = ctypes.create_string_buffer(buffer_size).raw
# Create an actual buffer and get the pointer
# (accessing .raw is doing Python magic)
raw = buff.raw
msg_received_type = RetrieveMessageFromQueue(msg_q,
buffer_size,
p_data_from_mq)
raw)
if msg_received_type == -1:
time.sleep(0.01)
continue
else:
for slot in self.slots:
slot.put((msg_received_type, p_data_from_mq))
slot.put((msg_received_type, raw))
def stop(self):
''' Request the poller to stop '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment