From 3ecb2bb60472ea291a5f13b4babe6fd9a7fba028 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 21 Aug 2014 16:12:50 +0200 Subject: sysmobts: Initialize fd with an invalid fd Initialize the ucinfo with an invalid fd to prevent writing on fd=0 by accident. --- src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c index e3cd104b..e5a2c800 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c @@ -51,7 +51,8 @@ struct ucinfo { static struct uc ucontrol0 = { .id = 0, - .path = "/dev/ttyS0" + .path = "/dev/ttyS0", + .fd = -1, }; /********************************************************************** -- cgit v1.2.3 From b1ceb403630d093c364736def15b7c9f48f6fed0 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 31 Jul 2014 20:56:18 +0200 Subject: sysmobts: Read the model number and trx once from the device Use it for the ipaccess-find response and for the sysmobts classification code. This can be used by the vty in a second. --- src/osmo-bts-sysmo/misc/sysmobts_mgr.c | 44 +++++++++++++++++++++++++---- src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c | 17 ++--------- src/osmo-bts-sysmo/misc/sysmobts_misc.h | 3 ++ 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index 2864ec9b..eb15c63f 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -44,11 +44,44 @@ #include "misc/sysmobts_nl.h" #include "misc/sysmobts_par.h" +static int bts_type; +static int trx_number; + static int no_eeprom_write = 0; static int daemonize = 0; static const char *cfgfile = "sysmobts-mgr.cfg"; void *tall_mgr_ctx; + +static int classify_bts(void) +{ + int rc; + + rc = sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &bts_type); + if (rc < 0) { + fprintf(stderr, "Failed to get model number.\n"); + return -1; + } + + rc = sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &trx_number); + if (rc < 0) { + fprintf(stderr, "Failed to get the trx number.\n"); + return -1; + } + + return 0; +} + +int is_sbts2050(void) +{ + return bts_type == 2050; +} + +int is_sbts2050_trx(int trx) +{ + return trx_number == trx; +} + static struct osmo_timer_list temp_timer; static void check_temp_timer_cb(void *unused) { @@ -221,7 +254,6 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd, if (!fetched_info) { uint8_t mac[6]; - int val; /* fetch the MAC */ sysmobts_par_get_buf(SYSMOBTS_PAR_MAC, mac, sizeof(mac)); @@ -230,18 +262,16 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd, mac[3], mac[4], mac[5]); /* fetch the model and trx number */ - sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val); - switch(val) { + switch(bts_type) { case 0: case 0xffff: case 1002: model_name = "sysmoBTS 1002"; break; case 2050: - sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val); - if (val == 0) + if (trx_number == 0) model_name = "sysmoBTS 2050 (master)"; - else if (val == 1) + else if (trx_number == 1) model_name = "sysmoBTS 2050 (slave)"; else model_name = "sysmoBTS 2050 (unknown)"; @@ -322,6 +352,8 @@ int main(int argc, char **argv) msgb_set_talloc_ctx(tall_msgb_ctx); mgr_log_init(); + if (classify_bts() != 0) + exit(2); osmo_init_ignore_signals(); signal(SIGINT, &signal_handler); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c index e5a2c800..3d1db152 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c @@ -313,23 +313,10 @@ static void check_uctemp_timer_cb(void *data) void sbts2050_uc_initialize(void) { - int val; - - if (sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val) < 0) { - LOGP(DTEMP, LOGL_ERROR, - "Failed to get Model number\n"); - return; - } - - if (val != 2050) - return; - - if (sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val) < 0) { - LOGP(DTEMP, LOGL_ERROR, "Failed to get the TRX number\n"); + if (!is_sbts2050()) return; - } - if (val != 0) + if (!is_sbts2050_trx(0)) return; ucontrol0.fd = osmo_serial_init(ucontrol0.path, 115200); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h index f3b85c2c..baa39889 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h @@ -43,6 +43,9 @@ enum sysmobts_firmware_type { int sysmobts_firmware_reload(enum sysmobts_firmware_type type); +int is_sbts2050(void); +int is_sbts2050_trx(int); + void sbts2050_uc_check_temp(int *temp_pa, int *temp_board); void sbts2050_uc_set_power(int pmaster, int pslave, int ppa); int sbts2050_uc_get_status(enum sbts2050_status_rqt status); -- cgit v1.2.3 From 46c085d794d9c973528718b62caeb41443a53417 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 21 Aug 2014 16:12:30 +0200 Subject: sysmobts: Add is_sbts2050_master --- src/osmo-bts-sysmo/misc/sysmobts_mgr.c | 9 +++++++++ src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c | 5 +---- src/osmo-bts-sysmo/misc/sysmobts_misc.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index eb15c63f..f8b3302e 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -82,6 +82,15 @@ int is_sbts2050_trx(int trx) return trx_number == trx; } +int is_sbts2050_master(void) +{ + if (!is_sbts2050()) + return 0; + if (!is_sbts2050_trx(0)) + return 0; + return 1; +} + static struct osmo_timer_list temp_timer; static void check_temp_timer_cb(void *unused) { diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c index 3d1db152..ce1aaf8c 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c @@ -313,10 +313,7 @@ static void check_uctemp_timer_cb(void *data) void sbts2050_uc_initialize(void) { - if (!is_sbts2050()) - return; - - if (!is_sbts2050_trx(0)) + if (!is_sbts2050_master()) return; ucontrol0.fd = osmo_serial_init(ucontrol0.path, 115200); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h index baa39889..238095dd 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h @@ -45,6 +45,7 @@ int sysmobts_firmware_reload(enum sysmobts_firmware_type type); int is_sbts2050(void); int is_sbts2050_trx(int); +int is_sbts2050_master(void); void sbts2050_uc_check_temp(int *temp_pa, int *temp_board); void sbts2050_uc_set_power(int pmaster, int pslave, int ppa); -- cgit v1.2.3 From 4059e29a29039759c60624f87e45d35d922d88d1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 31 Jul 2014 21:16:57 +0200 Subject: sysmobts: Read the temperature sensors on the device Read the sensors that are always present and the ones that are only present on the sysmoBTS 2050. --- src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c index 50d8e152..92e1073e 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c @@ -96,6 +96,22 @@ DEFUN(cfg_mgr, cfg_mgr_cmd, DEFUN(show_mgr, show_mgr_cmd, "show manager", SHOW_STR "Display information about the manager") { + vty_out(vty, "Current Temperatures%s", VTY_NEWLINE); + vty_out(vty, " Digital: %f Celcius%s", + sysmobts_temp_get(SYSMOBTS_TEMP_DIGITAL, + SYSMOBTS_TEMP_INPUT) / 1000.0f, + VTY_NEWLINE); + vty_out(vty, " RF: %f Celcius%s", + sysmobts_temp_get(SYSMOBTS_TEMP_RF, + SYSMOBTS_TEMP_INPUT) / 1000.0f, + VTY_NEWLINE); + if (is_sbts2050_master()) { + int temp_pa, temp_board; + sbts2050_uc_check_temp(&temp_pa, &temp_board); + vty_out(vty, " sysmoBTS 2050 PA: %d Celcius%s", temp_pa, VTY_NEWLINE); + vty_out(vty, " sysmoBTS 2050 PA: %d CelciusC%s", temp_board, VTY_NEWLINE); + } + return CMD_SUCCESS; } -- cgit v1.2.3 From 5e1363071f9e9951985ba1a21196c5548350fafc Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 31 Jul 2014 22:12:56 +0200 Subject: sysmobts: Fix the power request result We want to know which componets are enabled and the voltage and current used by the components. --- src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c | 39 ++++++++++++++++------------- src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c | 23 +++++++++++++++++ src/osmo-bts-sysmo/misc/sysmobts_misc.h | 26 +++++++++++++------ 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c index ce1aaf8c..7de68954 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c @@ -28,6 +28,7 @@ #include #include +#include #ifdef BUILD_SBTS2050 #include @@ -203,41 +204,43 @@ err: /********************************************************************** * Get power status function *********************************************************************/ -int sbts2050_uc_get_status(enum sbts2050_status_rqt status) +int sbts2050_uc_get_status(struct sbts2050_power_status *status) { struct msgb *msg; const struct ucinfo info = { .id = SBTS2050_PWR_STATUS, }; rsppkt_t *response; - int val_status; + memset(status, 0, sizeof(*status)); msg = sbts2050_ucinfo_get(&ucontrol0, &info); if (msg == NULL) { LOGP(DTEMP, LOGL_ERROR, - "Error requesting power status: %d\n", status); + "Error requesting power status.\n"); return -1; } response = (rsppkt_t *)msg->data; - switch (status) { - case SBTS2050_STATUS_MASTER: - val_status = response->rsp.pwrGetStatus.u1MasterEn; - break; - case SBTS2050_STATUS_SLAVE: - val_status = response->rsp.pwrGetStatus.u1SlaveEn; - break; - case SBTS2050_STATUS_PA: - val_status = response->rsp.pwrGetStatus.u1PwrAmpEn; - break; - default: - msgb_free(msg); - return -1; - } + status->main_supply_current = response->rsp.pwrGetStatus.u8MainSupplyA / 64.f; + + status->master_enabled = response->rsp.pwrGetStatus.u1MasterEn; + status->master_voltage = response->rsp.pwrGetStatus.u8MasterV / 32.f; + status->master_current = response->rsp.pwrGetStatus.u8MasterA / 64.f;; + + status->slave_enabled = response->rsp.pwrGetStatus.u1SlaveEn; + status->slave_voltage = response->rsp.pwrGetStatus.u8SlaveV / 32.f; + status->slave_current = response->rsp.pwrGetStatus.u8SlaveA / 64.f; + + status->pa_enabled = response->rsp.pwrGetStatus.u1PwrAmpEn; + status->pa_voltage = response->rsp.pwrGetStatus.u8PwrAmpV / 4.f; + status->pa_current = response->rsp.pwrGetStatus.u8PwrAmpA / 64.f; + + status->pa_bias_voltage = response->rsp.pwrGetStatus.u8PwrAmpBiasV / 16.f; + msgb_free(msg); - return val_status; + return 0; } /********************************************************************** diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c index 92e1073e..1cabe44a 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c @@ -107,9 +107,32 @@ DEFUN(show_mgr, show_mgr_cmd, "show manager", VTY_NEWLINE); if (is_sbts2050_master()) { int temp_pa, temp_board; + struct sbts2050_power_status status; + sbts2050_uc_check_temp(&temp_pa, &temp_board); vty_out(vty, " sysmoBTS 2050 PA: %d Celcius%s", temp_pa, VTY_NEWLINE); vty_out(vty, " sysmoBTS 2050 PA: %d CelciusC%s", temp_board, VTY_NEWLINE); + + sbts2050_uc_get_status(&status); + vty_out(vty, "Power Status%s", VTY_NEWLINE); + vty_out(vty, " Main Supply :(ON) [(24.00)Vdc, %4.2f A]%s", + status.main_supply_current, VTY_NEWLINE); + vty_out(vty, " Master SF : %s [%6.2f Vdc, %4.2f A]%s", + status.master_enabled ? "ON " : "OFF", + status.master_voltage, status.master_current, + VTY_NEWLINE); + vty_out(vty, " Slave SF : %s [%6.2f Vdc, %4.2f A]%s", + status.slave_enabled ? "ON" : "OFF", + status.slave_voltage, status.slave_current, + VTY_NEWLINE); + vty_out(vty, " Power Amp : %s [%6.2f Vdc, %4.2f A]%s", + status.pa_enabled ? "ON" : "OFF", + status.pa_voltage, status.pa_current, + VTY_NEWLINE); + vty_out(vty, " PA Bias : %s [%6.2f Vdc, ---- A]%s", + status.pa_enabled ? "ON" : "OFF", + status.pa_bias_voltage, + VTY_NEWLINE); } return CMD_SUCCESS; diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h index 238095dd..9d1bb47b 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h @@ -21,12 +21,6 @@ enum sysmobts_temp_type { _NUM_TEMP_TYPES }; -enum sbts2050_status_rqt { - SBTS2050_STATUS_MASTER, - SBTS2050_STATUS_SLAVE, - SBTS2050_STATUS_PA -}; - int sysmobts_temp_get(enum sysmobts_temp_sensor sensor, enum sysmobts_temp_type type); @@ -47,9 +41,27 @@ int is_sbts2050(void); int is_sbts2050_trx(int); int is_sbts2050_master(void); +struct sbts2050_power_status { + float main_supply_current; + + int master_enabled; + float master_voltage; + float master_current; + + int slave_enabled; + float slave_voltage; + float slave_current; + + int pa_enabled; + float pa_voltage; + float pa_current; + + float pa_bias_voltage; +}; + void sbts2050_uc_check_temp(int *temp_pa, int *temp_board); void sbts2050_uc_set_power(int pmaster, int pslave, int ppa); -int sbts2050_uc_get_status(enum sbts2050_status_rqt status); +int sbts2050_uc_get_status(struct sbts2050_power_status *status); void sbts2050_uc_initialize(); #endif -- cgit v1.2.3