Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
lerwys committed Jul 12, 2017
2 parents c244c6a + 2224311 commit f1e9a92
Show file tree
Hide file tree
Showing 18 changed files with 401 additions and 137 deletions.
80 changes: 65 additions & 15 deletions apps/halcsd/src/halcsd/c/halcsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,29 @@
#define LOG_FILENAME_LEN 50
/* This composes the log filename as "halcsd%u_fe%u.log" or
* "halcsd%u_be%u.log" */
#define DEVIO_LOG_PREFIX_PATTERN "%s/"
#define DEVIO_LOG_RADICAL_PATTERN "halcsd%u"
#define DEVIO_LOG_DEVIO_MODEL_TYPE "%s"
#define DEVIO_LOG_INST_TYPE "%u"
#define DEVIO_LOG_SUFFIX "log"
#define DEVIO_LOG_FILENAME_PATTERN \
#define DEVIO_LOG_FILENAME_PATTERN \
DEVIO_LOG_PREFIX_PATTERN \
DEVIO_LOG_RADICAL_PATTERN "_" \
DEVIO_LOG_DEVIO_MODEL_TYPE \
DEVIO_LOG_INST_TYPE "." \
DEVIO_LOG_SUFFIX

/* This composes the INFO filename as "halcsd%u_fe%u_info.log" or
* "halcsd%u_be%u_info.log" */
#define DEVIO_LOG_INFO_TYPE "info"
#define DEVIO_LOG_INFO_FILENAME_PATTERN \
DEVIO_LOG_PREFIX_PATTERN \
DEVIO_LOG_RADICAL_PATTERN "_" \
DEVIO_LOG_DEVIO_MODEL_TYPE \
DEVIO_LOG_INST_TYPE "_" \
DEVIO_LOG_INFO_TYPE "." \
DEVIO_LOG_SUFFIX

/* Arbitrary hard limit for the maximum number of AFE DEVIOs
* for each DBE DEVIO */
#define DEVIO_MAX_FE_DEVIOS 16
Expand All @@ -56,13 +69,14 @@
#define EPICS_PROCSERV_NAME "/usr/local/bin/procServ"
#define EPICS_HALCS_RUN_SCRIPT_NAME "./run.sh"

#define DEVIO_LIBHALCSCLIENT_LOG_MODE "a"
#define DEVIO_KILL_CFG_SIGNAL SIGINT
#define DEVIO_LIBHALCSCLIENT_LOG_MODE "a"
#define DEVIO_KILL_CFG_SIGNAL SIGINT
#define FRONTEND_ENDPOINT_PREFIX "ipc:///tmp/halcs-pipe"

static devio_err_e _rffe_get_dev_entry (uint32_t dev_id, uint32_t fe_smio_id,
zhashx_t *hints, char **dev_entry);
static char *_create_log_filename (char *log_prefix, uint32_t dev_id,
const char *devio_type, uint32_t smio_inst_id);
static char *_create_log_filename (char *log_prefix, char *log_filename_pattern,
uint32_t dev_id, const char *devio_type, uint32_t smio_inst_id);
static devio_err_e _spawn_platform_smios (void *pipe, devio_type_e devio_type,
uint32_t smio_inst_id, zhashx_t *hints, uint32_t dev_id);
static devio_err_e _spawn_fe_platform_smios (void *pipe, uint32_t smio_inst_id);
Expand Down Expand Up @@ -462,21 +476,24 @@ int main (int argc, char *argv[])
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_TRACE, "[halcsd] Creating DEVIO instance ...\n");

/* Create LOG filename path */
char *devio_log_filename = _create_log_filename (log_prefix, dev_id,
devio_type_str, fe_smio_id);
char *devio_log_filename = _create_log_filename (log_prefix,
DEVIO_LOG_FILENAME_PATTERN, dev_id, devio_type_str,
fe_smio_id);
ASSERT_ALLOC (devio_log_filename, err_devio_log_filename_alloc);

/* Create LOG DEVIO info path */
char *devio_log_info_filename = _create_log_filename (log_prefix,
DEVIO_LOG_INFO_FILENAME_PATTERN, dev_id, devio_type_str,
fe_smio_id);
ASSERT_ALLOC (devio_log_info_filename, err_devio_log_info_filename_alloc);

char devio_service_str [DEVIO_SERVICE_LEN];
snprintf (devio_service_str, DEVIO_SERVICE_LEN-1, "HALCS%u:DEVIO", dev_id);
devio_service_str [DEVIO_SERVICE_LEN-1] = '\0'; /* Just in case ... */
devio_t *devio = devio_new (devio_service_str, dev_id, dev_entry, llio_ops,
broker_endp, verbose, devio_log_filename);
broker_endp, verbose, devio_log_filename, devio_log_info_filename);
ASSERT_ALLOC (devio, err_devio_alloc);

/* Print SDB devices. FIXME. This must be called before zactor_new,
* as it access LLIO layer unsafely */
devio_print_info (devio);

/* Start DEVIO loop */

/* Step 1: Loop though all the SDB records and intialize (boot) the
Expand All @@ -494,6 +511,11 @@ int main (int argc, char *argv[])
goto err_server;
}

/* Print SDB devices into generic log */
devio_print_info (server);
/* Print SDB devices into log_info */
devio_print_info_log (server);

/* Spawn platform SMIOSs */
err = _spawn_platform_smios (server, devio_type, fe_smio_id, devio_hints,
dev_id);
Expand Down Expand Up @@ -550,6 +572,28 @@ int main (int argc, char *argv[])
* be sure HALCS is ready to go */
devio_register_sm (server, 0xdc64e778, 0, 0);

#if 0
/* Expose our PIPE port to IPC so other clients can query the server */
zactor_t *proxy = zactor_new (zproxy, NULL);
ASSERT_ALLOC (proxy, err_proxy_alloc, DEVIO_ERR_ALLOC);

const char *backend_endpoint = zsock_endpoint (devio_get_pipe (devio));
char frontend_endpoint [50];
snprintf (frontend_endpoint, sizeof (frontend_endpoint), "%s%u",
FRONTEND_ENDPOINT_PREFIX, full_dev_id);
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[halcsd] Backend (server) endpoint: %s\n",
backend_endpoint);
printf ("[halcsd] Backend (server) endpoint: %s\n", backend_endpoint);
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[halcsd] Frontend (clients) endpoint: %s\n",
frontend_endpoint);
printf ("[halcsd] Frontend (server) endpoint: %s\n", frontend_endpoint);
zstr_sendx (proxy, "FRONTEND", "ROUTER", frontend_endpoint, NULL);
zsock_wait (proxy);
zstr_sendx (proxy, "BACKEND", "PAIR", backend_endpoint, NULL);
zsock_wait (proxy);
#endif

#if 1
/* Accept and print any message back from server */
while (true) {
char *message = zstr_recv (server);
Expand All @@ -562,13 +606,19 @@ int main (int argc, char *argv[])
break;
}
}
#endif

#if 0
err_proxy_alloc:
#endif
smio_cfg_done_err:
err_plat_devio:
zactor_destroy (&server);
err_server:
devio_destroy (&devio);
err_devio_alloc:
free (devio_log_info_filename);
err_devio_log_info_filename_alloc:
free (devio_log_filename);
err_devio_log_filename_alloc:
#if defined (__BOARD_AFCV3__) && (__WITH_APP_CFG__)
Expand Down Expand Up @@ -630,16 +680,16 @@ static devio_err_e _rffe_get_dev_entry (uint32_t dev_id, uint32_t fe_smio_id,
return err;
}

static char *_create_log_filename (char *log_prefix, uint32_t dev_id,
const char *devio_type, uint32_t smio_inst_id)
static char *_create_log_filename (char *log_prefix, char *log_filename_pattern,
uint32_t dev_id, const char *devio_type, uint32_t smio_inst_id)
{
/* Set up logdir */
char *devio_log_filename = zmalloc (LOG_FILENAME_LEN * sizeof (char));
ASSERT_ALLOC (devio_log_filename, err_devio_log_alloc);

/* TODO: Check for the validity of the log filename */
int errs = snprintf (devio_log_filename, LOG_FILENAME_LEN,
"%s/"DEVIO_LOG_FILENAME_PATTERN, log_prefix,
log_filename_pattern, log_prefix,
dev_id, devio_type, smio_inst_id);
ASSERT_TEST (errs >= 0 && errs < LOG_FILENAME_LEN,
"Could not generate DEVIO LOG filename", err_devio_log_gen);
Expand Down
2 changes: 1 addition & 1 deletion apps/halcsd/src/halcsd_cfg/c/halcsd_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int main (int argc, char *argv[])
snprintf (devio_service_str, DEVIO_SERVICE_LEN-1, "HALCS%u:DEVIO_CFG", dev_id);
devio_service_str [DEVIO_SERVICE_LEN-1] = '\0'; /* Just in case ... */
devio_t *devio = devio_new (devio_service_str, dev_id, dev_entry, llio_ops,
broker_endp, verbose, log_filename);
broker_endp, verbose, log_filename, NULL);

if (devio == NULL) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_FATAL, "[halcsd_cfg] devio_new error!\n");
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ allprojects {
cCompiler.args '-std=gnu99', '-O2', '-g'
cCompiler.args '-Wall', '-Wextra', '-Werror'

cCompiler.define 'ERRHAND_MIN_LEVEL=DBG_LVL_WARN'
cCompiler.define 'ERRHAND_MIN_LEVEL=DBG_LVL_INFO'
cCompiler.define 'ERRHAND_SUBSYS_ON=(DBG_DEV_MNGR | ' +
'DBG_DEV_IO | DBG_SM_IO | DBG_LIB_CLIENT | ' +
'DBG_SM_PR | DBG_SM_CH | DBG_LL_IO | DBG_HAL_UTILS)'
Expand Down
4 changes: 2 additions & 2 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ else
fi

LIBSODIUM_VER=1.0.3
LIBZMQ_VER=v4.2.1
LIBZMQ_VER=v4.2.2
LIBCZMQ_VER=v4.0.2
MALAMUTE_VER=v1.3
MALAMUTE_VER=v1.4.3

CONFIG_FLAGS=()
CONFIG_FLAGS+=("CFLAGS=-I${BUILD_PREFIX}/include")
Expand Down
12 changes: 8 additions & 4 deletions core/common/include/dev_io_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ typedef struct {
/* Creates a new instance of Device Information */
devio_t * devio_new (char *name, uint32_t id, char *endpoint_dev,
const llio_ops_t *reg_ops, char *endpoint_broker, int verbose,
const char *log_file_name);
const char *log_file_name, const char *log_info_file_name);
/* Destroy an instance of the Device Information */
devio_err_e devio_destroy (devio_t **self_p);

/* Read specific information about the device. Typically,
* this is stored in the SDB structure inside the device */
devio_err_e devio_print_info (devio_t *self);
/* Register an specific sm_io module to this device */
devio_err_e devio_register_sm (void *pipe, uint32_t smio_id,
uint64_t base, uint32_t inst_id);
Expand All @@ -79,6 +76,13 @@ devio_err_e devio_reconfigure_sm (void *pipe, const char *smio_key);
devio_err_e devio_reconfigure_all_sm (void *pipe);
/* Reset associated LLIO*/
devio_err_e devio_reset_llio (void *pipe);
/* Read specific information about the device. Typically,
* this is stored in the SDB structure inside the device */
devio_err_e devio_print_info (void *pipe);
/* Read specific information about the device and print it
* to INFO log. Typically, this is stored in the SDB structure
* inside the device */
devio_err_e devio_print_info_log (void *pipe);

/* Poll all PIPE sockets */
void devio_loop (zsock_t *pipe, void *args);
Expand Down
Loading

0 comments on commit f1e9a92

Please sign in to comment.