From 5f57f6ff019f391b56461ebb76b5da52901ca62a Mon Sep 17 00:00:00 2001 From: Colin Waddell Date: Mon, 21 Jul 2025 15:23:43 +0100 Subject: [PATCH 1/3] Not all scripts are supported with a .bat file. Check if the .bat file exists first, and if not try a .exe --- lcm-python/lcm/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lcm-python/lcm/__init__.py b/lcm-python/lcm/__init__.py index 2b790250..63309aa5 100644 --- a/lcm-python/lcm/__init__.py +++ b/lcm-python/lcm/__init__.py @@ -177,9 +177,20 @@ def tell (self): LCM_BIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'bin') def run_script(name: str, args) -> int: - file_extension = '.bat' if platform.system() == 'Windows' else '' try: - return subprocess.call([os.path.join(LCM_BIN_DIR, name + file_extension), *args], close_fds=False) + if platform.system() == 'Windows': + candidates = [ + os.path.join(LCM_BIN_DIR, f"{name}.bat"), + os.path.join(LCM_BIN_DIR, f"{name}.exe") + ] + else: + candidates = [os.path.join(LCM_BIN_DIR, name)] + + for executable in candidates: + if os.path.exists(executable): + return subprocess.call([executable, *args], close_fds=False) + + raise FileNotFoundError(f"No executable found for {name} in {LCM_BIN_DIR}") except KeyboardInterrupt: return 0 From 087a70662dac3f0fa356115fd437abff0bedc6c6 Mon Sep 17 00:00:00 2001 From: Colin Waddell Date: Mon, 21 Jul 2025 15:24:34 +0100 Subject: [PATCH 2/3] On Windows these functions are getting stuck and causing the application to exit prematurely. Modified them as is appropriate for Windows and not lcm-logger is working as expected --- lcm-logger/glib_util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lcm-logger/glib_util.c b/lcm-logger/glib_util.c index e2773da4..ae0999d4 100644 --- a/lcm-logger/glib_util.c +++ b/lcm-logger/glib_util.c @@ -140,6 +140,10 @@ static void spgqok_handler(int signum, void *user) int signal_pipe_glib_quit_on_kill() { +#ifdef _WIN32 + // Windows does not support Unix-style signal handling reliably. + return 0; +#else if (0 != signal_pipe_init()) return -1; @@ -147,6 +151,7 @@ int signal_pipe_glib_quit_on_kill() signal_pipe_add_signal(SIGTERM); signal_pipe_add_signal(SIGKILL); return signal_pipe_attach_glib(spgqok_handler, _mainloop); +#endif } static int lcm_message_ready(GIOChannel *source, GIOCondition cond, lcm_t *lcm) @@ -182,7 +187,11 @@ int glib_mainloop_attach_lcm(lcm_t *lcm) glib_attached_lcm_t *galcm = (glib_attached_lcm_t *) calloc(1, sizeof(glib_attached_lcm_t)); +#ifdef _WIN32 + galcm->ioc = g_io_channel_win32_new_socket(lcm_get_fileno(lcm)); +#else galcm->ioc = g_io_channel_unix_new(lcm_get_fileno(lcm)); +#endif galcm->sid = g_io_add_watch(galcm->ioc, G_IO_IN, (GIOFunc) lcm_message_ready, lcm); galcm->lcm = lcm; From 58aa6d2d4bf977da1f8fdfc78690c80dc8253e70 Mon Sep 17 00:00:00 2001 From: Colin Waddell Date: Mon, 21 Jul 2025 16:45:10 +0100 Subject: [PATCH 3/3] Failed build tests due to -Werror=unused-function flag. Removing this function from builds where it's not required --- lcm-logger/glib_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lcm-logger/glib_util.c b/lcm-logger/glib_util.c index ae0999d4..3641c834 100644 --- a/lcm-logger/glib_util.c +++ b/lcm-logger/glib_util.c @@ -132,11 +132,13 @@ int signal_pipe_attach_glib(signal_pipe_glib_handler_t func, gpointer user_data) return 0; } +#ifndef _WIN32 static void spgqok_handler(int signum, void *user) { g_main_loop_quit(_mainloop); signal_pipe_cleanup(); } +#endif int signal_pipe_glib_quit_on_kill() {