diff --git a/doc/wrs-developer-manual.in b/doc/wrs-developer-manual.in index 0de02199f67cda3ab701586f1a7048aba21e617c..f5574b99524583226f1d69323ea3f25cc5c549c8 100644 --- a/doc/wrs-developer-manual.in +++ b/doc/wrs-developer-manual.in @@ -1525,12 +1525,6 @@ Clients are created in the following places: actions related to vlan setup. All status information is passed through shared memory. -@item userspace/wrsw_hal/hal_exports.c -@c FIXME: don't check with a socket, but with the shmem mechanism - - A temporary client is created to check whether a HAL process - is already running. - @item userspace/tools/wr_mon.c @c FIXME: wr_mon should use shmem diff --git a/userspace/wrsw_hal/Makefile b/userspace/wrsw_hal/Makefile index 9442847b22cbe642de06262658758165b63ffd8d..faf81676abefc365935a776507653f066eb800dd 100644 --- a/userspace/wrsw_hal/Makefile +++ b/userspace/wrsw_hal/Makefile @@ -23,7 +23,7 @@ CFLAGS = -O -g -Wall \ -I$(LINUX)/arch/arm/mach-at91/include LDFLAGS = -L../libwr -L../mini-rpc \ - -lminipc -lm -ldl -lwr + -lm -ldl -lwr -lminipc all: $(BINARY) diff --git a/userspace/wrsw_hal/hal_exports.c b/userspace/wrsw_hal/hal_exports.c index fad826457d26c61021b3d628e9478e5ae59e8868..7dbe74376ecb9982c4b4d0c4cfdb19aceb7df405 100644 --- a/userspace/wrsw_hal/hal_exports.c +++ b/userspace/wrsw_hal/hal_exports.c @@ -2,6 +2,9 @@ #include <stdio.h> #include <stdlib.h> +#include <errno.h> +#include <signal.h> +#include <string.h> #include <libwr/wrs-msg.h> #include <libwr/pps_gen.h> /* for direct access to DMPLL and PPS generator */ @@ -10,6 +13,7 @@ #include <rt_ipc.h> #include <minipc.h> +#include <libwr/shmem.h> #define HAL_EXPORT_STRUCTURES #include <hal/hal_exports.h> /* for exported structs/function protos */ @@ -212,11 +216,20 @@ int hal_update_wripc(int ms_timeout) to prevent from launching multiple HALs simultaneously. */ int hal_check_running() { - struct minipc_ch *ch; + struct wrs_shm_head *hal_head; + hal_head = wrs_shm_get(wrs_shm_hal, "", WRS_SHM_READ); + if (!hal_head) { + pr_info("Unable to open shm for HAL! Unable to check if there " + "is another HAL instance running. Error: %s\n", + strerror(errno)); + exit(-1); + } - ch = minipc_client_create(WRSW_HAL_SERVER_ADDR, 0); - if (!ch) + /* check if pid is 0 (shm not filled) or process with provided + * pid does not exist (probably crashed) */ + if ((hal_head->pid == 0) || (kill(hal_head->pid, 0) != 0)) return 0; - minipc_close(ch); + + wrs_shm_put(hal_head); return 1; }