diff --git a/src/scii/main.py b/src/scii/main.py
index c86f219..4d19748 100644
--- a/src/scii/main.py
+++ b/src/scii/main.py
@@ -1,12 +1,39 @@
+import sys
+
from loguru import logger
from scii.mq import MessageQueue
logger.catch
def main():
+ setup_logging("TRACE", True)
logger.info("welcome to the SCI Interface")
- with MessageQueue(rx="/sci_tx", tx="/sci_rx") as qu:
+ with MessageQueue(rx="/sci_tx", tx="/sci_rx") as queue:
while True:
- r = qu.receive()
+ r = queue.receive()
if r is None:
break
+ logger.info("msg: {}", r)
+
+ queue.send("list")
+ r = queue.receive()
+ if r is None:
+ break
+ logger.info("list: {}", r)
+
+
+def setup_logging(level: str, use_colors: bool) -> None:
+ """Setup logging.
+
+ Args:
+ level: The logging level.
+ use_colors: Whether to use colors in the log output.
+
+ """
+ logger.remove() # A fresh start
+ _ = logger.add(
+ sys.stderr,
+ colorize=use_colors,
+ format="{time:HH:mm:ss} {level} {file}:{line}: {message}",
+ level=level,
+ )
diff --git a/src/scii/mq.py b/src/scii/mq.py
index e66b050..a408fa2 100644
--- a/src/scii/mq.py
+++ b/src/scii/mq.py
@@ -43,7 +43,7 @@ class MessageQueue:
def receive(self) -> str | None:
if not self._is_rx_valid():
raise RuntimeError(f"rx queue is invalid {self._rx_queue}")
- result = create_string_buffer(b'\0' * 32)
+ result = create_string_buffer(b'\0' * 64)
res = libc.mq_receive(self._rx_queue, result, 8192, None)
if res == -1:
libc.perror(b"mq_receive")