Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/hal/utils/scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ static void exit_on_signal(int signum) {
exit(1);
}

/* callback for hal_list_funct(), matches a function by name */
static int find_funct_cb(hal_query_t *q, void *arg)
{
if (!strcmp((const char *)arg, q->name)) {
return 1; /* positive, break the loop without error */
}
return 0;
}

/* Read just the SAMPLES value from config file before loading scope_rt */
static int read_samples_from_config(const char *filename)
{
Expand Down Expand Up @@ -199,8 +208,9 @@ int main(int argc, gchar * argv[])
return -1;
}

int rv = hal_comp_by_name("scope.sample", NULL);
if (-ENOENT == rv) {
hal_query_t qf = {};
int rv = hal_list_funct(&qf, find_funct_cb, (void *)"scope.sample");
if (rv <= 0) {
char buf[1000];
snprintf(buf, sizeof(buf), EMC2_BIN_DIR "/halcmd loadrt scope_rt num_samples=%d",
num_samples);
Expand All @@ -211,10 +221,7 @@ int main(int argc, gchar * argv[])
}
} else {
/* scope_rt already loaded - we'll check if sample count matches later */
if(0 == rv)
rtapi_print_msg(RTAPI_MSG_DBG, "SCOPE: scope_rt already loaded, requested %d samples\n", num_samples);
else
rtapi_print_msg(RTAPI_MSG_DBG, "SCOPE: hal_comp_by_name() returned error %d\n", rv);
rtapi_print_msg(RTAPI_MSG_DBG, "SCOPE: scope_rt already loaded, requested %d samples\n", num_samples);
}
/* set up a shared memory region for the scope data */
shm_id = rtapi_shmem_new(SCOPE_SHM_KEY, comp_id, sizeof(scope_shm_control_t));
Expand Down
Loading