Commit 3b0932a5 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: improve opening of shmem in wr_phytool

Wait 10 seconds open shmem.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent bed6874b
......@@ -57,14 +57,26 @@ int hal_shm_init(void)
{
int ii;
struct hal_shmem_header *h;
/* open shmem to HAL */
hal_head = wrs_shm_get(wrs_shm_hal, "", WRS_SHM_READ | WRS_SHM_LOCKED);
if (!hal_head) {
fprintf(stderr,
"FATAL: wr_phytool unable to open shm to HAL.\n");
return -1;
int n_wait = 0;
int ret;
/* wait for HAL */
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
fprintf(stderr, "wr_phytool: Unable to open "
"HAL's shm !\n");
}
if (ret == 2) {
fprintf(stderr, "wr_phytool: Unable to read "
"HAL's version!\n");
}
return(-1);
}
sleep(1);
}
/* check hal's shm version */
if (hal_head->version != HAL_SHMEM_VERSION) {
fprintf(stderr, "wr_mon: unknown hal's shm version %i "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment