From 4a8ec296fac9c92b0f7cc190ff6702c51b9cda6e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 6 Sep 2023 17:53:06 +0200 Subject: [PATCH] WIP: generic board-info Change-Id: I0642269c924a0abe464a64c004681f507f14bc92 --- .../include/osmocom/simtrace2/simtrace2_api.h | 1 + host/lib/simtrace2_api.c | 13 ++++++++ host/src/simtrace2-tool.c | 32 ++++++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/host/include/osmocom/simtrace2/simtrace2_api.h b/host/include/osmocom/simtrace2/simtrace2_api.h index d658d161..867352dc 100644 --- a/host/include/osmocom/simtrace2/simtrace2_api.h +++ b/host/include/osmocom/simtrace2/simtrace2_api.h @@ -44,6 +44,7 @@ struct osmo_st2_cardem_inst { int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg, uint8_t msg_class, uint8_t msg_type); +int osmo_st2_generic_request_board_info(struct osmo_st2_slot *slot); int osmo_st2_cardem_request_card_insert(struct osmo_st2_cardem_inst *ci, bool inserted); int osmo_st2_cardem_request_pb_and_rx(struct osmo_st2_cardem_inst *ci, uint8_t pb, uint8_t le); diff --git a/host/lib/simtrace2_api.c b/host/lib/simtrace2_api.c index 4ad7eb75..c3c61a4d 100644 --- a/host/lib/simtrace2_api.c +++ b/host/lib/simtrace2_api.c @@ -154,6 +154,19 @@ int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg, return rc; } +/*********************************************************************** + * Generic protocol + ***********************************************************************/ + +/*! \brief Requeset the SIMtrace2 board information structure from the device */ +int osmo_st2_generic_request_board_info(struct osmo_st2_slot *slot) +{ + struct msgb *msg = st_msgb_alloc(); + + return osmo_st2_slot_tx_msg(0, msg, SIMTRACE_MSGC_GENERIC, SIMTRACE_CMD_BD_BOARD_INFO); +} + + /*********************************************************************** * Card Emulation protocol ***********************************************************************/ diff --git a/host/src/simtrace2-tool.c b/host/src/simtrace2-tool.c index fdf0d566..6b81bce6 100644 --- a/host/src/simtrace2-tool.c +++ b/host/src/simtrace2-tool.c @@ -63,6 +63,7 @@ static void print_help(void) "\n" ); printf( "Commands:\n" + "\tgeneric board-info\n" "\tmodem reset (enable|disable|cycle)\n" "\tmodem sim-switch (local|remote)\n" "\tmodem sim-card (insert|remove)\n" @@ -216,6 +217,33 @@ static int do_subsys_modem(int argc, char **argv) return rc; } + +static int do_generic_board_info(int argc, char **argv) +{ + return osmo_st2_generic_request_board_info(ci->slot); +} + +static int do_subsys_generic(int argc, char **argv) +{ + char *command; + int rc; + + if (argc < 1) + return -EINVAL; + command = argv[0]; + argc--; + argv++; + + if (!strcmp(command, "board-info")) { + rc = do_generic_board_info(argc, argv); + } else { + fprintf(stderr, "Unsupported command for subsystem generic: '%s'\n", command); + return -EINVAL; + } + + return rc; +} + static int do_command(int argc, char **argv) { char *subsys; @@ -227,7 +255,9 @@ static int do_command(int argc, char **argv) argc--; argv++; - if (!strcmp(subsys, "modem")) + if (!strcmp(subsys, "generic")) { + rc= do_subsys_generic(argc, argv); + } else if (!strcmp(subsys, "modem")) rc = do_subsys_modem(argc, argv); else { fprintf(stderr, "Unsupported subsystem '%s'\n", subsys);