aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
diff options
context:
space:
mode:
authorÁlvaro Neira Ayuso <anayuso@sysmocom.de>2014-03-12 16:19:59 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-03-12 16:27:38 +0100
commite030dfd443f50803835e6525265cdf6a378e334a (patch)
tree10a90a2f9c7cf85ce475c442ad218d8ed8624924 /src/osmo-bts-sysmo/misc/sysmobts_mgr.c
parent21104720f790eac667f73f012863a59ecbeb58d1 (diff)
misc/sysmobts_misc.c: Read temperature from microcontroller
Add function for requesting the temperature information to the microcontroller. I have added a function that we can extend for requesting more information but in this case we only need to know the temperature. I have added to a microcontroller temperature handling function in the manager for monitoring this information. Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
Diffstat (limited to 'src/osmo-bts-sysmo/misc/sysmobts_mgr.c')
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
index 171f79b7..3a2c10c5 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -35,6 +35,7 @@
#include <osmocom/core/application.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/msgb.h>
+#include <osmocom/core/serial.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
@@ -53,6 +54,58 @@ void *tall_mgr_ctx;
/* every 1 hours means 365*24 = 8760 EEprom writes per year (max) */
#define HOURS_TIMER_SECS (1 * 3600)
+#ifdef BUILD_SBTS2050
+static struct osmo_timer_list temp_uc_timer;
+static void check_uctemp_timer_cb(void *data)
+{
+ int temp_pa = 0, temp_board = 0;
+ struct uc *ucontrol0 = data;
+
+ sbts2050_uc_check_temp(ucontrol0, &temp_pa, &temp_board);
+
+ osmo_timer_schedule(&temp_uc_timer, TEMP_TIMER_SECS, 0);
+}
+#endif
+
+static void initialize_sbts2050(void)
+{
+#ifdef BUILD_SBTS2050
+ static struct uc ucontrol0 = {
+ .id = 0,
+ .path = "/dev/ttyS0"
+ };
+ int val;
+
+ if (sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val) < 0) {
+ LOGP(DFIND, LOGL_ERROR,
+ "Failed to get Model number\n");
+ return;
+ }
+
+ if (val == 2050) {
+ if (sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val) < 0) {
+ LOGP(DFIND, LOGL_ERROR,
+ "Failed to get the TRX number\n");
+ return;
+ }
+
+ if (val != 0)
+ return;
+ }
+
+ ucontrol0.fd = osmo_serial_init(ucontrol0.path, 115200);
+ if (ucontrol0.fd < 0) {
+ LOGP(DFIND, LOGL_ERROR,
+ "Failed to open the serial interface\n");
+ return;
+ }
+
+ temp_uc_timer.cb = check_uctemp_timer_cb;
+ temp_uc_timer.data = &ucontrol0;
+ check_uctemp_timer_cb(&ucontrol0);
+#endif
+}
+
static struct osmo_timer_list temp_timer;
static void check_temp_timer_cb(void *unused)
{
@@ -309,6 +362,9 @@ int main(int argc, char **argv)
hours_timer.cb = hours_timer_cb;
hours_timer_cb(NULL);
+ /* start uc temperature check timer */
+ initialize_sbts2050();
+
/* handle broadcast messages for ipaccess-find */
fd.cb = ipaccess_bcast;
rc = osmo_sock_init_ofd(&fd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,