Commit 692bbf39 authored by Lucas Russo's avatar Lucas Russo

src/dev_io/dev_io.c: don`t try to get board slot for RFFE DEVIO

RFFE DEVIO already has the correct slot number
from the regular DEVIO. As such, it does not need
to spawn a libclient instance to get ther board
number from DEVIO CFG.

This simplifies the creataion/destruction of DEVIO
CFG, as we don`t need to wait for anything to destroy
it. The regular DEVIO just kills it after getting the
board number.

This fixes #94 github issue.
parent acbe5a07
......@@ -51,6 +51,7 @@
#define DEVIO_SERVICE_LEN 50
#define DEVIO_NAME "/usr/local/bin/dev_io"
#define DEVIO_CFG_NAME "/usr/local/bin/dev_io_cfg"
#define DEVIO_CFG_TIMEOUT 5000 /* in ms */
#define EPICS_PROCSERV_NAME "/usr/local/bin/procServ"
#define EPICS_BPM_NAME "BPM"
#define EPICS_BPM_RUN_SCRIPT_NAME "./run.sh"
......@@ -260,7 +261,7 @@ int main (int argc, char *argv[])
/* Spawn the Configure DEVIO to get the uTCA slot number. This is only
* available in AFCv3 */
bpm_client_t *client_cfg = NULL;
#if defined (__BOARD_AFCV3__) && (__WITH_DEVIO_CFG__)
int child_devio_cfg_pid = 0;
if (llio_type == PCIE_DEV) {
......@@ -279,48 +280,58 @@ int main (int argc, char *argv[])
}
}
/* At this point, the Config DEVIO is ready to receive our commands */
char devio_config_service_str [DEVIO_SERVICE_LEN];
snprintf (devio_config_service_str, DEVIO_SERVICE_LEN-1, "BPM%u:DEVIO_CFG:AFC_DIAG%u",
dev_id, 0);
devio_config_service_str [DEVIO_SERVICE_LEN-1] = '\0'; /* Just in case ... */
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io] Creating libclient for DEVIO config\n");
bpm_client_err_e client_err = BPM_CLIENT_SUCCESS;
bpm_client_t *client_cfg = bpm_client_new_log_mode (broker_endp, 0,
"stdout", DEVIO_LIBBPMCLIENT_LOG_MODE);
if (client_cfg == NULL) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_FATAL, "[dev_io] Could not create "
"DEVIO Config libclient instance\n");
goto err_client_cfg;
}
/* Get uTCA card slot number */
client_err = bpm_get_afc_diag_card_slot (client_cfg, devio_config_service_str,
&dev_id);
if (client_err != BPM_CLIENT_SUCCESS) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_FATAL, "[dev_io] Could not retrieve "
"slot number. Unsupported board?\n");
goto err_card_slot;
}
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io] Slot number: 0x%08X\n", dev_id);
if (llio_type == PCIE_DEV) {
/* FIXME: give some time for the process to terminate gracefully */
sleep (5);
/* Kill DEVIO cfg as we've already got our slot number */
if (child_devio_cfg_pid > 0) {
kill (child_devio_cfg_pid, DEVIO_KILL_CFG_SIGNAL);
/* FE DEVIO is expected to have a correct dev_id. So, we don't need to get it
* from Hardware */
if (devio_type == BE_DEVIO) {
/* At this point, the Config DEVIO is ready to receive our commands */
char devio_config_service_str [DEVIO_SERVICE_LEN];
snprintf (devio_config_service_str, DEVIO_SERVICE_LEN-1, "BPM%u:DEVIO_CFG:AFC_DIAG%u",
dev_id, 0);
devio_config_service_str [DEVIO_SERVICE_LEN-1] = '\0'; /* Just in case ... */
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io] Creating libclient for DEVIO config\n");
bpm_client_err_e client_err = BPM_CLIENT_SUCCESS;
/* Give DEVIO CFG some time more to answer (DEVIO_CFG_TIMEOUT) as it was just spawned... */
client_cfg = bpm_client_new_log_mode_time (broker_endp, 0,
"stdout", DEVIO_LIBBPMCLIENT_LOG_MODE, DEVIO_CFG_TIMEOUT);
if (client_cfg == NULL) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_FATAL, "[dev_io] Could not create "
"DEVIO Config libclient instance\n");
goto err_client_cfg;
}
/* Get uTCA card slot number */
client_err = bpm_get_afc_diag_card_slot (client_cfg, devio_config_service_str,
&dev_id);
if (client_err != BPM_CLIENT_SUCCESS) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_FATAL, "[dev_io] Could not retrieve "
"slot number. Unsupported board?\n");
goto err_card_slot;
}
/* Wait child up to 5 seconds before giving up waiting */
hutils_wait_chld_timed (5000);
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io] Slot number: 0x%08X\n", dev_id);
/* We could just leave DEVIO CFG arounf and not kill it. We do it just
* for the sake not having unnecessary things running, as the regular
* DEVIO already spwan the same service (i.e., AFC DIAG) as DEVIO CFG */
#if 1
if (llio_type == PCIE_DEV) {
/* Kill DEVIO cfg as we've already got our slot number */
if (child_devio_cfg_pid > 0) {
kill (child_devio_cfg_pid, DEVIO_KILL_CFG_SIGNAL);
}
/* Wait child up to 5 seconds before giving up waiting */
hutils_wait_chld_timed (5000);
}
/* Destroy libclient */
bpm_client_destroy (&client_cfg);
}
/* Destroy libclient */
bpm_client_destroy (&client_cfg);
#endif
#endif
/* We don't need it anymore */
......
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