aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-16 13:49:50 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-16 13:49:50 +0100
commit19224b4b9b6767dedabfbcbcf41b9eab94b852f9 (patch)
treee939f9843a818a48abf37de0ae55914594fe06a9
parent3e110ae14101e60edc00803131165f11d4212db1 (diff)
sysmobts-mgr: Make it possible to not write to the EEPROM
For testing/trial it is better to not write to the EEPROM but it is still good to see how the logic is working.
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr.c42
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.c25
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.h4
3 files changed, 53 insertions, 18 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
index 01d65ce..0340243 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -1,6 +1,7 @@
/* Main program for SysmoBTS management daemon */
/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2014 by Holger Hans Peter Freyther
*
* All Rights Reserved
*
@@ -39,6 +40,7 @@
#include "misc/sysmobts_misc.h"
#include "misc/sysmobts_mgr.h"
+static int no_eeprom_write = 0;
static int daemonize = 0;
void *tall_mgr_ctx;
@@ -51,7 +53,7 @@ void *tall_mgr_ctx;
static struct osmo_timer_list temp_timer;
static void check_temp_timer_cb(void *unused)
{
- sysmobts_check_temp();
+ sysmobts_check_temp(no_eeprom_write);
osmo_timer_schedule(&temp_timer, TEMP_TIMER_SECS, 0);
}
@@ -59,19 +61,45 @@ static void check_temp_timer_cb(void *unused)
static struct osmo_timer_list hours_timer;
static void hours_timer_cb(void *unused)
{
- sysmobts_update_hours();
+ sysmobts_update_hours(no_eeprom_write);
osmo_timer_schedule(&hours_timer, HOURS_TIMER_SECS, 0);
}
+static void print_help(void)
+{
+ printf("sysmobts-mgr [-n]\n");
+ printf(" -n Do not write to EEPROM\n");
+}
+
+static int parse_options(int argc, char **argv)
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "nh")) != -1) {
+ switch (opt) {
+ case 'n':
+ no_eeprom_write = 1;
+ break;
+ case 'h':
+ print_help();
+ return -1;
+ default:
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static void signal_handler(int signal)
{
fprintf(stderr, "signal %u received\n", signal);
switch (signal) {
case SIGINT:
- sysmobts_check_temp();
- sysmobts_update_hours();
+ sysmobts_check_temp(no_eeprom_write);
+ sysmobts_update_hours(no_eeprom_write);
exit(0);
break;
case SIGABRT:
@@ -126,12 +154,14 @@ int main(int argc, char **argv)
void *tall_msgb_ctx;
int rc;
+ rc = parse_options(argc, argv);
+ if (rc < 0)
+ exit(2);
+
tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager");
tall_msgb_ctx = talloc_named_const(tall_mgr_ctx, 1, "msgb");
msgb_set_talloc_ctx(tall_msgb_ctx);
- //handle_options(argc, argv);
-
mgr_log_init(NULL);
signal(SIGINT, &signal_handler);
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.c b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
index c4f308a..74414d0 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
@@ -106,7 +106,7 @@ static const struct {
}
};
-void sysmobts_check_temp(void)
+void sysmobts_check_temp(int no_eeprom_write)
{
int temp_old[ARRAY_SIZE(temp_data)];
int temp_hi[ARRAY_SIZE(temp_data)];
@@ -135,12 +135,15 @@ void sysmobts_check_temp(void)
LOGP(DTEMP, LOGL_NOTICE, "New maximum %s "
"temperature: %d.%d C\n", temp_data[i].name,
temp_hi[i]/1000, temp_hi[i]%1000);
- rc = sysmobts_par_set_int(SYSMOBTS_PAR_TEMP_DIG_MAX,
+
+ if (!no_eeprom_write) {
+ rc = sysmobts_par_set_int(SYSMOBTS_PAR_TEMP_DIG_MAX,
temp_hi[0]/1000);
- if (rc < 0)
- LOGP(DTEMP, LOGL_ERROR, "error writing new %s "
- "max temp %d (%s)\n", temp_data[i].name,
- rc, strerror(errno));
+ if (rc < 0)
+ LOGP(DTEMP, LOGL_ERROR, "error writing new %s "
+ "max temp %d (%s)\n", temp_data[i].name,
+ rc, strerror(errno));
+ }
}
}
}
@@ -150,7 +153,7 @@ void sysmobts_check_temp(void)
*********************************************************************/
static time_t last_update;
-int sysmobts_update_hours(void)
+int sysmobts_update_hours(int no_eeprom_write)
{
time_t now = time(NULL);
int rc, op_hrs;
@@ -188,9 +191,11 @@ int sysmobts_update_hours(void)
LOGP(DTEMP, LOGL_INFO, "Total hours of Operation: %u\n",
op_hrs);
- rc = sysmobts_par_set_int(SYSMOBTS_PAR_HOURS, op_hrs);
- if (rc < 0)
- return rc;
+ if (!no_eeprom_write) {
+ rc = sysmobts_par_set_int(SYSMOBTS_PAR_HOURS, op_hrs);
+ if (rc < 0)
+ return rc;
+ }
last_update = now;
}
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
index 13d0add..8f7da47 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
@@ -16,9 +16,9 @@ enum sysmobts_temp_type {
int sysmobts_temp_get(enum sysmobts_temp_sensor sensor,
enum sysmobts_temp_type type);
-void sysmobts_check_temp(void);
+void sysmobts_check_temp(int no_eeprom_write);
-int sysmobts_update_hours(void);
+int sysmobts_update_hours(int no_epprom_write);
enum sysmobts_firmware_type {
SYSMOBTS_FW_FPGA,