eamio-icca: add config to allow port to be set
also fixes issue where no logging would show up in eamiotest
This commit is contained in:
committed by
b775d4b79856d2b538f34c4bd2ef68af9d144fff
parent
089253a537
commit
fb3d2ea312
@@ -4,7 +4,9 @@ dlls += \
|
||||
libs_eamio-icca := \
|
||||
aciodrv \
|
||||
aciomgr \
|
||||
cconfig \
|
||||
util \
|
||||
|
||||
src_eamio-icca := \
|
||||
config-icc.c \
|
||||
eamio-icca.c \
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "eamio-icca/config-icc.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#define EAMIO_ICCA_CONFIG_ICC_PORT_KEY "bio2.port"
|
||||
#define EAMIO_ICCA_CONFIG_ICC_BAUD_KEY "bio2.baud"
|
||||
|
||||
#define EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE "COM1"
|
||||
#define EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE 57600
|
||||
|
||||
void eamio_icca_config_icc_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
EAMIO_ICCA_CONFIG_ICC_PORT_KEY,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE,
|
||||
"ICCA serial port");
|
||||
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
EAMIO_ICCA_CONFIG_ICC_BAUD_KEY,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE,
|
||||
"ICCA bus baudrate (real devices expect 57600)");
|
||||
}
|
||||
|
||||
void eamio_icca_config_icc_get(
|
||||
struct icc_config *config_icc, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
EAMIO_ICCA_CONFIG_ICC_PORT_KEY,
|
||||
config_icc->port,
|
||||
sizeof(config_icc->port) - 1,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
EAMIO_ICCA_CONFIG_ICC_PORT_KEY,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
EAMIO_ICCA_CONFIG_ICC_BAUD_KEY,
|
||||
&config_icc->baud,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
EAMIO_ICCA_CONFIG_ICC_BAUD_KEY,
|
||||
EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef EAMIO_ICCA_CONFIG_ICC_H
|
||||
#define EAMIO_ICCA_CONFIG_ICC_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
struct icc_config {
|
||||
char port[64];
|
||||
int32_t baud;
|
||||
};
|
||||
|
||||
void eamio_icca_config_icc_init(struct cconfig *config);
|
||||
|
||||
void eamio_icca_config_icc_get(
|
||||
struct icc_config *config_icc, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
#include "bemanitools/eamio.h"
|
||||
|
||||
#include "cconfig/cconfig-main.h"
|
||||
#include "eamio-icca/config-icc.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#define NUMBER_OF_EMULATED_READERS 2
|
||||
@@ -73,7 +76,30 @@ static bool check_if_icca(int node_id) {
|
||||
bool eam_io_init(
|
||||
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
|
||||
{
|
||||
acio_manager_ctx = aciomgr_port_init("COM1", 57600);
|
||||
struct cconfig *config;
|
||||
struct icc_config config_icc;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
eamio_icca_config_icc_init(config);
|
||||
|
||||
if (!cconfig_main_config_init(
|
||||
config,
|
||||
"--icc-config",
|
||||
"eamio-icc.conf",
|
||||
"--help",
|
||||
"-h",
|
||||
"eamio-icca",
|
||||
CCONFIG_CMD_USAGE_OUT_STDOUT)) {
|
||||
cconfig_finit(config);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
eamio_icca_config_icc_get(&config_icc, config);
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
acio_manager_ctx = aciomgr_port_init(config_icc.port, config_icc.baud);
|
||||
|
||||
if (acio_manager_ctx == NULL) {
|
||||
log_warning("Opening acio device on COM1 failed");
|
||||
|
||||
Reference in New Issue
Block a user