From 2f7836c56355c45a8edec68d697f5dbda4a0e4a6 Mon Sep 17 00:00:00 2001 From: Minh-Quang Nguyen Date: Mon, 9 Jan 2017 14:51:05 -0500 Subject: LC15: LC15 BTS manager improvement Change-Id: I938c793ad709f3dd70d7d9d183a6614fe53b82b3 --- doc/examples/litecell15/lc15bts-mgr.cfg | 91 +++++ src/osmo-bts-litecell15/misc/lc15bts_mgr.c | 120 ++++-- src/osmo-bts-litecell15/misc/lc15bts_mgr.h | 135 +++++-- src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c | 468 +++++++++++++++++++----- src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c | 447 ++++++++++++++++------ src/osmo-bts-litecell15/misc/lc15bts_misc.c | 335 ++++++++++++++++- src/osmo-bts-litecell15/misc/lc15bts_misc.h | 2 +- src/osmo-bts-litecell15/misc/lc15bts_par.c | 12 +- src/osmo-bts-litecell15/misc/lc15bts_par.h | 5 +- src/osmo-bts-litecell15/misc/lc15bts_power.c | 43 ++- src/osmo-bts-litecell15/misc/lc15bts_power.h | 11 +- src/osmo-bts-litecell15/misc/lc15bts_temp.c | 26 +- src/osmo-bts-litecell15/misc/lc15bts_temp.h | 5 +- 13 files changed, 1391 insertions(+), 309 deletions(-) create mode 100644 doc/examples/litecell15/lc15bts-mgr.cfg diff --git a/doc/examples/litecell15/lc15bts-mgr.cfg b/doc/examples/litecell15/lc15bts-mgr.cfg new file mode 100644 index 00000000..5b19e232 --- /dev/null +++ b/doc/examples/litecell15/lc15bts-mgr.cfg @@ -0,0 +1,91 @@ +! +! lc15bts-mgr (0.3.0.284-a7c2-dirty) configuration saved from vty +!! +! +log stderr + logging filter all 1 + logging color 1 + logging print category 0 + logging timestamp 0 + logging level all everything + logging level temp info + logging level fw info + logging level find info + logging level calib info + logging level lglobal notice + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl notice + logging level lgtp notice +! +line vty + no login +! +lc15bts-mgr + limits supply_temp + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits soc + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits fpga + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits rmsdet + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits tx0_temp + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits tx1_temp + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -20 + limits pa0 + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -40 + limits pa1 + threshold warning max 70 + threshold critical max 85 + threshold warning min -10 + threshold critical min -40 + limits supply_volt + threshold warning max 28 + threshold critical max 30 + threshold warning min 20 + threshold critical min 18 + limits tx0_vswr + threshold warning max 3 + threshold critical max 5 + limits tx1_vswr + threshold warning max 3 + threshold critical max 5 + actions normal + pa0-on + pa1-on + bts-service-on + actions warn + no pa0-off + no pa1-off + no bts-service-off + actions critical + pa0-off + pa1-off + no bts-service-off diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c index 3a7d3a1f..2398f777 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,7 @@ static int daemonize = 0; void *tall_mgr_ctx; /* every 6 hours means 365*4 = 1460 rom writes per year (max) */ -#define TEMP_TIMER_SECS (6 * 3600) +#define SENSOR_TIMER_SECS (6 * 3600) /* every 1 hours means 365*24 = 8760 rom writes per year (max) */ #define HOURS_TIMER_SECS (1 * 3600) @@ -62,54 +63,97 @@ void *tall_mgr_ctx; static struct lc15bts_mgr_instance manager = { .config_file = "lc15bts-mgr.cfg", .temp = { - .supply_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .supply_temp_limit = { + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, .soc_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, .fpga_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, - .logrf_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .rmsdet_limit = { + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, .ocxo_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, - .tx0_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .tx0_temp_limit = { + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, - .tx1_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .tx1_temp_limit = { + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -20, }, .pa0_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -40, }, .pa1_limit = { - .thresh_warn = 60, - .thresh_crit = 78, + .thresh_warn_max = 70, + .thresh_crit_max = 85, + .thresh_warn_min = -10, + .thresh_crit_min = -40, + } + }, + .volt = { + .supply_volt_limit = { + .thresh_warn_max = 28, + .thresh_crit_max = 30, + .thresh_warn_min = 20, + .thresh_crit_min = 18, + } + }, + .vswr = { + .tx0_vswr_limit = { + .thresh_warn_max = 3, + .thresh_crit_max = 5, + .thresh_warn_min = 0, + .thresh_crit_min = 0, }, + .tx1_vswr_limit = { + .thresh_warn_max = 3, + .thresh_crit_max = 5, + .thresh_warn_min = 0, + .thresh_crit_min = 0, + } + }, + .state = { .action_warn = 0, - .action_crit = TEMP_ACT_PA0_OFF | TEMP_ACT_PA1_OFF, + .action_crit = SENSOR_ACT_PA0_OFF | SENSOR_ACT_PA1_OFF, .state = STATE_NORMAL, } }; -static struct osmo_timer_list temp_timer; -static void check_temp_timer_cb(void *unused) +static struct osmo_timer_list sensor_timer; +static void check_sensor_timer_cb(void *unused) { lc15bts_check_temp(no_rom_write); - - osmo_timer_schedule(&temp_timer, TEMP_TIMER_SECS, 0); + lc15bts_check_power(no_rom_write); + lc15bts_check_vswr(no_rom_write); + osmo_timer_schedule(&sensor_timer, SENSOR_TIMER_SECS, 0); } static struct osmo_timer_list hours_timer; @@ -169,6 +213,8 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: lc15bts_check_temp(no_rom_write); + lc15bts_check_power(no_rom_write); + lc15bts_check_vswr(no_rom_write); lc15bts_update_hours(no_rom_write); exit(0); break; @@ -222,11 +268,13 @@ static int mgr_log_init(void) int main(int argc, char **argv) { + void *tall_msgb_ctx; int rc; - + pthread_t tid; tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); - msgb_talloc_ctx_init(tall_mgr_ctx, 0); + tall_msgb_ctx = talloc_named_const(tall_mgr_ctx, 1, "msgb"); + msgb_set_talloc_ctx(tall_msgb_ctx); mgr_log_init(); @@ -254,8 +302,8 @@ int main(int argc, char **argv) } /* start temperature check timer */ - temp_timer.cb = check_temp_timer_cb; - check_temp_timer_cb(NULL); + sensor_timer.cb = check_sensor_timer_cb; + check_sensor_timer_cb(NULL); /* start operational hours timer */ hours_timer.cb = hours_timer_cb; @@ -271,14 +319,15 @@ int main(int argc, char **argv) if (rc < 0) { exit(3); } - /* handle broadcast messages for ipaccess-find */ if (lc15bts_mgr_nl_init() != 0) exit(3); - /* Initialize the temperature control */ - lc15bts_mgr_temp_init(&manager); + /* Initialize the sensor control */ + lc15bts_mgr_sensor_init(&manager); + + lc15bts_mgr_led_init(&manager); if (lc15bts_mgr_calib_init(&manager) != 0) exit(3); @@ -291,7 +340,6 @@ int main(int argc, char **argv) } } - while (1) { log_reset_context(); osmo_select_main(0); diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr.h b/src/osmo-bts-litecell15/misc/lc15bts_mgr.h index 98bd7010..97eb602c 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_mgr.h +++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr.h @@ -9,6 +9,39 @@ #include +enum BLINK_PATTERN { + BLINK_PATTERN_POWER_ON = 0, //hardware set + BLINK_PATTERN_INIT, + BLINK_PATTERN_NORMAL, + BLINK_PATTERN_BSC_DOWN, + BLINK_PATTERN_BTS_DOWN, + BLINK_PATTERN_PA1_OFF, + BLINK_PATTERN_SUPPLY_LOW, + BLINK_PATTERN_SUPPLY_MIN, + BLINK_PATTERN_VSWR_HIGH, + BLINK_PATTERN_HIGH_TEMP, + BLINK_PATTERN_MAX_TEMP, + BLINK_PATTERN_FLASH_ALL, + BLINK_PATTERN_MAX_ITEM +}; + +#define BLINK_PATTERN_COMMAND {\ + "set red; sleep 5",\ + "set orange; sleep 5",\ + "set green; sleep 0.5; set off; sleep 0.5",\ + "set green; sleep 0.5; set red; sleep 0.5",\ + "set orange; sleep 0.5; set red; sleep 0.5",\ + "set green; sleep 0.5; set off; sleep 2.5",\ + "set orange; sleep 0.5; set off; sleep 2.5",\ + "set red; sleep 0.5; set off; sleep 2.5",\ + "set red; sleep 0.5; set green; sleep 0.5; set orange; sleep 0.5",\ + "set orange; sleep 2.5; set off; sleep 0.5",\ + "set red; sleep 2.5; set off; sleep 0.5",\ + "set red; sleep 0.1; set off; sleep 0.1; set red; sleep 0.1; set off; sleep 0.1; set red; sleep 0.1; set off; sleep 0.1;"\ + "set orange; sleep 0.1; set off; sleep 0.1; set orange; sleep 0.1; set off; sleep 0.1; set orange; sleep 0.1; set off; sleep 0.1;" \ + "set green; sleep 0.1; set off; sleep 0.1; set green; sleep 0.1; set off; sleep 0.1; set green; sleep 0.1; set off; sleep 0.1"\ +} + enum { DTEMP, DFW, @@ -19,38 +52,68 @@ enum { // TODO NTQD: Define new actions like reducing output power, limit ARM core speed, shutdown second TRX/PA, ... enum { #if 0 - TEMP_ACT_PWR_CONTRL = 0x1, + SENSOR_ACT_PWR_CONTRL = 0x1, #endif - TEMP_ACT_PA0_OFF = 0x2, - TEMP_ACT_PA1_OFF = 0x4, - TEMP_ACT_BTS_SRV_OFF = 0x10, + SENSOR_ACT_PA0_OFF = 0x2, + SENSOR_ACT_PA1_OFF = 0x4, + SENSOR_ACT_BTS_SRV_OFF = 0x10, }; /* actions only for normal state */ enum { #if 0 - TEMP_ACT_NORM_PW_CONTRL = 0x1, + SENSOR_ACT_NORM_PW_CONTRL = 0x1, #endif - TEMP_ACT_NORM_PA0_ON = 0x2, - TEMP_ACT_NORM_PA1_ON = 0x4, - TEMP_ACT_NORM_BTS_SRV_ON= 0x10, + SENSOR_ACT_NORM_PA0_ON = 0x2, + SENSOR_ACT_NORM_PA1_ON = 0x4, + SENSOR_ACT_NORM_BTS_SRV_ON= 0x10, }; -enum lc15bts_temp_state { +enum lc15bts_sensor_state { STATE_NORMAL, /* Everything is fine */ STATE_WARNING_HYST, /* Go back to normal next? */ STATE_WARNING, /* We are above the warning threshold */ STATE_CRITICAL, /* We have an issue. Wait for below warning */ }; +struct lc15bts_alarms{ + int high_temp; + int max_temp; + int supply_low; + int supply_min; + int high_vswr; +}; + +struct lc15bts_led{ + char *name; + char *fullname; + char *path; +}; + /** * Temperature Limits. We separate from a threshold * that will generate a warning and one that is so * severe that an action will be taken. */ struct lc15bts_temp_limit { - int thresh_warn; - int thresh_crit; + int thresh_warn_max; + int thresh_crit_max; + int thresh_warn_min; + int thresh_crit_min; +}; + +struct lc15bts_volt_limit { + int thresh_warn_max; + int thresh_crit_max; + int thresh_warn_min; + int thresh_crit_min; +}; + +struct lc15bts_vswr_limit { + int thresh_warn_max; + int thresh_crit_max; + int thresh_warn_min; + int thresh_crit_min; }; enum mgr_vty_node { @@ -59,38 +122,52 @@ enum mgr_vty_node { ACT_NORM_NODE, ACT_WARN_NODE, ACT_CRIT_NODE, - LIMIT_SUPPLY_NODE, + LIMIT_SUPPLY_TEMP_NODE, LIMIT_SOC_NODE, LIMIT_FPGA_NODE, - LIMIT_LOGRF_NODE, + LIMIT_RMSDET_NODE, LIMIT_OCXO_NODE, - LIMIT_TX0_NODE, - LIMIT_TX1_NODE, + LIMIT_TX0_TEMP_NODE, + LIMIT_TX1_TEMP_NODE, LIMIT_PA0_NODE, LIMIT_PA1_NODE, + LIMIT_SUPPLY_VOLT_NODE, + LIMIT_TX0_VSWR_NODE, + LIMIT_TX1_VSWR_NODE, }; struct lc15bts_mgr_instance { const char *config_file; struct { - int action_norm; - int action_warn; - int action_crit; - - enum lc15bts_temp_state state; - - struct lc15bts_temp_limit supply_limit; + struct lc15bts_temp_limit supply_temp_limit; struct lc15bts_temp_limit soc_limit; struct lc15bts_temp_limit fpga_limit; - struct lc15bts_temp_limit logrf_limit; + struct lc15bts_temp_limit rmsdet_limit; struct lc15bts_temp_limit ocxo_limit; - struct lc15bts_temp_limit tx0_limit; - struct lc15bts_temp_limit tx1_limit; + struct lc15bts_temp_limit tx0_temp_limit; + struct lc15bts_temp_limit tx1_temp_limit; struct lc15bts_temp_limit pa0_limit; struct lc15bts_temp_limit pa1_limit; } temp; + struct { + struct lc15bts_volt_limit supply_volt_limit; + } volt; + + struct { + struct lc15bts_vswr_limit tx0_vswr_limit; + struct lc15bts_vswr_limit tx1_vswr_limit; + } vswr; + + struct { + int action_norm; + int action_warn; + int action_crit; + + enum lc15bts_sensor_state state; + } state; + struct { int state; int calib_from_loop; @@ -101,9 +178,11 @@ struct lc15bts_mgr_instance { int lc15bts_mgr_vty_init(void); int lc15bts_mgr_parse_config(struct lc15bts_mgr_instance *mgr); int lc15bts_mgr_nl_init(void); -int lc15bts_mgr_temp_init(struct lc15bts_mgr_instance *mgr); -const char *lc15bts_mgr_temp_get_state(enum lc15bts_temp_state state); - +int lc15bts_mgr_sensor_init(struct lc15bts_mgr_instance *mgr); +const char *lc15bts_mgr_sensor_get_state(enum lc15bts_sensor_state state); +extern void *led_light(void *arg); +extern void led_set(int pattern_id); +extern void led_test(void); int lc15bts_mgr_calib_init(struct lc15bts_mgr_instance *mgr); int lc15bts_mgr_calib_run(struct lc15bts_mgr_instance *mgr); diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c index 042fc875..5c555f60 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c @@ -27,6 +27,7 @@ #include "misc/lc15bts_misc.h" #include "misc/lc15bts_temp.h" #include "misc/lc15bts_power.h" +#include "limits.h" #include @@ -34,7 +35,8 @@ #include static struct lc15bts_mgr_instance *s_mgr; -static struct osmo_timer_list temp_ctrl_timer; +static struct osmo_timer_list sensor_ctrl_timer; +static struct osmo_timer_list led_ctrl_timer; static const struct value_string state_names[] = { { STATE_NORMAL, "NORMAL" }, @@ -44,12 +46,20 @@ static const struct value_string state_names[] = { { 0, NULL } }; -const char *lc15bts_mgr_temp_get_state(enum lc15bts_temp_state state) +static struct lc15bts_alarms alarms = { + .high_temp = 0, + .max_temp = 0, + .supply_low = 0, + .supply_min = 0, + .high_vswr = 0, +}; + +const char *lc15bts_mgr_sensor_get_state(enum lc15bts_sensor_state state) { return get_value_string(state_names, state); } -static int next_state(enum lc15bts_temp_state current_state, int critical, int warning) +static int next_state(enum lc15bts_sensor_state current_state, int critical, int warning) { int next_state = -1; switch (current_state) { @@ -85,7 +95,7 @@ static int next_state(enum lc15bts_temp_state current_state, int critical, int w static void handle_normal_actions(int actions) { /* switch on the PA */ - if (actions & TEMP_ACT_NORM_PA0_ON) { + if (actions & SENSOR_ACT_NORM_PA0_ON) { if (lc15bts_power_set(LC15BTS_POWER_PA0, 1) != 0) { LOGP(DTEMP, LOGL_ERROR, "Failed to switch on the PA #0\n"); @@ -95,7 +105,7 @@ static void handle_normal_actions(int actions) } } - if (actions & TEMP_ACT_NORM_PA1_ON) { + if (actions & SENSOR_ACT_NORM_PA1_ON) { if (lc15bts_power_set(LC15BTS_POWER_PA1, 1) != 0) { LOGP(DTEMP, LOGL_ERROR, "Failed to switch on the PA #1\n"); @@ -105,7 +115,7 @@ static void handle_normal_actions(int actions) } } - if (actions & TEMP_ACT_NORM_BTS_SRV_ON) { + if (actions & SENSOR_ACT_NORM_BTS_SRV_ON) { LOGP(DTEMP, LOGL_NOTICE, "Going to switch on the BTS service\n"); /* @@ -120,7 +130,7 @@ static void handle_normal_actions(int actions) static void handle_actions(int actions) { /* switch off the PA */ - if (actions & TEMP_ACT_PA1_OFF) { + if (actions & SENSOR_ACT_PA1_OFF) { if (lc15bts_power_set(LC15BTS_POWER_PA1, 0) != 0) { LOGP(DTEMP, LOGL_ERROR, "Failed to switch off the PA #1. Stop BTS?\n"); @@ -130,7 +140,7 @@ static void handle_actions(int actions) } } - if (actions & TEMP_ACT_PA0_OFF) { + if (actions & SENSOR_ACT_PA0_OFF) { if (lc15bts_power_set(LC15BTS_POWER_PA0, 0) != 0) { LOGP(DTEMP, LOGL_ERROR, "Failed to switch off the PA #0. Stop BTS?\n"); @@ -140,7 +150,7 @@ static void handle_actions(int actions) } } - if (actions & TEMP_ACT_BTS_SRV_OFF) { + if (actions & SENSOR_ACT_BTS_SRV_OFF) { LOGP(DTEMP, LOGL_NOTICE, "Going to switch off the BTS service\n"); /* @@ -161,36 +171,35 @@ static void handle_actions(int actions) */ static void execute_normal_act(struct lc15bts_mgr_instance *manager) { - LOGP(DTEMP, LOGL_NOTICE, "System is back to normal temperature.\n"); - handle_normal_actions(manager->temp.action_norm); + LOGP(DTEMP, LOGL_NOTICE, "System is back to normal state.\n"); + handle_normal_actions(manager->state.action_norm); } static void execute_warning_act(struct lc15bts_mgr_instance *manager) { - LOGP(DTEMP, LOGL_NOTICE, "System has reached temperature warning.\n"); - handle_actions(manager->temp.action_warn); + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning state.\n"); + handle_actions(manager->state.action_warn); } static void execute_critical_act(struct lc15bts_mgr_instance *manager) { LOGP(DTEMP, LOGL_NOTICE, "System has reached critical warning.\n"); - handle_actions(manager->temp.action_crit); + handle_actions(manager->state.action_crit); } -static void lc15bts_mgr_temp_handle(struct lc15bts_mgr_instance *manager, +static void lc15bts_mgr_sensor_handle(struct lc15bts_mgr_instance *manager, int critical, int warning) { - int new_state = next_state(manager->temp.state, critical, warning); + int new_state = next_state(manager->state.state, critical, warning); /* Nothing changed */ if (new_state < 0) return; - LOGP(DTEMP, LOGL_NOTICE, "Moving from state %s to %s.\n", - get_value_string(state_names, manager->temp.state), + get_value_string(state_names, manager->state.state), get_value_string(state_names, new_state)); - manager->temp.state = new_state; - switch (manager->temp.state) { + manager->state.state = new_state; + switch (manager->state.state) { case STATE_NORMAL: execute_normal_act(manager); break; @@ -206,163 +215,430 @@ static void lc15bts_mgr_temp_handle(struct lc15bts_mgr_instance *manager, }; } -static void temp_ctrl_check() +static void sensor_ctrl_check() { int rc; + int temp, volt, vswr; int warn_thresh_passed = 0; int crit_thresh_passed = 0; - LOGP(DTEMP, LOGL_DEBUG, "Going to check the temperature.\n"); + LOGP(DTEMP, LOGL_NOTICE, "Going to check the temperature.\n"); /* Read the current supply temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_SUPPLY); + rc = lc15bts_temp_get(LC15BTS_TEMP_SUPPLY, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the supply temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the supply temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.supply_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.supply_temp_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because supply temperature is over %d\n", s_mgr->temp.supply_temp_limit.thresh_warn_max); warn_thresh_passed = 1; - if (temp > s_mgr->temp.supply_limit.thresh_crit) + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.supply_temp_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because supply temperature is under %d\n", s_mgr->temp.supply_temp_limit.thresh_warn_min); + warn_thresh_passed = 1; + } + if (temp > s_mgr->temp.supply_temp_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because supply temperature is over %d\n", s_mgr->temp.supply_temp_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.supply_temp_limit.thresh_crit_min ){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because supply temperature is under %d\n", s_mgr->temp.supply_temp_limit.thresh_crit_min); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "Supply temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "Supply temperature is: %d\n", temp); } /* Read the current SoC temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_SOC); + rc = lc15bts_temp_get(LC15BTS_TEMP_SOC, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the SoC temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the SoC temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.soc_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.soc_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because SoC temperature is over %d\n", s_mgr->temp.soc_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.soc_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because SoC temperature is under %d\n", s_mgr->temp.soc_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.soc_limit.thresh_crit) + } + if (temp > s_mgr->temp.soc_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because SoC temperature is over %d\n", s_mgr->temp.soc_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.soc_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because SoC temperature is under %d\n", s_mgr->temp.soc_limit.thresh_crit_min); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "SoC temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "SoC temperature is: %d\n", temp); } /* Read the current fpga temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_FPGA); + rc = lc15bts_temp_get(LC15BTS_TEMP_FPGA, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the fpga temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the fpga temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.fpga_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.fpga_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because fpga temperature is over %d\n", s_mgr->temp.fpga_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.fpga_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because fpga temperature is under %d\n", s_mgr->temp.fpga_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.fpga_limit.thresh_crit) + } + if (temp > s_mgr->temp.fpga_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because fpga temperature is over %d\n", s_mgr->temp.fpga_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.fpga_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because fpga temperature is under %d\n", s_mgr->temp.fpga_limit.thresh_crit_min); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "FPGA temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "FPGA temperature is: %d\n", temp); } - /* Read the current RF log detector temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_LOGRF); + /* Read the current RMS detector temperature */ + rc = lc15bts_temp_get(LC15BTS_TEMP_RMSDET, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the RF log detector temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the RMS detector temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.logrf_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.rmsdet_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because RMS detector temperature is over %d\n", s_mgr->temp.rmsdet_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.rmsdet_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because RMS detector temperature is under %d\n", s_mgr->temp.rmsdet_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.logrf_limit.thresh_crit) + } + if (temp > s_mgr->temp.rmsdet_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because RMS detector temperature is over %d\n", s_mgr->temp.rmsdet_limit.thresh_crit_max); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "RF log detector temperature is: %d\n", temp); + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.rmsdet_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because RMS detector temperature is under %d\n", s_mgr->temp.rmsdet_limit.thresh_crit_min); + crit_thresh_passed = 1; + } + LOGP(DTEMP, LOGL_NOTICE, "RMS detector temperature is: %d\n", temp); } /* Read the current OCXO temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_OCXO); + rc = lc15bts_temp_get(LC15BTS_TEMP_OCXO, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the OCXO temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the OCXO temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.ocxo_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.ocxo_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because OCXO temperature is over %d\n", s_mgr->temp.ocxo_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.ocxo_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because OCXO temperature is under %d\n", s_mgr->temp.ocxo_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.ocxo_limit.thresh_crit) + } + if (temp > s_mgr->temp.ocxo_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because OCXO temperature is over %d\n", s_mgr->temp.ocxo_limit.thresh_crit_max); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "OCXO temperature is: %d\n", temp); + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.ocxo_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because OCXO temperature is under %d\n", s_mgr->temp.ocxo_limit.thresh_crit_min); + crit_thresh_passed = 1; + } + LOGP(DTEMP, LOGL_NOTICE, "OCXO temperature is: %d\n", temp); + } + + /* Read the current TX #0 temperature */ + rc = lc15bts_temp_get(LC15BTS_TEMP_TX0, &temp); + if (rc < 0) { + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the TX #0 temperature. rc=%n\n", rc); + warn_thresh_passed = crit_thresh_passed = 1; + } else { + temp = temp / 1000; + if (temp > s_mgr->temp.tx0_temp_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX0 temperature is over %d\n", s_mgr->temp.tx0_temp_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.tx0_temp_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX0 temperature is under %d\n", s_mgr->temp.tx0_temp_limit.thresh_warn_min); + warn_thresh_passed = 1; + } + if (temp > s_mgr->temp.tx0_temp_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX0 temperature is over %d\n", s_mgr->temp.tx0_temp_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.tx0_temp_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX0 temperature is under %d\n", s_mgr->temp.tx0_temp_limit.thresh_crit_min); + crit_thresh_passed = 1; + } + LOGP(DTEMP, LOGL_NOTICE, "TX #0 temperature is: %d\n", temp); } /* Read the current TX #1 temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_TX0); + rc = lc15bts_temp_get(LC15BTS_TEMP_TX1, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the TX #0 temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the TX #1 temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.tx0_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.tx1_temp_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX1 temperature is over %d\n", s_mgr->temp.tx1_temp_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.tx1_temp_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX1 temperature is under %d\n", s_mgr->temp.tx1_temp_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.tx0_limit.thresh_crit) + } + if (temp > s_mgr->temp.tx1_temp_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX1 temperature is over %d\n", s_mgr->temp.tx1_temp_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.tx1_temp_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX1 temperature is under %d\n", s_mgr->temp.tx1_temp_limit.thresh_crit_min); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "TX #0 temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "TX #1 temperature is: %d\n", temp); } - /* Read the current TX #2 temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_TX1); + /* Read the current PA #0 temperature */ + rc = lc15bts_temp_get(LC15BTS_TEMP_PA0, &temp); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the TX #1 temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the PA #0 temperature. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.tx1_limit.thresh_warn) + temp = temp / 1000; + if (temp > s_mgr->temp.pa0_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because PA0 temperature because is over %d\n", s_mgr->temp.pa0_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.pa0_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because PA0 temperature because is under %d\n", s_mgr->temp.pa0_limit.thresh_warn_min); warn_thresh_passed = 1; - if (temp > s_mgr->temp.tx1_limit.thresh_crit) + } + if (temp > s_mgr->temp.pa0_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because PA0 temperature because is over %d\n", s_mgr->temp.pa0_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.pa0_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because PA0 temperature because is under %d\n", s_mgr->temp.pa0_limit.thresh_crit_min); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "TX #1 temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "PA #0 temperature is: %d\n", temp); } /* Read the current PA #1 temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_PA0); + rc = lc15bts_temp_get(LC15BTS_TEMP_PA1, &temp); + if (rc < 0) { + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the PA #1 temperature. rc=%n\n", rc); + warn_thresh_passed = crit_thresh_passed = 1; + } else { + temp = temp / 1000; + if (temp > s_mgr->temp.pa1_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because PA1 temperature is over %d\n", s_mgr->temp.pa1_limit.thresh_warn_max); + warn_thresh_passed = 1; + alarms.high_temp = 1; + } + if (temp < s_mgr->temp.pa1_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because PA1 temperature is under %d\n", s_mgr->temp.pa1_limit.thresh_warn_min); + warn_thresh_passed = 1; + } + if (temp > s_mgr->temp.pa1_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because PA1 temperature is over %d\n", s_mgr->temp.pa1_limit.thresh_crit_max); + crit_thresh_passed = 1; + alarms.max_temp = 1; + } + if (temp < s_mgr->temp.pa1_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because PA1 temperature is under %d\n", s_mgr->temp.pa1_limit.thresh_crit_min); + crit_thresh_passed = 1; + } + LOGP(DTEMP, LOGL_NOTICE, "PA #1 temperature is: %d\n", temp); + } + + /* Read the current PA-supply voltage */ + rc = lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, LC15BTS_POWER_VOLTAGE, &volt); + if (rc < 0) { + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the PA-supply voltage. rc=%n\n", rc); + warn_thresh_passed = crit_thresh_passed = 1; + } else { + volt = volt / 1000; + if (volt > s_mgr->volt.supply_volt_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because supply voltage is over %d\n", s_mgr->volt.supply_volt_limit.thresh_warn_max); + warn_thresh_passed = 1; + } + if (volt < s_mgr->volt.supply_volt_limit.thresh_warn_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because supply voltage is under %d\n", s_mgr->volt.supply_volt_limit.thresh_warn_min); + warn_thresh_passed = 1; + alarms.supply_low = 1; + } + if (volt > s_mgr->volt.supply_volt_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because supply voltage is over %d\n", s_mgr->volt.supply_volt_limit.thresh_crit_max); + crit_thresh_passed = 1; + } + if (volt < s_mgr->volt.supply_volt_limit.thresh_crit_min){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because supply voltage is under %d\n", s_mgr->volt.supply_volt_limit.thresh_crit_min); + crit_thresh_passed = 1; + alarms.supply_min = 1; + } + LOGP(DTEMP, LOGL_NOTICE, "PA-supply voltage is: %d\n", volt); + } + + /* Read the current VSWR of TRX0 */ + rc = lc15bts_vswr_get(LC15BTS_VSWR_TX0, &vswr); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the PA #0 temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the VSWR of TRX0. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.pa0_limit.thresh_warn) + vswr = vswr / 1000; + if (vswr > s_mgr->vswr.tx0_vswr_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX0 VSWR is over %d\n", s_mgr->vswr.tx0_vswr_limit.thresh_warn_max); warn_thresh_passed = 1; - if (temp > s_mgr->temp.pa0_limit.thresh_crit) + alarms.high_vswr = 1; + } + if (vswr > s_mgr->vswr.tx0_vswr_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX0 VSWR is over %d\n", s_mgr->vswr.tx0_vswr_limit.thresh_crit_max); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "PA #0 temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "VSWR of TRX0 is: %d\n", vswr); } - /* Read the current PA #2 temperature */ - rc = lc15bts_temp_get(LC15BTS_TEMP_PA1); + /* Read the current VSWR of TRX1 */ + rc = lc15bts_vswr_get(LC15BTS_VSWR_TX1, &vswr); if (rc < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to read the PA #1 temperature. rc=%d\n", rc); + LOGP(DTEMP, LOGL_NOTICE, + "Failed to read the VSWR of TRX1. rc=%n\n", rc); warn_thresh_passed = crit_thresh_passed = 1; } else { - int temp = rc / 1000; - if (temp > s_mgr->temp.pa1_limit.thresh_warn) + vswr = vswr / 1000; + if (vswr > s_mgr->vswr.tx1_vswr_limit.thresh_warn_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached warning because TX1 VSWR is over %d\n", s_mgr->vswr.tx1_vswr_limit.thresh_warn_max); warn_thresh_passed = 1; - if (temp > s_mgr->temp.pa1_limit.thresh_crit) + alarms.high_vswr = 1; + } + if (vswr > s_mgr->vswr.tx1_vswr_limit.thresh_crit_max){ + LOGP(DTEMP, LOGL_NOTICE, "System has reached critical because TX1 VSWR is over %d\n", s_mgr->vswr.tx1_vswr_limit.thresh_crit_max); crit_thresh_passed = 1; - LOGP(DTEMP, LOGL_DEBUG, "PA #1 temperature is: %d\n", temp); + } + LOGP(DTEMP, LOGL_NOTICE, "VSWR of TRX1 is: %d\n", vswr); } - lc15bts_mgr_temp_handle(s_mgr, crit_thresh_passed, warn_thresh_passed); + select_led_pattern(s_mgr); + lc15bts_mgr_sensor_handle(s_mgr, crit_thresh_passed, warn_thresh_passed); +} + +static void sensor_ctrl_check_cb(void *unused) +{ + sensor_ctrl_check(); + /* Check every minute? XXX make it configurable! */ + osmo_timer_schedule(&sensor_ctrl_timer, 60, 0); +} + +int lc15bts_mgr_sensor_init(struct lc15bts_mgr_instance *mgr) +{ + s_mgr = mgr; + sensor_ctrl_timer.cb = sensor_ctrl_check_cb; + sensor_ctrl_check_cb(NULL); + return 0; +} + +int check_sensor_led_pattern(uint8_t *led) +{ + if(alarms.high_temp == 1) + led[BLINK_PATTERN_HIGH_TEMP] = 1; + if(alarms.max_temp == 1) + led[BLINK_PATTERN_MAX_TEMP] = 1; + if(alarms.supply_low == 1) + led[BLINK_PATTERN_SUPPLY_LOW] = 1; + if(alarms.supply_min == 1) + led[BLINK_PATTERN_SUPPLY_MIN] = 1; + if(alarms.high_vswr == 1) + led[BLINK_PATTERN_VSWR_HIGH] = 1; + return 0; +} + +static uint8_t led_priority[] = { + BLINK_PATTERN_INIT, + BLINK_PATTERN_SUPPLY_MIN, + BLINK_PATTERN_MAX_TEMP, + BLINK_PATTERN_BTS_DOWN, + BLINK_PATTERN_BSC_DOWN, + BLINK_PATTERN_SUPPLY_LOW, + BLINK_PATTERN_HIGH_TEMP, + BLINK_PATTERN_VSWR_HIGH, + BLINK_PATTERN_PA1_OFF, + BLINK_PATTERN_NORMAL +}; + +void select_led_pattern(struct lc15bts_mgr_instance *mgr) +{ + int i; + uint8_t led[BLINK_PATTERN_MAX_ITEM] = {0}; + + led[BLINK_PATTERN_NORMAL] = 1; + + check_sensor_led_pattern(led); + + /* + if(pa_is_ready(&lc->controller[1]) == 0) + led[BLINK_PATTERN_PA1_OFF] = 1; + + check_mss_led_pattern(led); + + */ + //check by priority + for(i = 0; i < sizeof(led_priority)/sizeof(uint8_t); i++) + { + if(led[led_priority[i]] == 1) + { + led_set(led_priority[i]); + break; + } + } } -static void temp_ctrl_check_cb(void *unused) +static void led_ctrl_check_cb(void *unused) { - temp_ctrl_check(); - /* Check every two minutes? XXX make it configurable! */ - osmo_timer_schedule(&temp_ctrl_timer, 2 * 60, 0); + led_ctrl_check(); + /* Check every minute? XXX make it configurable! */ + osmo_timer_schedule(&led_ctrl_timer, 60, 0); } -int lc15bts_mgr_temp_init(struct lc15bts_mgr_instance *mgr) +int lc15bts_mgr_led_init(struct lc15bts_mgr_instance *mgr) { s_mgr = mgr; - temp_ctrl_timer.cb = temp_ctrl_check_cb; - temp_ctrl_check_cb(NULL); + led_ctrl_timer.cb = led_ctrl_check_cb; + led_ctrl_check_cb(NULL); return 0; } diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c index 280c9c75..8bee1853 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c @@ -64,15 +64,18 @@ static int go_to_parent(struct vty *vty) case ACT_NORM_NODE: case ACT_WARN_NODE: case ACT_CRIT_NODE: - case LIMIT_SUPPLY_NODE: + case LIMIT_SUPPLY_TEMP_NODE: case LIMIT_SOC_NODE: case LIMIT_FPGA_NODE: - case LIMIT_LOGRF_NODE: + case LIMIT_RMSDET_NODE: case LIMIT_OCXO_NODE: - case LIMIT_TX0_NODE: - case LIMIT_TX1_NODE: + case LIMIT_TX0_TEMP_NODE: + case LIMIT_TX1_TEMP_NODE: case LIMIT_PA0_NODE: case LIMIT_PA1_NODE: + case LIMIT_SUPPLY_VOLT_NODE: + case LIMIT_TX0_VSWR_NODE: + case LIMIT_TX1_VSWR_NODE: vty->node = MGR_NODE; break; default: @@ -88,15 +91,18 @@ static int is_config_node(struct vty *vty, int node) case ACT_NORM_NODE: case ACT_WARN_NODE: case ACT_CRIT_NODE: - case LIMIT_SUPPLY_NODE: + case LIMIT_SUPPLY_TEMP_NODE: case LIMIT_SOC_NODE: case LIMIT_FPGA_NODE: - case LIMIT_LOGRF_NODE: + case LIMIT_RMSDET_NODE: case LIMIT_OCXO_NODE: - case LIMIT_TX0_NODE: - case LIMIT_TX1_NODE: + case LIMIT_TX0_TEMP_NODE: + case LIMIT_TX1_TEMP_NODE: case LIMIT_PA0_NODE: case LIMIT_PA1_NODE: + case LIMIT_SUPPLY_VOLT_NODE: + case LIMIT_TX0_VSWR_NODE: + case LIMIT_TX1_VSWR_NODE: return 1; default: return 0; @@ -122,25 +128,25 @@ static struct cmd_node mgr_node = { static struct cmd_node act_norm_node = { ACT_NORM_NODE, - "%s(action-normal)# ", + "%s(actions-normal)# ", 1, }; static struct cmd_node act_warn_node = { ACT_WARN_NODE, - "%s(action-warn)# ", + "%s(actions-warn)# ", 1, }; static struct cmd_node act_crit_node = { ACT_CRIT_NODE, - "%s(action-critical)# ", + "%s(actions-critical)# ", 1, }; -static struct cmd_node limit_supply_node = { - LIMIT_SUPPLY_NODE, - "%s(limit-supply)# ", +static struct cmd_node limit_supply_temp_node = { + LIMIT_SUPPLY_TEMP_NODE, + "%s(limit-supply-temp)# ", 1, }; @@ -156,9 +162,9 @@ static struct cmd_node limit_fpga_node = { 1, }; -static struct cmd_node limit_logrf_node = { - LIMIT_LOGRF_NODE, - "%s(limit-logrf)# ", +static struct cmd_node limit_rmsdet_node = { + LIMIT_RMSDET_NODE, + "%s(limit-rmsdet)# ", 1, }; @@ -168,14 +174,14 @@ static struct cmd_node limit_ocxo_node = { 1, }; -static struct cmd_node limit_tx0_node = { - LIMIT_TX0_NODE, - "%s(limit-tx0)# ", +static struct cmd_node limit_tx0_temp_node = { + LIMIT_TX0_TEMP_NODE, + "%s(limit-tx0-temp)# ", 1, }; -static struct cmd_node limit_tx1_node = { - LIMIT_TX1_NODE, - "%s(limit-tx1)# ", +static struct cmd_node limit_tx1_temp_node = { + LIMIT_TX1_TEMP_NODE, + "%s(limit-tx1-temp)# ", 1, }; static struct cmd_node limit_pa0_node = { @@ -188,6 +194,21 @@ static struct cmd_node limit_pa1_node = { "%s(limit-pa1)# ", 1, }; +static struct cmd_node limit_supply_volt_node = { + LIMIT_SUPPLY_VOLT_NODE, + "%s(limit-supply-volt)# ", + 1, +}; +static struct cmd_node limit_tx0_vswr_node = { + LIMIT_TX0_VSWR_NODE, + "%s(limit-tx0-vswr)# ", + 1, +}; +static struct cmd_node limit_tx1_vswr_node = { + LIMIT_TX1_VSWR_NODE, + "%s(limit-tx1-vswr)# ", + 1, +}; DEFUN(cfg_mgr, cfg_mgr_cmd, "lc15bts-mgr", @@ -201,51 +222,86 @@ static void write_temp_limit(struct vty *vty, const char *name, struct lc15bts_temp_limit *limit) { vty_out(vty, " %s%s", name, VTY_NEWLINE); - vty_out(vty, " threshold warning %d%s", - limit->thresh_warn, VTY_NEWLINE); - vty_out(vty, " threshold critical %d%s", - limit->thresh_crit, VTY_NEWLINE); + vty_out(vty, " threshold warning max %d%s", + limit->thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " threshold critical max %d%s", + limit->thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " threshold warning min %d%s", + limit->thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " threshold critical min %d%s", + limit->thresh_crit_min, VTY_NEWLINE); +} + +static void write_volt_limit(struct vty *vty, const char *name, + struct lc15bts_volt_limit *limit) +{ + vty_out(vty, " %s%s", name, VTY_NEWLINE); + vty_out(vty, " threshold warning max %d%s", + limit->thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " threshold critical max %d%s", + limit->thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " threshold warning min %d%s", + limit->thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " threshold critical min %d%s", + limit->thresh_crit_min, VTY_NEWLINE); +} + +static void write_vswr_limit(struct vty *vty, const char *name, + struct lc15bts_vswr_limit *limit) +{ + vty_out(vty, " %s%s", name, VTY_NEWLINE); + vty_out(vty, " threshold warning max %d%s", + limit->thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " threshold critical max %d%s", + limit->thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " threshold warning min %d%s", + limit->thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " threshold critical min %d%s", + limit->thresh_crit_min, VTY_NEWLINE); } static void write_norm_action(struct vty *vty, const char *name, int actions) { vty_out(vty, " %s%s", name, VTY_NEWLINE); vty_out(vty, " %spa0-on%s", - (actions & TEMP_ACT_NORM_PA0_ON) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_NORM_PA0_ON) ? "" : "no ", VTY_NEWLINE); vty_out(vty, " %spa1-on%s", - (actions & TEMP_ACT_NORM_PA1_ON) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_NORM_PA1_ON) ? "" : "no ", VTY_NEWLINE); vty_out(vty, " %sbts-service-on%s", - (actions & TEMP_ACT_NORM_BTS_SRV_ON) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_NORM_BTS_SRV_ON) ? "" : "no ", VTY_NEWLINE); } static void write_action(struct vty *vty, const char *name, int actions) { vty_out(vty, " %s%s", name, VTY_NEWLINE); vty_out(vty, " %spa0-off%s", - (actions & TEMP_ACT_PA0_OFF) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_PA0_OFF) ? "" : "no ", VTY_NEWLINE); vty_out(vty, " %spa1-off%s", - (actions & TEMP_ACT_PA1_OFF) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_PA1_OFF) ? "" : "no ", VTY_NEWLINE); vty_out(vty, " %sbts-service-off%s", - (actions & TEMP_ACT_BTS_SRV_OFF) ? "" : "no ", VTY_NEWLINE); + (actions & SENSOR_ACT_BTS_SRV_OFF) ? "" : "no ", VTY_NEWLINE); } static int config_write_mgr(struct vty *vty) { vty_out(vty, "lc15bts-mgr%s", VTY_NEWLINE); - write_temp_limit(vty, "limits supply", &s_mgr->temp.supply_limit); + write_temp_limit(vty, "limits supply temp", &s_mgr->temp.supply_temp_limit); write_temp_limit(vty, "limits soc", &s_mgr->temp.soc_limit); write_temp_limit(vty, "limits fpga", &s_mgr->temp.fpga_limit); - write_temp_limit(vty, "limits logrf", &s_mgr->temp.logrf_limit); + write_temp_limit(vty, "limits rmsdet", &s_mgr->temp.rmsdet_limit); write_temp_limit(vty, "limits ocxo", &s_mgr->temp.ocxo_limit); - write_temp_limit(vty, "limits tx0", &s_mgr->temp.tx0_limit); - write_temp_limit(vty, "limits tx1", &s_mgr->temp.tx1_limit); + write_temp_limit(vty, "limits tx0 temp", &s_mgr->temp.tx0_temp_limit); + write_temp_limit(vty, "limits tx1 temp", &s_mgr->temp.tx1_temp_limit); write_temp_limit(vty, "limits pa0", &s_mgr->temp.pa0_limit); write_temp_limit(vty, "limits pa1", &s_mgr->temp.pa1_limit); + write_volt_limit(vty, "limits supply volt", &s_mgr->volt.supply_volt_limit); + write_vswr_limit(vty, "limits tx0 vswr", &s_mgr->vswr.tx0_vswr_limit); + write_vswr_limit(vty, "limits tx1 vswr", &s_mgr->vswr.tx1_vswr_limit); - write_norm_action(vty, "actions normal", s_mgr->temp.action_norm); - write_action(vty, "actions warn", s_mgr->temp.action_warn); - write_action(vty, "actions critical", s_mgr->temp.action_crit); + write_norm_action(vty, "actions normal", s_mgr->state.action_norm); + write_action(vty, "actions warn", s_mgr->state.action_warn); + write_action(vty, "actions critical", s_mgr->state.action_crit); return CMD_SUCCESS; } @@ -255,7 +311,7 @@ static int config_write_dummy(struct vty *vty) return CMD_SUCCESS; } -#define CFG_LIMIT(name, expl, switch_to, variable) \ +#define CFG_LIMIT_TEMP(name, expl, switch_to, variable) \ DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ "limits " #name, \ "Configure Limits\n" expl) \ @@ -265,32 +321,77 @@ DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ return CMD_SUCCESS; \ } -CFG_LIMIT(supply, "SUPPLY\n", LIMIT_SUPPLY_NODE, supply_limit) -CFG_LIMIT(soc, "SOC\n", LIMIT_SOC_NODE, soc_limit) -CFG_LIMIT(fpga, "FPGA\n", LIMIT_FPGA_NODE, fpga_limit) -CFG_LIMIT(logrf, "LOGRF\n", LIMIT_LOGRF_NODE, logrf_limit) -CFG_LIMIT(ocxo, "OCXO\n", LIMIT_OCXO_NODE, ocxo_limit) -CFG_LIMIT(tx0, "TX0\n", LIMIT_TX0_NODE, tx0_limit) -CFG_LIMIT(tx1, "TX1\n", LIMIT_TX1_NODE, tx1_limit) -CFG_LIMIT(pa0, "PA0\n", LIMIT_PA0_NODE, pa0_limit) -CFG_LIMIT(pa1, "PA1\n", LIMIT_PA1_NODE, pa1_limit) -#undef CFG_LIMIT +CFG_LIMIT_TEMP(supply_temp, "SUPPLY TEMP\n", LIMIT_SUPPLY_TEMP_NODE, supply_temp_limit) +CFG_LIMIT_TEMP(soc, "SOC\n", LIMIT_SOC_NODE, soc_limit) +CFG_LIMIT_TEMP(fpga, "FPGA\n", LIMIT_FPGA_NODE, fpga_limit) +CFG_LIMIT_TEMP(rmsdet, "RMSDET\n", LIMIT_RMSDET_NODE, rmsdet_limit) +CFG_LIMIT_TEMP(ocxo, "OCXO\n", LIMIT_OCXO_NODE, ocxo_limit) +CFG_LIMIT_TEMP(tx0_temp, "TX0 TEMP\n", LIMIT_TX0_TEMP_NODE, tx0_temp_limit) +CFG_LIMIT_TEMP(tx1_temp, "TX1 TEMP\n", LIMIT_TX1_TEMP_NODE, tx1_temp_limit) +CFG_LIMIT_TEMP(pa0, "PA0\n", LIMIT_PA0_NODE, pa0_limit) +CFG_LIMIT_TEMP(pa1, "PA1\n", LIMIT_PA1_NODE, pa1_limit) +#undef CFG_LIMIT_TEMP + +#define CFG_LIMIT_VOLT(name, expl, switch_to, variable) \ +DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ + "limits " #name, \ + "Configure Limits\n" expl) \ +{ \ + vty->node = switch_to; \ + vty->index = &s_mgr->volt.variable; \ + return CMD_SUCCESS; \ +} + +CFG_LIMIT_VOLT(supply_volt, "SUPPLY VOLT\n", LIMIT_SUPPLY_VOLT_NODE, supply_volt_limit) +#undef CFG_LIMIT_VOLT + +#define CFG_LIMIT_VSWR(name, expl, switch_to, variable) \ +DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ + "limits " #name, \ + "Configure Limits\n" expl) \ +{ \ + vty->node = switch_to; \ + vty->index = &s_mgr->vswr.variable; \ + return CMD_SUCCESS; \ +} + +CFG_LIMIT_VSWR(tx0_vswr, "TX0 VSWR\n", LIMIT_TX0_VSWR_NODE, tx0_vswr_limit) +CFG_LIMIT_VSWR(tx1_vswr, "TX1 VSWR\n", LIMIT_TX1_VSWR_NODE, tx1_vswr_limit) +#undef CFG_LIMIT_VSWR -DEFUN(cfg_limit_warning, cfg_thresh_warning_cmd, - "threshold warning <0-200>", +DEFUN(cfg_limit_warning_max, cfg_thresh_warning_max_cmd, + "threshold warning max <-200-200>", "Threshold to reach\n" "Warning level\n" "Range\n") { struct lc15bts_temp_limit *limit = vty->index; - limit->thresh_warn = atoi(argv[0]); + limit->thresh_warn_max = atoi(argv[0]); return CMD_SUCCESS; } -DEFUN(cfg_limit_crit, cfg_thresh_crit_cmd, - "threshold critical <0-200>", +DEFUN(cfg_limit_crit_max, cfg_thresh_crit_max_cmd, + "threshold critical max <-200-200>", "Threshold to reach\n" "Severe level\n" "Range\n") { struct lc15bts_temp_limit *limit = vty->index; - limit->thresh_crit = atoi(argv[0]); + limit->thresh_crit_max = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_limit_warning_min, cfg_thresh_warning_min_cmd, + "threshold warning min <-200-200>", + "Threshold to reach\n" "Warning level\n" "Range\n") +{ + struct lc15bts_temp_limit *limit = vty->index; + limit->thresh_warn_min = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_limit_crit_min, cfg_thresh_crit_min_cmd, + "threshold critical min <-200-200>", + "Threshold to reach\n" "Severe level\n" "Range\n") +{ + struct lc15bts_temp_limit *limit = vty->index; + limit->thresh_crit_min = atoi(argv[0]); return CMD_SUCCESS; } @@ -300,7 +401,7 @@ DEFUN(cfg_action_##name, cfg_action_##name##_cmd, \ "Configure Actions\n" expl) \ { \ vty->node = switch_to; \ - vty->index = &s_mgr->temp.variable; \ + vty->index = &s_mgr->state.variable; \ return CMD_SUCCESS; \ } CFG_ACTION(normal, "Normal Actions\n", ACT_NORM_NODE, action_norm) @@ -313,7 +414,7 @@ DEFUN(cfg_action_pa0_on, cfg_action_pa0_on_cmd, "Switch the Power Amplifier #0 on\n") { int *action = vty->index; - *action |= TEMP_ACT_NORM_PA0_ON; + *action |= SENSOR_ACT_NORM_PA0_ON; return CMD_SUCCESS; } @@ -322,7 +423,7 @@ DEFUN(cfg_no_action_pa0_on, cfg_no_action_pa0_on_cmd, NO_STR "Switch the Power Amplifieri #0 on\n") { int *action = vty->index; - *action &= ~TEMP_ACT_NORM_PA0_ON; + *action &= ~SENSOR_ACT_NORM_PA0_ON; return CMD_SUCCESS; } @@ -331,7 +432,7 @@ DEFUN(cfg_action_pa1_on, cfg_action_pa1_on_cmd, "Switch the Power Amplifier #1 on\n") { int *action = vty->index; - *action |= TEMP_ACT_NORM_PA1_ON; + *action |= SENSOR_ACT_NORM_PA1_ON; return CMD_SUCCESS; } @@ -340,7 +441,7 @@ DEFUN(cfg_no_action_pa1_on, cfg_no_action_pa1_on_cmd, NO_STR "Switch the Power Amplifieri #1 on\n") { int *action = vty->index; - *action &= ~TEMP_ACT_NORM_PA1_ON; + *action &= ~SENSOR_ACT_NORM_PA1_ON; return CMD_SUCCESS; } @@ -349,7 +450,7 @@ DEFUN(cfg_action_bts_srv_on, cfg_action_bts_srv_on_cmd, "Start the systemd lc15bts.service\n") { int *action = vty->index; - *action |= TEMP_ACT_NORM_BTS_SRV_ON; + *action |= SENSOR_ACT_NORM_BTS_SRV_ON; return CMD_SUCCESS; } @@ -358,7 +459,7 @@ DEFUN(cfg_no_action_bts_srv_on, cfg_no_action_bts_srv_on_cmd, NO_STR "Start the systemd lc15bts.service\n") { int *action = vty->index; - *action &= ~TEMP_ACT_NORM_BTS_SRV_ON; + *action &= ~SENSOR_ACT_NORM_BTS_SRV_ON; return CMD_SUCCESS; } @@ -367,7 +468,7 @@ DEFUN(cfg_action_pa0_off, cfg_action_pa0_off_cmd, "Switch the Power Amplifier #0 off\n") { int *action = vty->index; - *action |= TEMP_ACT_PA0_OFF; + *action |= SENSOR_ACT_PA0_OFF; return CMD_SUCCESS; } @@ -376,7 +477,7 @@ DEFUN(cfg_no_action_pa0_off, cfg_no_action_pa0_off_cmd, NO_STR "Do not switch off the Power Amplifier #0\n") { int *action = vty->index; - *action &= ~TEMP_ACT_PA0_OFF; + *action &= ~SENSOR_ACT_PA0_OFF; return CMD_SUCCESS; } @@ -385,7 +486,7 @@ DEFUN(cfg_action_pa1_off, cfg_action_pa1_off_cmd, "Switch the Power Amplifier #1 off\n") { int *action = vty->index; - *action |= TEMP_ACT_PA1_OFF; + *action |= SENSOR_ACT_PA1_OFF; return CMD_SUCCESS; } @@ -394,7 +495,7 @@ DEFUN(cfg_no_action_pa1_off, cfg_no_action_pa1_off_cmd, NO_STR "Do not switch off the Power Amplifier #1\n") { int *action = vty->index; - *action &= ~TEMP_ACT_PA1_OFF; + *action &= ~SENSOR_ACT_PA1_OFF; return CMD_SUCCESS; } @@ -403,7 +504,7 @@ DEFUN(cfg_action_bts_srv_off, cfg_action_bts_srv_off_cmd, "Stop the systemd lc15bts.service\n") { int *action = vty->index; - *action |= TEMP_ACT_BTS_SRV_OFF; + *action |= SENSOR_ACT_BTS_SRV_OFF; return CMD_SUCCESS; } @@ -412,75 +513,169 @@ DEFUN(cfg_no_action_bts_srv_off, cfg_no_action_bts_srv_off_cmd, NO_STR "Stop the systemd lc15bts.service\n") { int *action = vty->index; - *action &= ~TEMP_ACT_BTS_SRV_OFF; + *action &= ~SENSOR_ACT_BTS_SRV_OFF; return CMD_SUCCESS; } DEFUN(show_mgr, show_mgr_cmd, "show manager", SHOW_STR "Display information about the manager") { + int temp, volt, current, power, vswr; vty_out(vty, "Temperature control state: %s%s", - lc15bts_mgr_temp_get_state(s_mgr->temp.state), VTY_NEWLINE); + lc15bts_mgr_sensor_get_state(s_mgr->state.state), VTY_NEWLINE); vty_out(vty, "Current Temperatures%s", VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_SUPPLY, &temp); vty_out(vty, " Main Supply : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_SUPPLY) / 1000.0f, + temp/ 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_SOC, &temp); vty_out(vty, " SoC : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_SOC) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_FPGA, &temp); vty_out(vty, " FPGA : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_FPGA) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); - vty_out(vty, " LogRF : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_LOGRF) / 1000.0f, + lc15bts_temp_get(LC15BTS_TEMP_RMSDET, &temp); + vty_out(vty, " RMSDet : %f Celcius%s", + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_OCXO, &temp); vty_out(vty, " OCXO : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_OCXO) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_TX0, &temp); vty_out(vty, " TX 0 : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_TX0) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_TX1, &temp); vty_out(vty, " TX 1 : %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_TX1) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_PA0, &temp); vty_out(vty, " Power Amp #0: %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_PA0) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); + lc15bts_temp_get(LC15BTS_TEMP_PA1, &temp); vty_out(vty, " Power Amp #1: %f Celcius%s", - lc15bts_temp_get(LC15BTS_TEMP_PA1) / 1000.0f, + temp / 1000.0f, VTY_NEWLINE); vty_out(vty, "Power Status%s", VTY_NEWLINE); + lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, + LC15BTS_POWER_VOLTAGE, &volt); + lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, + LC15BTS_POWER_CURRENT, ¤t); + lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, + LC15BTS_POWER_POWER, &power); vty_out(vty, " Main Supply : ON [%6.2f Vdc, %4.2f A, %6.2f W]%s", - lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, - LC15BTS_POWER_VOLTAGE)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, - LC15BTS_POWER_CURRENT)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, - LC15BTS_POWER_POWER)/1000000.0f, + volt /1000.0f, + current /1000.0f, + power /1000000.0f, VTY_NEWLINE); + lc15bts_power_sensor_get(LC15BTS_POWER_PA0, + LC15BTS_POWER_VOLTAGE, &volt); + lc15bts_power_sensor_get(LC15BTS_POWER_PA0, + LC15BTS_POWER_CURRENT, ¤t); + lc15bts_power_sensor_get(LC15BTS_POWER_PA0, + LC15BTS_POWER_POWER, &power); vty_out(vty, " Power Amp #0: %s [%6.2f Vdc, %4.2f A, %6.2f W]%s", lc15bts_power_get(LC15BTS_POWER_PA0) ? "ON " : "OFF", - lc15bts_power_sensor_get(LC15BTS_POWER_PA0, - LC15BTS_POWER_VOLTAGE)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_PA0, - LC15BTS_POWER_CURRENT)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_PA0, - LC15BTS_POWER_POWER)/1000000.0f, + volt /1000.0f, + current /1000.0f, + power /1000000.0f, VTY_NEWLINE); + lc15bts_power_sensor_get(LC15BTS_POWER_PA1, + LC15BTS_POWER_VOLTAGE, &volt); + lc15bts_power_sensor_get(LC15BTS_POWER_PA1, + LC15BTS_POWER_CURRENT, ¤t); + lc15bts_power_sensor_get(LC15BTS_POWER_PA1, + LC15BTS_POWER_POWER, &power); vty_out(vty, " Power Amp #1: %s [%6.2f Vdc, %4.2f A, %6.2f W]%s", lc15bts_power_get(LC15BTS_POWER_PA1) ? "ON " : "OFF", - lc15bts_power_sensor_get(LC15BTS_POWER_PA1, - LC15BTS_POWER_VOLTAGE)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_PA1, - LC15BTS_POWER_CURRENT)/1000.0f, - lc15bts_power_sensor_get(LC15BTS_POWER_PA1, - LC15BTS_POWER_POWER)/1000000.0f, + volt /1000.0f, + current /1000.0f, + power /1000000.0f, + VTY_NEWLINE); + vty_out(vty, "VSWR Status%s", VTY_NEWLINE); + lc15bts_vswr_get(LC15BTS_VSWR_TX0, &vswr); + vty_out(vty, " VSWR TX 0: %f %s", + vswr / 1000.0f, + VTY_NEWLINE); + lc15bts_vswr_get(LC15BTS_VSWR_TX1, &vswr); + vty_out(vty, " VSWR TX 1: %f %s", + vswr / 1000.0f, VTY_NEWLINE); return CMD_SUCCESS; } +DEFUN(show_thresh, show_thresh_cmd, "show thresholds", + SHOW_STR "Display information about the thresholds") +{ + vty_out(vty, "Temperature limits%s", VTY_NEWLINE); + vty_out(vty, " Main supply%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.supply_temp_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.supply_temp_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " SoC%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.soc_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.soc_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.soc_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.soc_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " FPGA%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.fpga_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.fpga_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.fpga_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.fpga_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " RMSDet%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.rmsdet_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.rmsdet_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.rmsdet_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.rmsdet_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " OCXO%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.ocxo_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.ocxo_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.ocxo_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.ocxo_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " TX0%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.tx0_temp_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.tx0_temp_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.tx0_temp_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.tx0_temp_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " TX1%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.tx1_temp_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.tx1_temp_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.tx1_temp_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.tx1_temp_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " PA0%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.pa0_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.pa0_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.pa0_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.pa0_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, " PA1%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->temp.pa1_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->temp.pa1_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->temp.pa1_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->temp.pa1_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, "Power limits%s", VTY_NEWLINE); + vty_out(vty, " Main supply%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " Warning min : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_min, VTY_NEWLINE); + vty_out(vty, " Critical min : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_min, VTY_NEWLINE); + vty_out(vty, "VSWR limits%s", VTY_NEWLINE); + vty_out(vty, " TX0%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->vswr.tx0_vswr_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->vswr.tx0_vswr_limit.thresh_warn_max, VTY_NEWLINE); + vty_out(vty, " TX1%s", VTY_NEWLINE); + vty_out(vty, " Critical max : %d%s",s_mgr->vswr.tx1_vswr_limit.thresh_crit_max, VTY_NEWLINE); + vty_out(vty, " Warning max : %d%s",s_mgr->vswr.tx1_vswr_limit.thresh_warn_max, VTY_NEWLINE); + + return CMD_SUCCESS; +} + DEFUN(calibrate_clock, calibrate_clock_cmd, "calibrate clock", "Calibration commands\n" @@ -495,8 +690,10 @@ DEFUN(calibrate_clock, calibrate_clock_cmd, static void register_limit(int limit) { - install_element(limit, &cfg_thresh_warning_cmd); - install_element(limit, &cfg_thresh_crit_cmd); + install_element(limit, &cfg_thresh_warning_max_cmd); + install_element(limit, &cfg_thresh_crit_max_cmd); + install_element(limit, &cfg_thresh_warning_min_cmd); + install_element(limit, &cfg_thresh_crit_min_cmd); } static void register_normal_action(int act) @@ -524,6 +721,7 @@ int lc15bts_mgr_vty_init(void) vty_init(&vty_info); install_element_ve(&show_mgr_cmd); + install_element_ve(&show_thresh_cmd); install_element(ENABLE_NODE, &calibrate_clock_cmd); @@ -532,10 +730,10 @@ int lc15bts_mgr_vty_init(void) vty_install_default(MGR_NODE); /* install the limit nodes */ - install_node(&limit_supply_node, config_write_dummy); - install_element(MGR_NODE, &cfg_limit_supply_cmd); - register_limit(LIMIT_SUPPLY_NODE); - vty_install_default(LIMIT_SUPPLY_NODE); + install_node(&limit_supply_temp_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_supply_temp_cmd); + register_limit(LIMIT_SUPPLY_TEMP_NODE); + vty_install_default(LIMIT_SUPPLY_TEMP_NODE); install_node(&limit_soc_node, config_write_dummy); install_element(MGR_NODE, &cfg_limit_soc_cmd); @@ -547,25 +745,25 @@ int lc15bts_mgr_vty_init(void) register_limit(LIMIT_FPGA_NODE); vty_install_default(LIMIT_FPGA_NODE); - install_node(&limit_logrf_node, config_write_dummy); - install_element(MGR_NODE, &cfg_limit_logrf_cmd); - register_limit(LIMIT_LOGRF_NODE); - vty_install_default(LIMIT_LOGRF_NODE); + install_node(&limit_rmsdet_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_rmsdet_cmd); + register_limit(LIMIT_RMSDET_NODE); + vty_install_default(LIMIT_RMSDET_NODE); install_node(&limit_ocxo_node, config_write_dummy); install_element(MGR_NODE, &cfg_limit_ocxo_cmd); register_limit(LIMIT_OCXO_NODE); vty_install_default(LIMIT_OCXO_NODE); - install_node(&limit_tx0_node, config_write_dummy); - install_element(MGR_NODE, &cfg_limit_tx0_cmd); - register_limit(LIMIT_TX0_NODE); - vty_install_default(LIMIT_TX0_NODE); + install_node(&limit_tx0_temp_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_tx0_temp_cmd); + register_limit(LIMIT_TX0_TEMP_NODE); + vty_install_default(LIMIT_TX0_TEMP_NODE); - install_node(&limit_tx1_node, config_write_dummy); - install_element(MGR_NODE, &cfg_limit_tx1_cmd); - register_limit(LIMIT_TX1_NODE); - vty_install_default(LIMIT_TX1_NODE); + install_node(&limit_tx1_temp_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_tx1_temp_cmd); + register_limit(LIMIT_TX1_TEMP_NODE); + vty_install_default(LIMIT_TX1_TEMP_NODE); install_node(&limit_pa0_node, config_write_dummy); install_element(MGR_NODE, &cfg_limit_pa0_cmd); @@ -577,6 +775,21 @@ int lc15bts_mgr_vty_init(void) register_limit(LIMIT_PA1_NODE); vty_install_default(LIMIT_PA1_NODE); + install_node(&limit_supply_volt_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_supply_volt_cmd); + register_limit(LIMIT_SUPPLY_VOLT_NODE); + vty_install_default(LIMIT_SUPPLY_VOLT_NODE); + + install_node(&limit_tx0_vswr_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_tx0_vswr_cmd); + register_limit(LIMIT_TX0_VSWR_NODE); + vty_install_default(LIMIT_TX0_VSWR_NODE); + + install_node(&limit_tx1_vswr_node, config_write_dummy); + install_element(MGR_NODE, &cfg_limit_tx1_vswr_cmd); + register_limit(LIMIT_TX1_VSWR_NODE); + vty_install_default(LIMIT_TX1_VSWR_NODE); + /* install the normal node */ install_node(&act_norm_node, config_write_dummy); install_element(MGR_NODE, &cfg_action_normal_cmd); diff --git a/src/osmo-bts-litecell15/misc/lc15bts_misc.c b/src/osmo-bts-litecell15/misc/lc15bts_misc.c index 5ff8e312..0aeb3842 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_misc.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_misc.c @@ -41,11 +41,13 @@ #include #include +#include "lc15bts_mgr.h" #include "btsconfig.h" #include "lc15bts_misc.h" #include "lc15bts_par.h" #include "lc15bts_mgr.h" #include "lc15bts_temp.h" +#include "lc15bts_power.h" /********************************************************************* * Temperature handling @@ -58,7 +60,7 @@ static const struct { enum lc15bts_par ee_par; } temp_data[] = { { - .name = "supply", + .name = "supply_temp", .has_max = 1, .sensor = LC15BTS_TEMP_SUPPLY, .ee_par = LC15BTS_PAR_TEMP_SUPPLY_MAX, @@ -74,22 +76,22 @@ static const struct { .ee_par = LC15BTS_PAR_TEMP_FPGA_MAX, }, { - .name = "logrf", + .name = "rmsdet", .has_max = 1, - .sensor = LC15BTS_TEMP_LOGRF, - .ee_par = LC15BTS_PAR_TEMP_LOGRF_MAX, + .sensor = LC15BTS_TEMP_RMSDET, + .ee_par = LC15BTS_PAR_TEMP_RMSDET_MAX, }, { .name = "ocxo", .has_max = 1, .sensor = LC15BTS_TEMP_OCXO, .ee_par = LC15BTS_PAR_TEMP_OCXO_MAX, }, { - .name = "tx0", + .name = "tx0_temp", .has_max = 0, .sensor = LC15BTS_TEMP_TX0, .ee_par = LC15BTS_PAR_TEMP_TX0_MAX, }, { - .name = "tx1", + .name = "tx1_temp", .has_max = 0, .sensor = LC15BTS_TEMP_TX1, .ee_par = LC15BTS_PAR_TEMP_TX1_MAX, @@ -106,6 +108,41 @@ static const struct { } }; +static const struct { + const char *name; + int has_max; + enum lc15bts_power_source sensor_source; + enum lc15bts_power_type sensor_type; + enum lc15bts_par ee_par; +} power_data[] = { + { + .name = "supply_volt", + .has_max = 1, + .sensor_source = LC15BTS_POWER_SUPPLY, + .sensor_type = LC15BTS_POWER_VOLTAGE, + .ee_par = LC15BTS_PAR_VOLT_SUPPLY_MAX, + } +}; + +static const struct { + const char *name; + int has_max; + enum lc15bts_vswr_sensor sensor; + enum lc15bts_par ee_par; +} vswr_data[] = { + { + .name = "tx0_vswr", + .has_max = 0, + .sensor = LC15BTS_VSWR_TX0, + .ee_par = LC15BTS_PAR_VSWR_TX0_MAX, + }, { + .name = "tx1_vswr", + .has_max = 0, + .sensor = LC15BTS_VSWR_TX1, + .ee_par = LC15BTS_PAR_VSWR_TX1_MAX, + } +}; + void lc15bts_check_temp(int no_rom_write) { int temp_old[ARRAY_SIZE(temp_data)]; @@ -117,7 +154,7 @@ void lc15bts_check_temp(int no_rom_write) rc = lc15bts_par_get_int(temp_data[i].ee_par, &ret); temp_old[i] = ret * 1000; - temp_cur[i] = lc15bts_temp_get(temp_data[i].sensor); + lc15bts_temp_get(temp_data[i].sensor, &temp_cur[i]); if (temp_cur[i] < 0 && temp_cur[i] > -1000) { LOGP(DTEMP, LOGL_ERROR, "Error reading temperature (%d)\n", temp_data[i].sensor); continue; @@ -143,6 +180,80 @@ void lc15bts_check_temp(int no_rom_write) } } +void lc15bts_check_power(int no_rom_write) +{ + int power_old[ARRAY_SIZE(power_data)]; + int power_cur[ARRAY_SIZE(power_data)]; + int i, rc; + + for (i = 0; i < ARRAY_SIZE(power_data); i++) { + int ret; + rc = lc15bts_par_get_int(power_data[i].ee_par, &ret); + power_old[i] = ret * 1000; + + lc15bts_power_sensor_get(power_data[i].sensor_source, power_data[i].sensor_type, &power_cur[i]); + if (power_cur[i] < 0 && power_cur[i] > -1000) { + LOGP(DTEMP, LOGL_ERROR, "Error reading power (%d) (%d)\n", power_data[i].sensor_source, power_data[i].sensor_type); + continue; + } + + LOGP(DTEMP, LOGL_DEBUG, "Current %s power: %d.%d C\n", + power_data[i].name, power_cur[i]/1000, power_cur[i]%1000); + + if (power_cur[i] > power_old[i]) { + LOGP(DTEMP, LOGL_NOTICE, "New maximum %s " + "power: %d.%d C\n", power_data[i].name, + power_cur[i]/1000, power_old[i]%1000); + + if (!no_rom_write) { + rc = lc15bts_par_set_int(power_data[i].ee_par, + power_cur[i]/1000); + if (rc < 0) + LOGP(DTEMP, LOGL_ERROR, "error writing new %s " + "max power %d (%s)\n", power_data[i].name, + rc, strerror(errno)); + } + } + } +} + +void lc15bts_check_vswr(int no_rom_write) +{ + int vswr_old[ARRAY_SIZE(vswr_data)]; + int vswr_cur[ARRAY_SIZE(vswr_data)]; + int i, rc; + + for (i = 0; i < ARRAY_SIZE(vswr_data); i++) { + int ret; + rc = lc15bts_par_get_int(vswr_data[i].ee_par, &ret); + vswr_old[i] = ret * 1000; + + lc15bts_vswr_get(vswr_data[i].sensor, &vswr_cur[i]); + if (vswr_cur[i] < 0 && vswr_cur[i] > -1000) { + LOGP(DTEMP, LOGL_ERROR, "Error reading vswr (%d)\n", vswr_data[i].sensor); + continue; + } + + LOGP(DTEMP, LOGL_DEBUG, "Current %s vswr: %d.%d C\n", + vswr_data[i].name, vswr_cur[i]/1000, vswr_cur[i]%1000); + + if (vswr_cur[i] > vswr_old[i]) { + LOGP(DTEMP, LOGL_NOTICE, "New maximum %s " + "vswr: %d.%d C\n", vswr_data[i].name, + vswr_cur[i]/1000, vswr_old[i]%1000); + + if (!no_rom_write) { + rc = lc15bts_par_set_int(vswr_data[i].ee_par, + vswr_cur[i]/1000); + if (rc < 0) + LOGP(DTEMP, LOGL_ERROR, "error writing new %s " + "max vswr %d (%s)\n", vswr_data[i].name, + rc, strerror(errno)); + } + } + } +} + /********************************************************************* * Hours handling *********************************************************************/ @@ -235,3 +346,213 @@ int lc15bts_firmware_reload(enum lc15bts_firmware_type type) } return 0; } + +/********************************************************************************** +THIS SHOULD BE IN ANOTHER FILE +***********************************************************************************/ + +int lc15bts_led_write(char *path, char *str) +{ + int fd; + + if((fd = open(path, O_WRONLY)) == -1) + { + return 0; + } + + write(fd, str, strlen(str)+1); + close(fd); + return 1; +} + +static struct lc15bts_led led_entries[] = { + { + .name = "led0", + .fullname = "led red", + .path = "/var/lc15/leds/led0/brightness" + }, + { + .name = "led1", + .fullname = "led green", + .path = "/var/lc15/leds/led1/brightness" + } +}; + +char *blink_pattern_command[] = BLINK_PATTERN_COMMAND; +static char *current_blink_pattern; +static uint8_t reload_now = 0; + +void led_set_red() +{ + lc15bts_led_write(led_entries[0].path, "1"); + lc15bts_led_write(led_entries[1].path, "0"); +} + +void led_set_green() +{ + lc15bts_led_write(led_entries[0].path, "0"); + lc15bts_led_write(led_entries[1].path, "1"); +} + +void led_set_orange() +{ + LOGP(DTEMP, LOGL_NOTICE,"LED orange called new code\n"); + lc15bts_led_write(led_entries[0].path, "1"); + lc15bts_led_write(led_entries[1].path, "1"); +} + +void led_set_off() +{ + lc15bts_led_write(led_entries[0].path, "0"); + lc15bts_led_write(led_entries[1].path, "0"); +} + +void led_sleep(double sec) +{ + int i; + long msec = (long )(sec*1000); + + for(i = 0; i < msec; i++) + { + if(reload_now == 1) + { + reload_now = 0; + break; + } + usleep(1000); + } +} +void call_led_cmd(char *cmdstr) +{ + double sec; + + if(strstr(cmdstr, "set red") != NULL) + { + led_set_red(); + } + else if(strstr(cmdstr, "set green") != NULL) + { + led_set_green(); + } + else if(strstr(cmdstr, "set orange") != NULL) + { + led_set_orange(); + } + else if(strstr(cmdstr, "set off") != NULL) + { + led_set_off(); + } + else if(strstr(cmdstr, "sleep") != NULL) + { + sec = atof(cmdstr+6); + led_sleep(sec); + } + else + { + LOGP(DTEMP, LOGL_ERROR,"Command not found\n"); + } +} + +void led_light_pattern(char *pattern) +{ + char str[1024]; + char *pstr; + char *sep; + + strcpy(str, pattern); + pstr = str; + while((sep = strsep(&pstr, ";")) != NULL) + { + call_led_cmd(sep); + } +} + +void led_light_loop(int times) +{ + int i; + + if(times == 0) + { + for(;;) + led_light_pattern(current_blink_pattern); + } + else + { + for(i = 0; i < times; i++) + led_light_pattern(current_blink_pattern); + } +} + +void led_set_pattern(char *pattern) +{ + if(current_blink_pattern != pattern) + { + current_blink_pattern = pattern; + reload_now = 1; + LOGP(DTEMP, LOGL_NOTICE,"LED pattern changed to %s\n", pattern); + } +} + + +/*** led interface ***/ + +void led_set(int pattern_id) +{ + LOGP(DTEMP, LOGL_NOTICE, "blink pattern command : %d\n", pattern_id); + led_set_pattern(blink_pattern_command[pattern_id]); +} + +void led_ctrl_check() +{ + led_light_loop(0); +} + +void led_test(void) +{ + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_NORMAL); + led_light_loop(12); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_BSC_DOWN); + led_light_loop(12); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_BTS_DOWN); + led_light_loop(12); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_PA1_OFF); + led_light_loop(3); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_SUPPLY_LOW); + led_light_loop(6); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_SUPPLY_MIN); + led_light_loop(6); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_VSWR_HIGH); + led_light_loop(8); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_HIGH_TEMP); + led_light_loop(6); + + led_set(BLINK_PATTERN_FLASH_ALL); + led_light_loop(1); + led_set(BLINK_PATTERN_MAX_TEMP); + led_light_loop(6); + + LOGP(DTEMP, LOGL_NOTICE,"LED test finished\n"); +} diff --git a/src/osmo-bts-litecell15/misc/lc15bts_misc.h b/src/osmo-bts-litecell15/misc/lc15bts_misc.h index 4c3a862a..a2972200 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_misc.h +++ b/src/osmo-bts-litecell15/misc/lc15bts_misc.h @@ -3,7 +3,7 @@ #include -void lc15bts_check_temp(int no_rom_write); +void lc15bts_check_sensor(int no_rom_write); int lc15bts_update_hours(int no_rom_write); diff --git a/src/osmo-bts-litecell15/misc/lc15bts_par.c b/src/osmo-bts-litecell15/misc/lc15bts_par.c index 3d80e67d..5c2643b3 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_par.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_par.c @@ -40,18 +40,21 @@ #define FACTORY_ROM_PATH "/mnt/rom/factory" -#define USER_ROM_PATH "/mnt/rom/user" +#define USER_ROM_PATH "/var/run/lc15bts-mgr" const struct value_string lc15bts_par_names[_NUM_LC15BTS_PAR+1] = { { LC15BTS_PAR_TEMP_SUPPLY_MAX, "temp-supply-max" }, { LC15BTS_PAR_TEMP_SOC_MAX, "temp-soc-max" }, { LC15BTS_PAR_TEMP_FPGA_MAX, "temp-fpga-max" }, - { LC15BTS_PAR_TEMP_LOGRF_MAX, "temp-logrf-max" }, + { LC15BTS_PAR_TEMP_RMSDET_MAX, "temp-rmsdet-max" }, { LC15BTS_PAR_TEMP_OCXO_MAX, "temp-ocxo-max" }, { LC15BTS_PAR_TEMP_TX0_MAX, "temp-tx0-max" }, { LC15BTS_PAR_TEMP_TX1_MAX, "temp-tx1-max" }, { LC15BTS_PAR_TEMP_PA0_MAX, "temp-pa0-max" }, { LC15BTS_PAR_TEMP_PA1_MAX, "temp-pa1-max" }, + { LC15BTS_PAR_VOLT_SUPPLY_MAX, "volt-supply-max" }, + { LC15BTS_PAR_VSWR_TX0_MAX, "vswr-tx0-max" }, + { LC15BTS_PAR_VSWR_TX1_MAX, "vswr-tx1-max" }, { LC15BTS_PAR_SERNR, "serial-nr" }, { LC15BTS_PAR_HOURS, "hours-running" }, { LC15BTS_PAR_BOOTS, "boot-count" }, @@ -65,12 +68,15 @@ int lc15bts_par_is_int(enum lc15bts_par par) case LC15BTS_PAR_TEMP_SUPPLY_MAX: case LC15BTS_PAR_TEMP_SOC_MAX: case LC15BTS_PAR_TEMP_FPGA_MAX: - case LC15BTS_PAR_TEMP_LOGRF_MAX: + case LC15BTS_PAR_TEMP_RMSDET_MAX: case LC15BTS_PAR_TEMP_OCXO_MAX: case LC15BTS_PAR_TEMP_TX0_MAX: case LC15BTS_PAR_TEMP_TX1_MAX: case LC15BTS_PAR_TEMP_PA0_MAX: case LC15BTS_PAR_TEMP_PA1_MAX: + case LC15BTS_PAR_VOLT_SUPPLY_MAX: + case LC15BTS_PAR_VSWR_TX0_MAX: + case LC15BTS_PAR_VSWR_TX1_MAX: case LC15BTS_PAR_SERNR: case LC15BTS_PAR_HOURS: case LC15BTS_PAR_BOOTS: diff --git a/src/osmo-bts-litecell15/misc/lc15bts_par.h b/src/osmo-bts-litecell15/misc/lc15bts_par.h index c50a69fc..9b3179ae 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_par.h +++ b/src/osmo-bts-litecell15/misc/lc15bts_par.h @@ -7,12 +7,15 @@ enum lc15bts_par { LC15BTS_PAR_TEMP_SUPPLY_MAX, LC15BTS_PAR_TEMP_SOC_MAX, LC15BTS_PAR_TEMP_FPGA_MAX, - LC15BTS_PAR_TEMP_LOGRF_MAX, + LC15BTS_PAR_TEMP_RMSDET_MAX, LC15BTS_PAR_TEMP_OCXO_MAX, LC15BTS_PAR_TEMP_TX0_MAX, LC15BTS_PAR_TEMP_TX1_MAX, LC15BTS_PAR_TEMP_PA0_MAX, LC15BTS_PAR_TEMP_PA1_MAX, + LC15BTS_PAR_VOLT_SUPPLY_MAX, + LC15BTS_PAR_VSWR_TX0_MAX, + LC15BTS_PAR_VSWR_TX1_MAX, LC15BTS_PAR_SERNR, LC15BTS_PAR_HOURS, LC15BTS_PAR_BOOTS, diff --git a/src/osmo-bts-litecell15/misc/lc15bts_power.c b/src/osmo-bts-litecell15/misc/lc15bts_power.c index 5b01d36b..d145ce33 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_power.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_power.c @@ -52,7 +52,8 @@ static const char *power_sensor_type_str[_NUM_POWER_TYPES] = { int lc15bts_power_sensor_get( enum lc15bts_power_source source, - enum lc15bts_power_type type) + enum lc15bts_power_type type, + int *power) { char buf[PATH_MAX]; char pwrstr[10]; @@ -82,8 +83,8 @@ int lc15bts_power_sensor_get( return -EIO; } close(fd); - - return atoi(pwrstr); + *power = atoi(pwrstr); + return 0; } @@ -171,3 +172,39 @@ int lc15bts_power_get( return retVal; } + +static const char *vswr_devs[_NUM_VSWR_SENSORS] = { + [LC15BTS_VSWR_TX0] = "/var/lc15/vswr/tx0/vswr", + [LC15BTS_VSWR_TX1] = "/var/lc15/vswr/tx1/vswr", +}; + +int lc15bts_vswr_get(enum lc15bts_vswr_sensor sensor, int *vswr) +{ + char buf[PATH_MAX]; + char vswrstr[8]; + int fd, rc; + + if (sensor < 0 || sensor >= _NUM_VSWR_SENSORS) + return -EINVAL; + + snprintf(buf, sizeof(buf)-1, "%s", vswr_devs[sensor]); + buf[sizeof(buf)-1] = '\0'; + + fd = open(buf, O_RDONLY); + if (fd < 0) + return fd; + + rc = read(fd, vswrstr, sizeof(vswrstr)); + vswrstr[sizeof(vswrstr)-1] = '\0'; + if (rc < 0) { + close(fd); + return rc; + } + if (rc == 0) { + close(fd); + return -EIO; + } + close(fd); + *vswr = atoi(vswrstr); + return 0; +} diff --git a/src/osmo-bts-litecell15/misc/lc15bts_power.h b/src/osmo-bts-litecell15/misc/lc15bts_power.h index 8963b761..b48cfdcd 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_power.h +++ b/src/osmo-bts-litecell15/misc/lc15bts_power.h @@ -17,7 +17,8 @@ enum lc15bts_power_type { int lc15bts_power_sensor_get( enum lc15bts_power_source source, - enum lc15bts_power_type type); + enum lc15bts_power_type type, + int *volt); int lc15bts_power_set( enum lc15bts_power_source source, @@ -26,4 +27,12 @@ int lc15bts_power_set( int lc15bts_power_get( enum lc15bts_power_source source); +enum lc15bts_vswr_sensor { + LC15BTS_VSWR_TX0, + LC15BTS_VSWR_TX1, + _NUM_VSWR_SENSORS +}; + +int lc15bts_vswr_get(enum lc15bts_vswr_sensor sensor, int *vswr); + #endif diff --git a/src/osmo-bts-litecell15/misc/lc15bts_temp.c b/src/osmo-bts-litecell15/misc/lc15bts_temp.c index aa358547..217b16bb 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_temp.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_temp.c @@ -29,20 +29,19 @@ #include "lc15bts_temp.h" - static const char *temp_devs[_NUM_TEMP_SENSORS] = { - [LC15BTS_TEMP_SUPPLY] = "/var/lc15/temp/pa-supply/temp", - [LC15BTS_TEMP_SOC] = "/var/lc15/temp/cpu/temp", - [LC15BTS_TEMP_FPGA] = "/var/lc15/temp/fpga/temp", - [LC15BTS_TEMP_LOGRF] = "/var/lc15/temp/logrf/temp", - [LC15BTS_TEMP_OCXO] = "/var/lc15/temp/ocxo/temp", - [LC15BTS_TEMP_TX0] = "/var/lc15/temp/tx0/temp", - [LC15BTS_TEMP_TX1] = "/var/lc15/temp/tx1/temp", - [LC15BTS_TEMP_PA0] = "/var/lc15/temp/pa0/temp", - [LC15BTS_TEMP_PA1] = "/var/lc15/temp/pa1/temp", + [LC15BTS_TEMP_SUPPLY] = "/var/lc15/temp/pa-supply/temp", + [LC15BTS_TEMP_SOC] = "/var/lc15/temp/cpu/temp", + [LC15BTS_TEMP_FPGA] = "/var/lc15/temp/fpga/temp", + [LC15BTS_TEMP_RMSDET] = "/var/lc15/temp/rmsdet/temp", + [LC15BTS_TEMP_OCXO] = "/var/lc15/temp/ocxo/temp", + [LC15BTS_TEMP_TX0] = "/var/lc15/temp/tx0/temp", + [LC15BTS_TEMP_TX1] = "/var/lc15/temp/tx1/temp", + [LC15BTS_TEMP_PA0] = "/var/lc15/temp/pa0/temp", + [LC15BTS_TEMP_PA1] = "/var/lc15/temp/pa1/temp", }; -int lc15bts_temp_get(enum lc15bts_temp_sensor sensor) +int lc15bts_temp_get(enum lc15bts_temp_sensor sensor, int *temp) { char buf[PATH_MAX]; char tempstr[8]; @@ -69,7 +68,6 @@ int lc15bts_temp_get(enum lc15bts_temp_sensor sensor) return -EIO; } close(fd); - - return atoi(tempstr); + *temp = atoi(tempstr); + return 0; } - diff --git a/src/osmo-bts-litecell15/misc/lc15bts_temp.h b/src/osmo-bts-litecell15/misc/lc15bts_temp.h index aca8fe26..35d81f1b 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_temp.h +++ b/src/osmo-bts-litecell15/misc/lc15bts_temp.h @@ -5,7 +5,7 @@ enum lc15bts_temp_sensor { LC15BTS_TEMP_SUPPLY, LC15BTS_TEMP_SOC, LC15BTS_TEMP_FPGA, - LC15BTS_TEMP_LOGRF, + LC15BTS_TEMP_RMSDET, LC15BTS_TEMP_OCXO, LC15BTS_TEMP_TX0, LC15BTS_TEMP_TX1, @@ -22,6 +22,7 @@ enum lc15bts_temp_type { _NUM_TEMP_TYPES }; -int lc15bts_temp_get(enum lc15bts_temp_sensor sensor); +int lc15bts_temp_get(enum lc15bts_temp_sensor sensor, int *temp); + #endif -- cgit v1.2.3