linux: add start script and fixes; diagnostic outputs

This commit is contained in:
2025-10-19 21:50:09 +02:00
parent d2a9a4197c
commit 6d751861c8
11 changed files with 668 additions and 485 deletions

View File

@@ -144,13 +144,12 @@ class Refifc(object):
os.chdir(self.original_directory)
raise
ctypes_refrig_name = refrig_name
if os.name == 'posix':
if not ctypes_refrig_name.lower().endswith("so"):
ctypes_refrig_name = ctypes_refrig_name + ".so"
if not ctypes_refrig_name.lower().startswith("lib"):
ctypes_refrig_name = "lib" + ctypes_refrig_name
# Use the plain refrigerant identifier when calling the native loader.
# On POSIX the native library usually resolves the actual "libRxxx.so"
# filename itself and expects a simple name like "R134a". Passing a
# modified filename (e.g. "libR134a.so") can confuse the native loader
# and lead to crashes. Also ensure the loader returns a void pointer and
# validate it before using.
try:
ctypes.CDLL(os.path.join(dll_directory, REFIFC_LIB_NAME))
except OSError:
@@ -158,14 +157,17 @@ class Refifc(object):
print(f"Refrig {refrig_name} not found, please check!")
func = self.lib.refdll_load
func.restype = POINTER(c_void_p)
# expect a void* handle from the loader
func.restype = c_void_p
func.argtypes = [c_char_p, c_void_p]
# On POSIX the native loader often expects the full SO filename
# (e.g. "libR290.so"). We built `ctypes_refrig_name` above to match
# that convention; use it when calling the native loader.
name_to_pass = ctypes_refrig_name if ctypes_refrig_name else refrig_name
name_bytes = refrig_name.encode('utf-8')
try:
self.handle = func(c_char_p(name_to_pass.encode('utf-8')), c_void_p())
res = func(c_char_p(name_bytes), c_void_p())
if not res:
# loader returned NULL -> raise to surface a Python-level error
raise OSError(f"refdll_load returned NULL for refrigerant '{refrig_name}'")
# store handle as a c_void_p
self.handle = c_void_p(res)
finally:
# restore cwd even if the native call raises
try: