Merge branch 'main' into feature/drive-type-marker

This commit is contained in:
2025-12-06 23:06:05 +01:00
7 changed files with 344 additions and 52 deletions

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Author: Hendrik Schutter, localhorst@mosad.xyz
Date of creation: 2022/11/23
Date of last modification: 2025/06/15
"""Author: Hendrik Schutter, localhorst@mosad.xyz
Date of creation: 2022/11/23
Date of last modification: 2025/06/15
"""
import ctypes
@ -121,6 +121,7 @@ def create_drive_objects(drive_info):
def worker(queue_id, test_mode=False):
try:
while not terminate:
time.sleep(3)
if test_mode:
drive_info = {
"driveIndex": "42",
@ -171,7 +172,6 @@ def worker(queue_id, test_mode=False):
"driveConnectionType": d.caDriveConnectionType.decode().strip("\x00"),
"driveReHddVersion": d.caDriveReHddVersion.decode().strip("\x00"),
}
time.sleep(3)
print(f"Received Drive Data: {drive_info}")
@ -208,9 +208,16 @@ def main():
return
while True:
try:
queue_id = msgget(MSG_QUEUE_KEY, 0)
# Create or connect to the message queue with IPC_CREAT flag
# This matches the C++ sender's flags (IPC_CREAT | 0666)
queue_id = msgget(MSG_QUEUE_KEY, IPC_CREAT | 0o666)
if queue_id == -1:
raise RuntimeError("Failed to connect to the existing message queue.")
err = ctypes.get_errno()
raise RuntimeError(
f"Failed to create/connect to the message queue: {os.strerror(err)}"
)
print(f"Successfully connected to message queue (ID: {queue_id})")
worker(queue_id)
except Exception as e:
print(f"Main process encountered an error: {e}")