fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/35654?usp=email )
Change subject: osmo-bts-trx: add test VTY command to send arbitrary TRXC messages ......................................................................
osmo-bts-trx: add test VTY command to send arbitrary TRXC messages
Change-Id: Iabc9b702e5f1513187e24f45d9ffe06ea940c3ec --- M src/osmo-bts-trx/trx_if.c M src/osmo-bts-trx/trx_if.h M src/osmo-bts-trx/trx_vty.c 3 files changed, 50 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/54/35654/1
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 89078a3..b6b20e9 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -227,8 +227,8 @@ * The new command will be added to the end of the control command * queue. */ -static int trx_ctrl_cmd_cb(struct trx_l1h *l1h, int critical, void *cb, const char *cmd, - const char *fmt, ...) +int trx_ctrl_cmd_cb(struct trx_l1h *l1h, int critical, void *cb, + const char *cmd, const char *fmt, ...) { struct trx_ctrl_msg *tcm; struct trx_ctrl_msg *prev = NULL; @@ -277,7 +277,6 @@
return 0; } -#define trx_ctrl_cmd(l1h, critical, cmd, fmt, ...) trx_ctrl_cmd_cb(l1h, critical, NULL, cmd, fmt, ##__VA_ARGS__)
/*! Send "POWEROFF" command to TRX */ int trx_if_cmd_poweroff(struct trx_l1h *l1h, trx_if_cmd_poweronoff_cb *cb) diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index b838b76..3a22a1b 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -48,3 +48,7 @@
/* Format negotiation command */ int trx_if_cmd_setformat(struct trx_l1h *l1h, uint8_t ver, trx_if_cmd_generic_cb *cb); + +int trx_ctrl_cmd_cb(struct trx_l1h *l1h, int critical, void *cb, + const char *cmd, const char *fmt, ...); +#define trx_ctrl_cmd(l1h, critical, cmd, fmt, ...) trx_ctrl_cmd_cb(l1h, critical, NULL, cmd, fmt, ##__VA_ARGS__) diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index 998e9cb..f132937 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -194,6 +194,39 @@ return CMD_SUCCESS; }
+DEFUN_HIDDEN(test_send_trxc, + test_send_trxc_cmd, + "test send-trxc-cmd <0-255> CMD [.ARGS]", + "Various testing commands\n" + "Send an arbitrary TRX command\n" + "Transceiver number\n" + "TRXC command\n" "TRXC command arguments\n") +{ + const struct gsm_bts_trx *trx; + const struct phy_instance *pinst; + struct trx_l1h *l1h; + int rc; + + trx = gsm_bts_trx_num(g_bts, atoi(argv[0])); + if (trx == NULL) { + vty_out(vty, "%% Cound not find TRX%s", VTY_NEWLINE); + return CMD_WARNING; + } + + pinst = trx_phy_instance(trx); + l1h = pinst->u.osmotrx.hdl; + + if (argc > 2) { + char *cmd_args = argv_concat(argv, argc, 2); + rc = trx_ctrl_cmd(l1h, 0, argv[1], "%s", cmd_args); + talloc_free(cmd_args); + } else { + rc = trx_ctrl_cmd(l1h, 0, argv[1], ""); + } + + return (rc == 0) ? CMD_SUCCESS : CMD_WARNING; +} + DEFUN_USRATTR(cfg_trx_nominal_power, cfg_trx_nominal_power_cmd, X(BTS_VTY_TRX_POWERCYCLE), "nominal-tx-power <-10-100>", @@ -630,6 +663,8 @@ install_element_ve(&show_transceiver_cmd); install_element_ve(&show_phy_cmd);
+ install_element(ENABLE_NODE, &test_send_trxc_cmd); + install_element(TRX_NODE, &cfg_trx_nominal_power_cmd); install_element(TRX_NODE, &cfg_trx_no_nominal_power_cmd);