aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-31 19:35:41 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-08-21 15:49:06 +0200
commitc84ca8c82fa1383efc96016e206bce709ed9b9d4 (patch)
tree30d5199948d9f294a1dfe547696a3a89bd95f53f
parent035187b44ea12d0ff551973517c2525d0a8cf068 (diff)
sysmobts: Clean-up the parsing routines
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c49
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.h29
2 files changed, 38 insertions, 40 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
index c772b53..c480a7a 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
@@ -35,6 +35,12 @@
#define SIZE_HEADER_RSP 5
#define SIZE_HEADER_CMD 4
+struct ucinfo {
+ uint16_t id;
+ int master;
+ int slave;
+ int pa;
+};
/**********************************************************************
* Functions read/write from serial interface
@@ -89,7 +95,7 @@ static void add_parity(cmdpkt_t *command)
command->cmd.raw[command->u8Len] = parity;
}
-static struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, struct ucinfo info)
+static struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, const struct ucinfo *info)
{
int num, rc;
cmdpkt_t *command;
@@ -100,7 +106,7 @@ static struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, struct ucinfo info)
.tv_sec = 10,
};
- switch (info.id) {
+ switch (info->id) {
case SBTS2050_TEMP_RQT:
num = sizeof(command->cmd.tempGet);
break;
@@ -123,20 +129,20 @@ static struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, struct ucinfo info)
command = (cmdpkt_t *) msgb_put(msg, num);
command->u16Magic = 0xCAFE;
- switch (info.id) {
+ switch (info->id) {
case SBTS2050_TEMP_RQT:
- command->u8Id = info.id;
+ command->u8Id = info->id;
command->u8Len = sizeof(command->cmd.tempGet);
break;
case SBTS2050_PWR_RQT:
- command->u8Id = info.id;
+ command->u8Id = info->id;
command->u8Len = sizeof(command->cmd.pwrSetState);
- command->cmd.pwrSetState.u1MasterEn = !!info.master;
- command->cmd.pwrSetState.u1SlaveEn = !!info.slave;
- command->cmd.pwrSetState.u1PwrAmpEn = !!info.pa;
+ command->cmd.pwrSetState.u1MasterEn = !!info->master;
+ command->cmd.pwrSetState.u1SlaveEn = !!info->slave;
+ command->cmd.pwrSetState.u1PwrAmpEn = !!info->pa;
break;
case SBTS2050_PWR_STATUS:
- command->u8Id = info.id;
+ command->u8Id = info->id;
command->u8Len = sizeof(command->cmd.pwrGetStatus);
break;
default:
@@ -162,7 +168,7 @@ static struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, struct ucinfo info)
response = (rsppkt_t *)msg->data;
- if (response->u8Id != info.id || msg->len <= 0 ||
+ if (response->u8Id != info->id || msg->len <= 0 ||
response->i8Error != RQT_SUCCESS)
goto err;
@@ -184,19 +190,20 @@ err:
/**********************************************************************
* Get power status function
*********************************************************************/
-int sbts2050_uc_status(struct uc *ucontrol, enum sbts2050_status_rqt status)
+int sbts2050_uc_get_status(struct uc *ucontrol, enum sbts2050_status_rqt status)
{
struct msgb *msg;
- struct ucinfo info = {
+ const struct ucinfo info = {
.id = SBTS2050_PWR_STATUS,
};
rsppkt_t *response;
int val_status;
- msg = sbts2050_ucinfo_get(ucontrol, info);
+ msg = sbts2050_ucinfo_get(ucontrol, &info);
if (msg == NULL) {
- LOGP(DTEMP, LOGL_ERROR, "Error switching off some unit");
+ LOGP(DTEMP, LOGL_ERROR,
+ "Error requesting power status: %d\n", status);
return -1;
}
@@ -223,20 +230,20 @@ int sbts2050_uc_status(struct uc *ucontrol, enum sbts2050_status_rqt status)
/**********************************************************************
* Uc Power Switching handling
*********************************************************************/
-void sbts2050_uc_power(struct uc *ucontrol, int pmaster, int pslave, int ppa)
+void sbts2050_uc_set_power(struct uc *ucontrol, int pmaster, int pslave, int ppa)
{
struct msgb *msg;
- struct ucinfo info = {
- .id = 0x00,
+ const struct ucinfo info = {
+ .id = SBTS2050_PWR_RQT,
.master = pmaster,
.slave = pslave,
.pa = ppa
};
- msg = sbts2050_ucinfo_get(ucontrol, info);
+ msg = sbts2050_ucinfo_get(ucontrol, &info);
if (msg == NULL) {
- LOGP(DTEMP, LOGL_ERROR, "Error switching off some unit");
+ LOGP(DTEMP, LOGL_ERROR, "Error switching off some unit.\n");
return;
}
@@ -258,11 +265,11 @@ void sbts2050_uc_check_temp(struct uc *ucontrol, int *temp_pa, int *temp_board)
{
rsppkt_t *response;
struct msgb *msg;
- struct ucinfo info = {
+ const struct ucinfo info = {
.id = SBTS2050_TEMP_RQT,
};
- msg = sbts2050_ucinfo_get(ucontrol, info);
+ msg = sbts2050_ucinfo_get(ucontrol, &info);
if (msg == NULL) {
LOGP(DTEMP, LOGL_ERROR, "Error reading temperature\n");
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
index dc57639..7df3587 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
@@ -21,30 +21,11 @@ enum sbts2050_status_rqt {
SBTS2050_STATUS_PA
};
-struct uc {
- int id;
- int fd;
- const char *path;
-};
-
-struct ucinfo {
- uint16_t id;
- int master;
- int slave;
- int pa;
-};
-
int sysmobts_temp_get(enum sysmobts_temp_sensor sensor,
enum sysmobts_temp_type type);
void sysmobts_check_temp(int no_eeprom_write);
-void sbts2050_uc_check_temp(struct uc *ucontrol, int *temp_pa, int *temp_board);
-
-void sbts2050_uc_power(struct uc *ucontrol, int pmaster, int pslave, int ppa);
-
-int sbts2050_uc_status(struct uc *ucontrol, enum sbts2050_status_rqt status);
-
int sysmobts_update_hours(int no_epprom_write);
enum sysmobts_firmware_type {
@@ -55,4 +36,14 @@ enum sysmobts_firmware_type {
int sysmobts_firmware_reload(enum sysmobts_firmware_type type);
+
+struct uc {
+ int id;
+ int fd;
+ const char *path;
+};
+void sbts2050_uc_check_temp(struct uc *ucontrol, int *temp_pa, int *temp_board);
+void sbts2050_uc_set_power(struct uc *ucontrol, int pmaster, int pslave, int ppa);
+int sbts2050_uc_get_status(struct uc *ucontrol, enum sbts2050_status_rqt status);
+
#endif