diff options
author | Max <msuraev@sysmocom.de> | 2017-07-18 18:34:29 +0200 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2017-07-19 11:47:47 +0200 |
commit | 2d2fca434209f96ae2c3b9e0221c6a063d23dfd9 (patch) | |
tree | 1cfb1ef45cbf0ee6eb3b2a6eb567531afe820451 /src/osmo-bts-litecell15/misc/lc15bts_par.c | |
parent | b2bbc819218c0f842ad00a1608725cccb780e6bd (diff) |
lc15: port lc15bts-mgr changes
That's mostly changes related to lc15bts-mgr from
https://gitlab.com/nrw_noa/osmo-bts branch nrw/litecell15 based on
eb5b7f80510b603579f7af6d7d5ead296c2fa260 commit.
I wanted to incorporate vty and hardcoded paths changes so we can use it
from this point without major backward-incompatible changes as a base
for future ports.
Change-Id: Iabbaedc84aaaa594150a4e5445c16dd1f6f89858
Related: SYS#3679
Diffstat (limited to 'src/osmo-bts-litecell15/misc/lc15bts_par.c')
-rw-r--r-- | src/osmo-bts-litecell15/misc/lc15bts_par.c | 80 |
1 files changed, 71 insertions, 9 deletions
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_par.c b/src/osmo-bts-litecell15/misc/lc15bts_par.c index 13b00803..75314a44 100644 --- a/src/osmo-bts-litecell15/misc/lc15bts_par.c +++ b/src/osmo-bts-litecell15/misc/lc15bts_par.c @@ -43,12 +43,19 @@ 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_PWR_SUPPLY_MAX, "pwr-supply-max" }, + { LC15BTS_PAR_PWR_PA0_MAX, "pwr-pa0-max" }, + { LC15BTS_PAR_PWR_PA1_MAX, "pwr-pa1-max" }, + { LC15BTS_PAR_VSWR_TX0_MAX, "vswr-tx0-max" }, + { LC15BTS_PAR_VSWR_TX1_MAX, "vswr-tx1-max" }, + { LC15BTS_PAR_GPS_FIX, "gps-fix" }, { LC15BTS_PAR_SERNR, "serial-nr" }, { LC15BTS_PAR_HOURS, "hours-running" }, { LC15BTS_PAR_BOOTS, "boot-count" }, @@ -60,17 +67,23 @@ int lc15bts_par_is_int(enum lc15bts_par par) { switch (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_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_TEMP_SOC_MAX: + case LC15BTS_PAR_TEMP_FPGA_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: + case LC15BTS_PAR_PWR_SUPPLY_MAX: + case LC15BTS_PAR_PWR_PA0_MAX: + case LC15BTS_PAR_PWR_PA1_MAX: return 1; default: return 0; @@ -168,3 +181,52 @@ int lc15bts_par_set_buf(void *ctx, enum lc15bts_par par, const uint8_t *buf, uns return rc; } + +int lc15bts_par_get_gps_fix(time_t *ret) +{ + char fpath[PATH_MAX]; + FILE *fp; + int rc; + + snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, LC15BTS_PAR_GPS_FIX)); + fpath[sizeof(fpath)-1] = '\0'; + + fp = fopen(fpath, "r"); + if (fp == NULL) { + return -errno; + } + + rc = fscanf(fp, "%lld", (long long *)ret); + if (rc != 1) { + fclose(fp); + return -EIO; + } + fclose(fp); + + return 0; +} + +int lc15bts_par_set_gps_fix(time_t val) +{ + char fpath[PATH_MAX]; + FILE *fp; + int rc; + + snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, LC15BTS_PAR_GPS_FIX)); + fpath[sizeof(fpath)-1] = '\0'; + + fp = fopen(fpath, "w"); + if (fp == NULL) { + return -errno; + } + + rc = fprintf(fp, "%lld", (long long)val); + if (rc < 0) { + fclose(fp); + return -EIO; + } + fsync(fp); + fclose(fp); + + return 0; +} |