Commit 0898204f authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

No more SWIG dependencies

parent 79a0d84e
......@@ -21,6 +21,7 @@ import os
import importlib
import time
import DV
import ctypes
try:
from PythonController import(OpenMsgQueueForReading, GetMsgQueueBufferSize,
......@@ -176,10 +177,11 @@ class PollerThread(QThread):
print 'Failed to open message queue ' + self.q_name
return -1
buffer_size = GetMsgQueueBufferSize(msg_q)
#p_data_from_mq = DV.new_byte_SWIG_PTR(buffer_size)
p_data_from_mq = ctypes.create_string_buffe(buffer_size).raw
while True:
if self.stop_requested:
return 0
p_data_from_mq = DV.new_byte_SWIG_PTR(buffer_size)
msg_received_type = RetrieveMessageFromQueue(
msg_q, buffer_size, p_data_from_mq)
if msg_received_type == -1:
......
......@@ -27,7 +27,7 @@ import logging
import argparse
import time
from functools import partial
from ctypes import CDLL
from ctypes import CDLL, create_string_buffer
log = logging.getLogger(__name__)
terminal_formatter = logging.Formatter(
......@@ -60,7 +60,7 @@ except ImportError:
datamodel = None
try:
from PythonController import(OpenMsgQueueForReading, new_byte_SWIG_PTR,
from PythonController import(OpenMsgQueueForReading,
GetMsgQueueBufferSize, DV, RetrieveMessageFromQueue)
python_controller = True
except ImportError:
......@@ -108,7 +108,8 @@ class MsgQ_Poller(QThread):
"Retrying...".format(Qname=self.Qname))
time.sleep(1)
bufferSize = GetMsgQueueBufferSize(self._msgQueue)
pDataFromMQ = new_byte_SWIG_PTR(bufferSize)
#pDataFromMQ = new_byte_SWIG_PTR(bufferSize)
pDataFromMQ = create_string_buffer(bufferSize).raw
while not self._bDie:
messageReceivedType = RetrieveMessageFromQueue(
self._msgQueue, bufferSize, pDataFromMQ)
......@@ -202,7 +203,7 @@ def gui():
# Default: use message queue
log.info('Using message queues to communicate')
if not python_controller:
log.error('Python module "PythonController" is missing')
log.error('Python module "PythonController": import error')
return -1
elif options.udp:
msgQ = False
......
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